From a43b02076cb1b59ff463bb56418349db18dcc422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?= <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de> Date: Wed, 12 May 2021 01:16:50 +0200 Subject: [PATCH] Fix temporary m2m relations of constraint violation Previously, ak and ak slot sets were modelled as class attributes, which could cause wrong AKs to show up in a relation when multiple constraints were updated in the same function call --- AKModel/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/AKModel/models.py b/AKModel/models.py index 1cd08ac8..e1435c3e 100644 --- a/AKModel/models.py +++ b/AKModel/models.py @@ -465,6 +465,11 @@ class ConstraintViolation(models.Model): fields = ['ak_owner', 'room', 'requirement', 'category'] fields_mm = ['_aks', '_ak_slots'] + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.aks_tmp = set() + self.ak_slots_tmp = set() + def get_details(self): """ Get details of this constraint (all fields connected to it) @@ -500,8 +505,6 @@ class ConstraintViolation(models.Model): def timestamp_display(self): return self.timestamp.astimezone(self.event.timezone).strftime('%d.%m.%y %H:%M') - aks_tmp = set() - @property def _aks(self): """ @@ -517,8 +520,6 @@ class ConstraintViolation(models.Model): return set(self.aks.all()) return self.aks_tmp - ak_slots_tmp = set() - @property def _aks_str(self): if self.pk and self.pk > 0: -- GitLab