diff options
| -rw-r--r-- | archaeological_files/wizards.py | 1 | ||||
| -rw-r--r-- | archaeological_operations/wizards.py | 4 | ||||
| -rw-r--r-- | ishtar_common/views.py | 4 | ||||
| -rw-r--r-- | ishtar_common/wizards.py | 20 | 
4 files changed, 21 insertions, 8 deletions
| diff --git a/archaeological_files/wizards.py b/archaeological_files/wizards.py index 99ef593d9..6e1e3ba03 100644 --- a/archaeological_files/wizards.py +++ b/archaeological_files/wizards.py @@ -129,6 +129,7 @@ class FileDeletionWizard(FileClosingWizard):  class FileAdministrativeActWizard(OperationAdministrativeActWizard):      model = models.File +    current_obj_slug = 'administrativeactfile'      def get_reminder(self):          form_key = 'selec-' + self.url_name diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index 2e7b3c4b4..6e512e826 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -329,6 +329,7 @@ class OperationSourceDeletionWizard(DeletionWizard):  class OperationAdministrativeActWizard(OperationWizard):      edit = False      wizard_done_window = reverse_lazy('show-administrativeact') +    current_obj_slug = 'administrativeactop'      def get_reminder(self):          form_key = 'selec-' + self.url_name @@ -416,6 +417,9 @@ class OperationAdministrativeActWizard(OperationWizard):              if r and r[0]:                  dct['redirect'] = reverse('generatedoc-administrativeactop',                                            args=[admact.pk, r[0]]) +        # make the new object a default +        self.request.session[self.current_obj_slug] = unicode(admact.pk) +        self.request.session[self.get_object_name(admact)] = unicode(admact.pk)          res = render_to_response('ishtar/wizard/wizard_done.html', dct,                                   context_instance=RequestContext(self.request)) diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 981522d0d..6f95e070a 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -398,11 +398,11 @@ def get_item(model, func_name, default_name, extra_request_keys=[],                  q = Q(**{req_key: val})                  reqs = reqs | q              and_reqs.append(reqs) -        if not dct and 'submited' not in request_items: +        if 'submited' not in request_items:              if default_name in request.session and \                 request.session[default_name]:                  dct = {"pk": request.session[default_name]} -            else: +            elif not dct:                  for name in relative_session_names.keys():                      if name in request.session and request.session[name]:                          k = relative_session_names[name] diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index ffbf9b994..0b121fd76 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -103,6 +103,7 @@ class Wizard(NamedUrlWizardView):      wizard_confirm = 'ishtar/wizard/confirm_wizard.html'      wizard_templates = {}      filter_owns = {} +    current_obj_slug = ''      @staticmethod      def _check_right(step, condition=True): @@ -592,6 +593,10 @@ class Wizard(NamedUrlWizardView):                      # necessary to manage interaction between models like                      # material_index management for baseitems                      obj.save() +        # make the new object a default +        if self.current_obj_slug: +            self.request.session[self.current_obj_slug] = unicode(obj.pk) +        self.request.session[self.get_object_name(obj)] = unicode(obj.pk)          dct = {'item': obj}          # force evaluation of lazy urls          wizard_done_window = unicode(self.wizard_done_window) @@ -876,17 +881,20 @@ class Wizard(NamedUrlWizardView):                  return initial          return super(Wizard, self).get_form_initial(step) -    def get_instanced_init(self, obj, step=None): -        """Get initial data from an init""" -        current_step = step or self.steps.current -        c_form = self.form_list[current_step] -        # make the current object the default item for the session +    def get_object_name(self, obj):          obj_name = obj.__class__.__name__.lower()          # prefer a specialized name if available          prefixes = self.storage.prefix.split('_')          if len(prefixes) > 1 and prefixes[-2].startswith(obj_name):              obj_name = prefixes[-2] -        self.request.session[obj_name] = unicode(obj.pk) +        return obj_name + +    def get_instanced_init(self, obj, step=None): +        """Get initial data from an init""" +        current_step = step or self.steps.current +        c_form = self.form_list[current_step] +        # make the current object the default item for the session +        self.request.session[self.get_object_name(obj)] = unicode(obj.pk)          initial = MultiValueDict()          if self.request.POST or \                  (step in self.request.session[self.storage.prefix] and | 
