adding in-stroke analysis delete
This commit is contained in:
@@ -4978,3 +4978,9 @@ class InStrokeAnalysis(models.Model):
|
||||
end_second = models.IntegerField(default=3600)
|
||||
spm_min = models.IntegerField(default=10)
|
||||
spm_max = models.IntegerField(default=45)
|
||||
|
||||
def __str__(self):
|
||||
s = 'In-Stroke Analysis {name} ({date})'.format(name = self.name,
|
||||
date = self.date)
|
||||
|
||||
return s
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="workoutelement">
|
||||
<a class="small" href="/rowers/instrokeanalysis/{{ analysis.id }}/delete/"
|
||||
<a class="small" href="/rowers/analysis/instrokeanalysis/{{ analysis.id }}/delete/"
|
||||
title="Delete">
|
||||
<i class="fas fa-trash-alt fa-fw"></i>
|
||||
</a>
|
||||
|
||||
29
rowers/templates/instrokeanalysis_delete_confirm.html
Normal file
29
rowers/templates/instrokeanalysis_delete_confirm.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{% extends "newbase.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}In-Stroke Analysis{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<h1>Confirm Delete</h1>
|
||||
<p>This will permanently delete the analysis</p>
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_2">
|
||||
<p>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
<p>Are you sure you want to delete <em>{{ object }}</em>?</p>
|
||||
<input class="button" type="submit" value="Confirm">
|
||||
</form>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_analytics.html' %}
|
||||
{% endblock %}
|
||||
@@ -254,6 +254,8 @@ urlpatterns = [
|
||||
views.instroke_chart_interactive, name='instroke_chart_interactive'),
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/instroke/interactive/(?P<analysis>\d+)/$',
|
||||
views.instroke_chart_interactive, name='instroke_chart_interactive'),
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/instroke/interactive/(?P<analysis>\d+)/user/(?P<userid>\d+)/$',
|
||||
views.instroke_chart_interactive, name='instroke_chart_interactive'),
|
||||
re_path(r'^exportallworkouts/?/$', views.workouts_summaries_email_view,
|
||||
name='workouts_summaries_email_view'),
|
||||
path('failedjobs/', views.failed_queue_view, name='failed_queue_view'),
|
||||
@@ -832,6 +834,8 @@ urlpatterns = [
|
||||
re_path(r'^analysis/$', views.analysis_view, name='analysis'),
|
||||
re_path(r'^analysis/instrokeanalysis/$', views.instrokeanalysis_view,
|
||||
name='instrokeanalysis_view'),
|
||||
re_path(r'^analysis/instrokeanalysis/(?P<pk>\d+)/delete/$',
|
||||
views.InStrokeAnalysisDelete.as_view(), name='instroke_analysis_delete_view'),
|
||||
re_path(r'^promembership', TemplateView.as_view(
|
||||
template_name='promembership.html'), name='promembership'),
|
||||
re_path(r'^checkout/(?P<planid>\d+)/$',
|
||||
|
||||
@@ -1845,7 +1845,10 @@ def agegrouprecordview(request, sex='male', weightcategory='hwt',
|
||||
})
|
||||
|
||||
|
||||
@login_required
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher."
|
||||
" If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
@permission_required('rower.is_coach', fn=get_user_by_userid, raise_exception=True)
|
||||
def instrokeanalysis_view(request, userid=0):
|
||||
r = getrequestrower(request, userid=userid)
|
||||
@@ -1885,6 +1888,61 @@ def instrokeanalysis_view(request, userid=0):
|
||||
'the_div': div,
|
||||
})
|
||||
|
||||
#instroke analysis delete view
|
||||
class InStrokeAnalysisDelete(DeleteView):
|
||||
login_required = True
|
||||
model = InStrokeAnalysis
|
||||
template_name = 'instrokeanalysis_delete_confirm.html'
|
||||
|
||||
# extra parameters
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(InStrokeAnalysisDelete, self).get_context_data(**kwargs)
|
||||
|
||||
if 'userid' in kwargs: # pragma: no cover
|
||||
userid = kwargs['userid']
|
||||
else:
|
||||
userid = 0
|
||||
|
||||
context['rower'] = getrequestrower(self.request, userid=userid)
|
||||
context['alert'] = self.object
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url': '/rowers/analysis',
|
||||
'name': 'Analysis'
|
||||
},
|
||||
{
|
||||
'url': reverse('instrokeanalysis_view'),
|
||||
'name': 'In-Stroke Analysis',
|
||||
},
|
||||
{
|
||||
'url': reverse('instroke_chart_interactive',
|
||||
kwargs={'userid': userid,
|
||||
'id': encoder.encode_hex(self.object.workout.id),
|
||||
'analysis': self.object.pk}),
|
||||
'name': self.object.name,
|
||||
},
|
||||
{
|
||||
'url': reverse('instroke_analysis_delete_view', kwargs={'pk': self.object.pk}),
|
||||
'name': 'Delete'
|
||||
}
|
||||
]
|
||||
|
||||
context['breadcrumbs'] = breadcrumbs
|
||||
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('instrokeanalysis_view')
|
||||
|
||||
def get_object(self, *args, **kwargs):
|
||||
obj = super(InStrokeAnalysisDelete, self).get_object(*args, **kwargs)
|
||||
|
||||
if obj.rower != self.request.user.rower:
|
||||
raise PermissionDenied("You are not allowed to delete this Analysis")
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
@login_required
|
||||
@permission_required('rower.is_coach', fn=get_user_by_userid, raise_exception=True)
|
||||
@@ -1918,8 +1976,6 @@ def alerts_view(request, userid=0):
|
||||
})
|
||||
|
||||
# alert create view
|
||||
|
||||
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher."
|
||||
" If you are already a Pro user, please log in to access this functionality",
|
||||
@@ -2174,8 +2230,6 @@ def alert_edit_view(request, id=0, userid=0):
|
||||
})
|
||||
|
||||
# alert delete view
|
||||
|
||||
|
||||
class AlertDelete(DeleteView):
|
||||
login_required = True
|
||||
model = Alert
|
||||
|
||||
@@ -2915,6 +2915,10 @@ def instroke_chart(request, id=0, metric=''): # pragma: no cover
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher."
|
||||
" If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
@permission_required('workout.change_workout', fn=get_workout_by_opaqueid, raise_exception=True)
|
||||
def instroke_chart_interactive(request, id=0, analysis=0, userid=0):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user