This commit is contained in:
Ross
2022-02-24 19:16:08 +00:00
parent 81e2d2cb32
commit e07ba636f9
2 changed files with 8 additions and 19 deletions
-15
View File
@@ -134,21 +134,6 @@ class RapidForm(ModelForm):
for exam in self.cleaned_data["exams"]:
exam.exam_questions.add(instance)
# # Prepare a 'save_m2m' method for the form,
# old_save_m2m = self.save_m2m
#
# def save_m2m():
# old_save_m2m()
# # This is where we actually link the pizza with toppings
# instance.exams.clear()
# for exam in self.cleaned_data["exams"]:
# instance.exams.add(exam)
#
# self.save_m2m = save_m2m
#
# # Do we need to save all changes now?
# # if commit:
# instance.save()
self.save_m2m()
return instance
+4
View File
@@ -370,7 +370,11 @@ class RapidUpdate(
answer_formset.save()
# restore exam orders
wanted_exams = form["exams"].data
for exam in self.object.exams.all():
# Only readd if exam is still added
# There is probably a better way to do this
if str(exam.pk) in wanted_exams:
if exam in exam_orders and self.object in exam_orders[exam]:
print(exam_orders[exam])
exam.exam_questions.set(exam_orders[exam])