diff --git a/rowers/templates/trainingplan.html b/rowers/templates/trainingplan.html
index e3d67466..721d6539 100644
--- a/rowers/templates/trainingplan.html
+++ b/rowers/templates/trainingplan.html
@@ -127,9 +127,9 @@
|
- edit
+ edit
/
- delete
+ delete
/
sessions
|
diff --git a/rowers/views.py b/rowers/views.py
index 7a232db9..4f80455c 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -14417,7 +14417,7 @@ class TrainingPlanDelete(DeleteView):
def get_object(self, *args, **kwargs):
obj = super(TrainingPlanDelete, self).get_object(*args, **kwargs)
if not checkaccessuser(self.request.user,obj.plan.rower):
- raise Http404
+ raise PermissionDenied('You are not allowed to delete this training plan')
return obj
@@ -14436,8 +14436,7 @@ class MicroCycleDelete(DeleteView):
def get_object(self, *args, **kwargs):
obj = super(MicroCycleDelete, self).get_object(*args, **kwargs)
if not checkaccessuser(self.request.user,obj.plan.plan.plan.rower):
- raise Http404
-
+ raise PermissionDenied('You are not allowed to delete this training plan cycle')
return obj
@@ -14456,7 +14455,7 @@ class MesoCycleDelete(DeleteView):
def get_object(self, *args, **kwargs):
obj = super(MesoCycleDelete, self).get_object(*args, **kwargs)
if not checkaccessuser(self.request.user,obj.plan.plan.rower):
- raise Http404
+ raise PermissionDenied('You are not allowed to delete this training plan cycle')
return obj
@@ -14476,7 +14475,7 @@ class MacroCycleDelete(DeleteView):
def get_object(self, *args, **kwargs):
obj = super(MacroCycleDelete, self).get_object(*args, **kwargs)
if not checkaccessuser(self.request.user,obj.plan.rower):
- raise Http404
+ raise PermissionDenied('You are not allowed to delete this training plan cycle')
return obj
@@ -14496,8 +14495,6 @@ def rower_trainingplan_view(request,id=0):
createmacrofillers(plan)
macrocycles = TrainingMacroCycle.objects.filter(plan=plan).order_by("startdate")
- count = 0
- cycles = {}
r = plan.rower
@@ -14514,8 +14511,7 @@ def rower_trainingplan_view(request,id=0):
mesocycles = TrainingMesoCycle.objects.filter(plan=m).order_by("startdate")
- mesos = {}
- count2 = 0
+
for me in mesocycles:
createmicrofillers(me)
me.plantime = 0
@@ -14586,11 +14582,30 @@ def rower_trainingplan_view(request,id=0):
m.actualtrimp += me.actualtrimp
- mesos[count2] = (me, microcycles)
- count2 += 1
if m.type == 'userdefined':
m.save()
+
+ createmacrofillers(plan)
+ macrocycles = TrainingMacroCycle.objects.filter(plan=plan).order_by("startdate")
+
+ count = 0
+ cycles = {}
+
+ r = plan.rower
+
+ for m in macrocycles:
+ createmesofillers(m)
+ mesocycles = TrainingMesoCycle.objects.filter(plan=m).order_by("startdate")
+ mesos = {}
+ count2 = 0
+ for me in mesocycles:
+ createmicrofillers(me)
+ microcycles = TrainingMicroCycle.objects.filter(plan=me).order_by("startdate")
+
+ mesos[count2] = (me, microcycles)
+ count2 += 1
+
cycles[count] = (m,mesos)
count += 1
@@ -14627,7 +14642,7 @@ class TrainingMacroCycleUpdate(UpdateView):
def get_object(self, *args, **kwargs):
obj = super(TrainingMacroCycleUpdate, self).get_object(*args, **kwargs)
if not checkaccessuser(self.request.user,obj.plan.rower):
- raise Http404
+ raise PermissionDenied('You are not allowed to edit this training plan cycle')
else:
obj.type = 'userdefined'
obj.save()
@@ -14659,7 +14674,7 @@ class TrainingMesoCycleUpdate(UpdateView):
obj = super(TrainingMesoCycleUpdate, self).get_object(*args, **kwargs)
r = obj.plan.plan.rower
if not checkaccessuser(self.request.user,r):
- raise Http404
+ raise PermissionDenied('You are not allowed to edit this training plan cycle')
else:
obj.type = 'userdefined'
obj.save()
@@ -14692,7 +14707,7 @@ class TrainingMicroCycleUpdate(UpdateView):
obj = super(TrainingMicroCycleUpdate, self).get_object(*args, **kwargs)
r = obj.plan.plan.plan.rower
if not checkaccessuser(self.request.user,r):
- raise Http404
+ raise PermissionDenied('You are not allowed to edit this training plan cycle')
else:
obj.type = 'userdefined'
obj.save()
@@ -14718,7 +14733,7 @@ class TrainingPlanUpdate(UpdateView):
def get_object(self, *args, **kwargs):
obj = super(TrainingPlanUpdate, self).get_object(*args, **kwargs)
if not checkaccessuser(self.request.user,obj.rower):
- raise Http404
+ raise PermissionDenied('You are not allowed to edit this training plan cycle')
return obj
class TrainingTargetUpdate(UpdateView):
@@ -14738,6 +14753,6 @@ class TrainingTargetUpdate(UpdateView):
def get_object(self, *args, **kwargs):
obj = super(TrainingTargetUpdate, self).get_object(*args, **kwargs)
if not checkaccessuser(self.request.user,obj.rower):
- raise Http404
+ raise PermissionDenied('You are not allowed to edit this training plan target')
return obj