diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/templates/ishtar/wizard/default_wizard.html | 2 | ||||
| -rw-r--r-- | ishtar_common/urls.py | 1 | ||||
| -rw-r--r-- | ishtar_common/views.py | 14 | ||||
| -rw-r--r-- | ishtar_common/wizards.py | 7 | 
4 files changed, 24 insertions, 0 deletions
| diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html index 3f2f3943e..2eb62457b 100644 --- a/ishtar_common/templates/ishtar/wizard/default_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html @@ -1,5 +1,6 @@  {% extends "base.html" %}  {% load i18n range table_form %} +{% load url from future %}  {% block extra_head %}  {{form.media}}  {% endblock %} @@ -43,6 +44,7 @@  <div id='validation-bar'>    <input type="submit" id="submit_form" name='validate' value="{% trans "Validate" %}"/>    {% if next_steps %}<input type="submit" id="submit_end_form" name='validate_and_end' value="{% trans "Validate and end" %}"/>{% endif %} +  <input type="button" id="reset_wizards" name='cancel' value="{% trans "Cancel" %}" onclick="window.location='{% url 'reset_wizards' %}';"/>  </div>  </div>  </form> diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index 0c4059eeb..10a397fe0 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -123,6 +123,7 @@ urlpatterns += patterns('ishtar_common.views',       url(r'person_merge/(?:(?P<page>\d+)/)?$', 'person_merge', name='person_merge'),       url(r'organization_merge/(?:(?P<page>\d+)/)?$', 'organization_merge',           name='organization_merge'), +     url(r'reset/$', 'reset_wizards', name='reset_wizards'),       url(r'(?P<action_slug>' + actions + r')/$', 'action', name='action'),  ) diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 1885493b1..7b2fffcef 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -832,6 +832,20 @@ def dashboard_main_detail(request, item_name):      return render_to_response('ishtar/dashboards/dashboard_main_detail.html',                              dct, context_instance=RequestContext(request)) +def reset_wizards(request): +    # dynamicaly execute each reset_wizards of each ishtar app +    for app in settings.INSTALLED_APPS: +        if app == 'ishtar_common': +            # no need for infinite recursion +            continue +        try: +            module = __import__(app) +        except ImportError: +            continue +        if hasattr(module, 'views') and hasattr(module.views, 'reset_wizards'): +            module.views.reset_wizards(request) +    return redirect(reverse('start')) +  ITEM_PER_PAGE = 20  def merge_action(model, form, key):      def merge(request, page=1): diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 2ad3635d7..1e515d13e 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -620,6 +620,13 @@ class Wizard(NamedUrlWizardView):          return key in request.session[storage.prefix]['step_data'][form_key]      @classmethod +    def session_reset(cls, request, url_name): +        prefix = url_name + normalize_name(cls.__name__) +        storage = get_storage(cls.storage_name, prefix, request, +                              getattr(cls, 'file_storage', None)) +        storage.reset() + +    @classmethod      def session_set_value(cls, request, form_key, key, value, reset=False):          prefix = form_key.split('-')[1] + normalize_name(cls.__name__)          storage = get_storage(cls.storage_name, prefix, request, | 
