diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-10-05 11:57:12 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-07-08 09:58:48 +0200 | 
| commit | 90f70cab6935ea31d45151ffde0862cf59d01c14 (patch) | |
| tree | 413cf2e6d461ecde4ecbfd25d0b2e716f8e9fb3e /archaeological_context_records/wizards.py | |
| parent | bac3bd38813fb2b9c303bb4214f4c5829a05e794 (diff) | |
| download | Ishtar-90f70cab6935ea31d45151ffde0862cf59d01c14.tar.bz2 Ishtar-90f70cab6935ea31d45151ffde0862cf59d01c14.zip  | |
Optimize context record wizard
Diffstat (limited to 'archaeological_context_records/wizards.py')
| -rw-r--r-- | archaeological_context_records/wizards.py | 11 | 
1 files changed, 8 insertions, 3 deletions
diff --git a/archaeological_context_records/wizards.py b/archaeological_context_records/wizards.py index da1364b28..e92d9587e 100644 --- a/archaeological_context_records/wizards.py +++ b/archaeological_context_records/wizards.py @@ -44,15 +44,18 @@ class RecordWizard(Wizard):          return templates      def get_current_operation(self): +        if hasattr(self, "_current_operation"): +            return self._current_operation          step = self.steps.current          if not step:              return -        # manage manualy on creation +        # manage manually on creation          if step.endswith("_creation"):  # an operation has been selected              main_form_key = "selec-" + self.url_name              try:                  idx = int(self.session_get_value(main_form_key, "operation_id"))                  current_ope = models.Operation.objects.get(pk=idx) +                self._current_operation = current_ope                  return current_ope              except (TypeError, ValueError, ObjectDoesNotExist):                  pass @@ -61,11 +64,13 @@ class RecordWizard(Wizard):              try:                  idx = int(self.session_get_value(ope_form_key, "operation"))                  current_ope = models.Operation.objects.get(pk=idx) +                self._current_operation = current_ope                  return current_ope              except (TypeError, ValueError, ObjectDoesNotExist):                  pass          current_cr = self.get_current_object()          if current_cr: +            self._current_operation = current_cr.operation              return current_cr.operation      def get_context_data(self, form, **kwargs): @@ -123,11 +128,11 @@ class RecordWizard(Wizard):          operation = self.get_current_operation()          if not operation:              return [] -        q = models.ContextRecord.objects.filter(operation=operation) +        q = models.ContextRecord.objects.filter(operation_id=operation.pk)          obj = self.get_current_object()          if obj and obj.pk:              q = q.exclude(pk=obj.pk) -        return [(cr.pk, str(cr)) for cr in q.all()] +        return [(cr.pk, cr.cached_label) for cr in q.all()]  class RecordModifWizard(RecordWizard):  | 
