Ticket #19189: wizard-subclass.py

File wizard-subclass.py, 932 bytes (added by kenth, 2 years ago)

implementation w/o patching Django

Line 
1#
2# Extend WizardView w/o patching Django
3#
4
5class SessionWizardView(SessionWizardView):
6    class RevalidationError(Exception):
7        def __init__(self, step, form, **kwargs):
8            self.step = step
9            self.form = form
10            self.kwargs = kwargs
11
12        def __repr__(self):
13            return '%s(%s)' % (self.__class__, self.step)
14        __str__ = __repr__
15
16    def render_done(self, form, **kwargs):
17        """See ticket #19189"""
18        try:
19            done_response = super(SessionWizardView, self).render_done(form, **kwargs)
20        except self.RevalidationError as e:
21            return self.render_revalidation_failure(e.step, e.form, **e.kwargs)
22        return done_response
23
24    def get_context_data(self, form, **kwargs):
25        """See ticket #19025"""
26        context = super(SessionWizardView, self).get_context_data(form, **kwargs)
27        context['form'] = form
28        return context
29
30
Back to Top