diff options
| author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-12-27 17:53:15 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-12-27 17:55:37 +0100 | 
| commit | 0bbb58bdf1cad93846bec23d2481e5ffffa818f8 (patch) | |
| tree | 9ba5641662d7abeb2c690595f3255eb9df32ccc1 /ishtar_common | |
| parent | e027edce6edc7d8ba5a7dfc14069a95e531da2e1 (diff) | |
| download | Ishtar-0bbb58bdf1cad93846bec23d2481e5ffffa818f8.tar.bz2 Ishtar-0bbb58bdf1cad93846bec23d2481e5ffffa818f8.zip  | |
Display current item window after creation and modification (refs #1574)
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/templates/ishtar/wizard/wizard_done.html | 8 | ||||
| -rw-r--r-- | ishtar_common/urls.py | 4 | ||||
| -rw-r--r-- | ishtar_common/wizards.py | 18 | 
3 files changed, 22 insertions, 8 deletions
diff --git a/ishtar_common/templates/ishtar/wizard/wizard_done.html b/ishtar_common/templates/ishtar/wizard/wizard_done.html index 7de3edfce..2823c1bae 100644 --- a/ishtar_common/templates/ishtar/wizard/wizard_done.html +++ b/ishtar_common/templates/ishtar/wizard/wizard_done.html @@ -2,10 +2,14 @@  {% load i18n %}  {% block content %}  <p>{%trans "Item successfully saved"%}</p> -{% if redirect %} +{% if redirect or wizard_done_window %}  <script type='text/javascript' language='javascript'> +{% if redirect %}  window.location.href = "{{redirect}}"; +{% endif %} +{% if wizard_done_window %} +$(function(){ load_window("{{wizard_done_window}}{{item.pk}}/"); }); +{% endif %}  </script>  {% endif %} -</div>  {% endblock %} diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index 565db57d5..63c0d55f8 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -65,7 +65,7 @@ urlpatterns += patterns('ishtar_common.views',             name='autocomplete-person'),       url(r'get-person/(?P<type>.+)?$', 'get_person',             name='get-person'), -     url(r'show-person/(?P<pk>.+)?/(?P<type>.+)?$', +     url(r'show-person(?:/(?P<pk>.+))?/(?P<type>.+)?$',             'show_person', name='show-person'),       url(r'autocomplete-town/?$', 'autocomplete_town',             name='autocomplete-town'), @@ -77,7 +77,7 @@ urlpatterns += patterns('ishtar_common.views',             'new_organization', name='new-organization'),       url(r'get-organization/(?P<type>.+)?$', 'get_organization',             name='get-organization'), -     url(r'show-organization/(?P<pk>.+)?/(?P<type>.+)?$', +     url(r'show-organization(?:/(?P<pk>.+))?/(?P<type>.+)?$',             'show_organization', name='show-organization'),       url(r'autocomplete-organization/([0-9_]+)?$',             'autocomplete_organization', name='autocomplete-organization'), diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index a237fb327..7add2faa8 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -34,7 +34,9 @@ import models  class MultiValueDict(BaseMultiValueDict):      def get(self, *args, **kwargs):          v = super(MultiValueDict, self).getlist(*args, **kwargs) -        if len(v) > 1: +        if callable(v): +            v = v() +        if type(v) in (list, tuple) and len(v) > 1:              v = ",".join(v)          else:              v = super(MultiValueDict, self).get(*args, **kwargs) @@ -46,6 +48,8 @@ class Wizard(NamedUrlWizardView):      modification = None # True when the wizard modify an item      storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage'      translated_keys = ['title'] +    wizard_done_template = 'ishtar/wizard/wizard_done.html' +    wizard_done_window = ''      @staticmethod      def _check_right(step, condition=True): @@ -355,8 +359,9 @@ class Wizard(NamedUrlWizardView):                     isinstance(obj.__class__._meta.get_field(k), ImageFile)):                      if not dct[k]:                          dct[k] = None -                if isinstance(obj.__class__._meta.get_field(k), -                              ManyToManyField): +                if not k.endswith('_id') and ( +                   isinstance(obj.__class__._meta.get_field(k), +                              ManyToManyField)):                      if not dct[k]:                          dct[k] = []                      elif type(dct[k]) not in (list, tuple): @@ -439,7 +444,12 @@ class Wizard(NamedUrlWizardView):                  # necessary to manage interaction between models like                  # material_index management for baseitems                  obj.save() -        res = render_to_response('ishtar/wizard/wizard_done.html', {}, +        dct = {'item':obj} +        # force evaluation of lazy urls +        wizard_done_window = unicode(self.wizard_done_window) +        if wizard_done_window: +            dct['wizard_done_window'] = wizard_done_window +        res = render_to_response(self.wizard_done_template, dct,                                    context_instance=RequestContext(self.request))          return return_object and (obj, res) or res  | 
