Skip to content

Commit 3cb3b83

Browse files
murhum1ihalaij1
authored andcommitted
Add "get_module_of_exercise" url param to deviations page
This is required for mooc-jutut's "add deadline deviation" button to work.
1 parent f554172 commit 3cb3b83

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

deviations/views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.http import HttpRequest, HttpResponse
66

77
from course.models import UserTag, UserTagging
8+
from exercise.exercise_models import BaseExercise
89
from .forms import (
910
DeadlineRuleDeviationForm,
1011
RemoveDeviationForm,
@@ -37,6 +38,13 @@ class AddDeadlinesView(AddDeviationsView):
3738
def get_success_no_override_url(self) -> str:
3839
return self.instance.get_url('deviations-add-dl')
3940

41+
def get_initial(self):
42+
initial = super().get_initial()
43+
if self.request.GET.get('get_module_of_exercise'):
44+
exercise = BaseExercise.objects.get(id=self.request.GET.get('get_module_of_exercise'))
45+
initial['module'] = [exercise.course_module.id]
46+
return initial
47+
4048
def get_initial_get_param_spec(self) -> Dict[str, Optional[Callable[[str], Any]]]:
4149
spec = super().get_initial_get_param_spec()
4250
spec.update({

0 commit comments

Comments
 (0)