Self hosted FLOSS fitness/workout, nutrition and weight tracker
Pass the form action to the exercise comments edit and add forms
Roland Geider9f830ba67db5
diff --git a/exercises/views.py b/exercises/views.pyindex ddbc2f3b4..68dd99e35 100644--- a/exercises/views.py+++ b/exercises/views.py@@ -244,10 +244,19 @@ class ExerciseCommentEditView(YamlFormMixin, UpdateView):active_tab = 'exercises'model = ExerciseCommentform_class = ExerciseCommentForm-+ title = ugettext_lazy('Edit exercise comment')+def get_success_url(self):return reverse('exercises.views.exercise_view', kwargs ={'id': self.object.exercise.id})+ # Send some additional data to the template+ def get_context_data(self, **kwargs):+ context = super(ExerciseCommentEditView, self).get_context_data(**kwargs)+ context['form_action'] = reverse('exercisecomment-edit',+ kwargs={'pk': self.object.id})++ return context+class ExerciseCommentAddView(YamlFormMixin, CreateView):"""@@ -257,6 +266,7 @@ class ExerciseCommentAddView(YamlFormMixin, CreateView):active_tab = 'exercises'model = ExerciseCommentform_class = ExerciseCommentForm+ title = ugettext_lazy('Add exercise comment')def form_valid(self, form):form.instance.exercise = Exercise.objects.get(pk = self.kwargs['exercise_pk'])@@ -267,6 +277,14 @@ class ExerciseCommentAddView(YamlFormMixin, CreateView):return reverse('exercises.views.exercise_view', kwargs ={'id': self.object.exercise.id})+ # Send some additional data to the template+ def get_context_data(self, **kwargs):+ context = super(ExerciseCommentAddView, self).get_context_data(**kwargs)+ context['form_action'] = reverse('exercisecomment-add',+ kwargs={'exercise_pk': self.kwargs['exercise_pk']})++ return context+@permission_required('exercises.delete_exercise')def exercise_delete(request, id):# Load the exercise