diff options
Diffstat (limited to 'archaeological_context_records/wizards.py')
| -rw-r--r-- | archaeological_context_records/wizards.py | 30 | 
1 files changed, 14 insertions, 16 deletions
diff --git a/archaeological_context_records/wizards.py b/archaeological_context_records/wizards.py index 1fd657bcc..86ce3bd30 100644 --- a/archaeological_context_records/wizards.py +++ b/archaeological_context_records/wizards.py @@ -30,30 +30,29 @@ class RecordWizard(Wizard):      model = models.ContextRecord      edit = False -    def get_current_operation(self, request, storage): -        step = storage.get_current_step() +    def get_current_operation(self): +        step = self.steps.current          if not step:              return          if step.endswith('_creation'): # an operation has been selected              main_form_key = 'selec-' + self.url_name              try: -                idx = int(self.session_get_value(request, storage, -                                        main_form_key, 'operation_id')) +                idx = int(self.session_get_value(main_form_key, 'operation_id'))                  current_ope = models.Operation.objects.get(pk=idx)                  return current_ope              except(TypeError, ValueError, ObjectDoesNotExist):                  pass -        current_cr = self.get_current_object(request, storage) +        current_cr = self.get_current_object()          if current_cr:              return current_cr.parcel.operation -    def get_template_context(self, request, storage, form=None): +    # get_template_context +    def get_context_data(self, form, **kwargs):          """          Get the operation "reminder" on top of wizard forms          """ -        context = super(RecordWizard, self).get_template_context(request, -                                                            storage, form) -        operation = self.get_current_operation(request, storage) +        context = super(RecordWizard, self).get_context_data(form) +        operation = self.get_current_operation()          if not operation:              return context          items = [] @@ -64,7 +63,7 @@ class RecordWizard(Wizard):          context['reminder'] = _("Current operation: ") + " - ".join(items)          return context -    def get_form(self, request, storage, step=None, data=None, files=None): +    def get_form(self, step=None, data=None, files=None):          """          Get associated operation          """ @@ -75,24 +74,23 @@ class RecordWizard(Wizard):          if not step:              step = self.steps.current              #step = self.determine_step(request, storage) -        form = self.get_form_list(request, storage)[step] +        form = self.get_form_list()[step]          general_form_key = 'general-' + self.url_name          if step.startswith('general-'):              if step.endswith('_creation'): # an operation has been selected                  main_form_key = 'selec-' + self.url_name                  try: -                    idx = int(self.session_get_value(request, storage, -                                            main_form_key, 'operation_id')) +                    idx = int(self.session_get_value(main_form_key, +                                                     'operation_id'))                      current_obj = models.Operation.objects.get(pk=idx)                      data['operation'] = current_obj                  except(TypeError, ValueError, ObjectDoesNotExist):                      pass              else: -                current_object = self.get_current_object(request, storage) +                current_object = self.get_current_object()                  data['context_record'] = current_object -        form = super(RecordWizard, self).get_form(request, storage, step, data, -                                                  files) +        form = super(RecordWizard, self).get_form(step, data, files)          return form  class RecordModifWizard(RecordWizard):  | 
