100 percent coverage on analysis views
This commit is contained in:
@@ -177,8 +177,6 @@ def set_strava_athlete_id(user):
|
|||||||
r.strava_owner_id = response.json()['id']
|
r.strava_owner_id = response.json()['id']
|
||||||
r.save()
|
r.save()
|
||||||
return response.json()['id']
|
return response.json()['id']
|
||||||
else:
|
|
||||||
print(response)
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@@ -775,7 +773,7 @@ def workout_strava_upload(user,w, quick=False,asynchron=True):
|
|||||||
activity_type = mytypes.stravamapping[w.workouttype]
|
activity_type = mytypes.stravamapping[w.workouttype]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
activity_type = 'Rowing'
|
activity_type = 'Rowing'
|
||||||
print(w.workouttype,activity_type)
|
|
||||||
with open(tcxfile,'rb') as f:
|
with open(tcxfile,'rb') as f:
|
||||||
res,mes = handle_stravaexport(
|
res,mes = handle_stravaexport(
|
||||||
f,w.name,
|
f,w.name,
|
||||||
|
|||||||
@@ -1916,7 +1916,7 @@ def alert_create_view(request,userid=0):
|
|||||||
@permission_required('rower.is_coach',fn=get_user_by_userid,raise_exception=True)
|
@permission_required('rower.is_coach',fn=get_user_by_userid,raise_exception=True)
|
||||||
def alert_report_view(request,id=0,userid=0,nperiod=0):
|
def alert_report_view(request,id=0,userid=0,nperiod=0):
|
||||||
r = getrequestrower(request,userid=userid)
|
r = getrequestrower(request,userid=userid)
|
||||||
if userid == 0:
|
if userid == 0: # pragma: no cover
|
||||||
userid = request.user.id
|
userid = request.user.id
|
||||||
|
|
||||||
alert = Alert.objects.get(id=id)
|
alert = Alert.objects.get(id=id)
|
||||||
@@ -1924,11 +1924,11 @@ def alert_report_view(request,id=0,userid=0,nperiod=0):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
alert = Alert.objects.get(id=id)
|
alert = Alert.objects.get(id=id)
|
||||||
except Alert.DoesNotExist:
|
except Alert.DoesNotExist: # pragma: no cover
|
||||||
raise Http404("This alert doesn't exist")
|
raise Http404("This alert doesn't exist")
|
||||||
|
|
||||||
|
|
||||||
if not checkalertowner(alert,request.user):
|
if not checkalertowner(alert,request.user): # pragma: no cover
|
||||||
raise PermissionDenied('You are not allowed to edit this Alert')
|
raise PermissionDenied('You are not allowed to edit this Alert')
|
||||||
|
|
||||||
stats = alert_get_stats(alert,nperiod=nperiod)
|
stats = alert_get_stats(alert,nperiod=nperiod)
|
||||||
@@ -1958,7 +1958,7 @@ def alert_report_view(request,id=0,userid=0,nperiod=0):
|
|||||||
kwargs={'userid':userid,'id':alert.id}),
|
kwargs={'userid':userid,'id':alert.id}),
|
||||||
'name': 'Report',
|
'name': 'Report',
|
||||||
},
|
},
|
||||||
]
|
] # pragma: no cover
|
||||||
return render(request,'alert_stats.html',
|
return render(request,'alert_stats.html',
|
||||||
{
|
{
|
||||||
'breadcrumbs':breadcrumbs,
|
'breadcrumbs':breadcrumbs,
|
||||||
@@ -1966,7 +1966,7 @@ def alert_report_view(request,id=0,userid=0,nperiod=0):
|
|||||||
'rower':r,
|
'rower':r,
|
||||||
'alert':alert,
|
'alert':alert,
|
||||||
'nperiod':nperiod,
|
'nperiod':nperiod,
|
||||||
})
|
}) # pragma: no cover
|
||||||
|
|
||||||
# alert edit view
|
# alert edit view
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
@@ -1978,15 +1978,15 @@ def alert_edit_view(request,id=0,userid=0):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
alert = Alert.objects.get(id=id)
|
alert = Alert.objects.get(id=id)
|
||||||
except Alert.DoesNotExist:
|
except Alert.DoesNotExist: # pragma: no cover
|
||||||
raise Http404("This alert doesn't exist")
|
raise Http404("This alert doesn't exist")
|
||||||
|
|
||||||
|
|
||||||
if alert.manager != request.user:
|
if alert.manager != request.user: # pragma: no cover
|
||||||
raise PermissionDenied('You are not allowed to edit this Alert')
|
raise PermissionDenied('You are not allowed to edit this Alert')
|
||||||
|
|
||||||
FilterFormSet = formset_factory(ConditionEditForm, formset=BaseConditionFormSet,extra=0)
|
FilterFormSet = formset_factory(ConditionEditForm, formset=BaseConditionFormSet,extra=0)
|
||||||
if len(alert.filter.all()) == 0:
|
if len(alert.filter.all()) == 0: # pragma: no cover
|
||||||
FilterFormSet = formset_factory(ConditionEditForm, formset=BaseConditionFormSet, extra=1)
|
FilterFormSet = formset_factory(ConditionEditForm, formset=BaseConditionFormSet, extra=1)
|
||||||
|
|
||||||
filter_data = [{'metric':m.metric,
|
filter_data = [{'metric':m.metric,
|
||||||
@@ -2090,7 +2090,7 @@ class AlertDelete(DeleteView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(AlertDelete, self).get_context_data(**kwargs)
|
context = super(AlertDelete, self).get_context_data(**kwargs)
|
||||||
|
|
||||||
if 'userid' in kwargs:
|
if 'userid' in kwargs: # pragma: no cover
|
||||||
userid = kwargs['userid']
|
userid = kwargs['userid']
|
||||||
else:
|
else:
|
||||||
userid = 0
|
userid = 0
|
||||||
@@ -2128,7 +2128,7 @@ class AlertDelete(DeleteView):
|
|||||||
def get_object(self, *args, **kwargs):
|
def get_object(self, *args, **kwargs):
|
||||||
obj = super(AlertDelete, self).get_object(*args, **kwargs)
|
obj = super(AlertDelete, self).get_object(*args, **kwargs)
|
||||||
|
|
||||||
if obj.manager != self.request.user:
|
if obj.manager != self.request.user: # pragma: no cover
|
||||||
raise PermissionDenied("You are not allowed to delete this Alert")
|
raise PermissionDenied("You are not allowed to delete this Alert")
|
||||||
|
|
||||||
# some checks
|
# some checks
|
||||||
|
|||||||
Reference in New Issue
Block a user