Ticket #7222: preview.2.diff

File preview.2.diff, 2.7 KB (added by Samuel Cormier-Iijima <sciyoshi@…>, 16 years ago)

forgot to change done() parameter

  • django/contrib/formtools/preview.py

     
    7070        if f.is_valid():
    7171            if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')):
    7272                return self.failed_hash(request) # Security hash failed.
    73             return self.done(request, f.cleaned_data)
     73            return self.done(request, f)
    7474        else:
    7575            return render_to_response(self.form_template,
    7676                {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},
     
    117117
    118118    # METHODS SUBCLASSES MUST OVERRIDE ########################################
    119119
    120     def done(self, request, cleaned_data):
     120    def done(self, request, form):
    121121        """
    122         Does something with the cleaned_data and returns an
     122        Does something with the form and returns an
    123123        HttpResponseRedirect.
    124124        """
    125125        raise NotImplementedError('You must define a done() method on your %s subclass.' % self.__class__.__name__)
  • docs/form_preview.txt

     
    2121       a. If it's valid, displays a preview page.
    2222       b. If it's not valid, redisplays the form with error messages.
    2323    3. When the "confirmation" form is submitted from the preview page, calls
    24        a hook that you define -- a ``done()`` method that gets passed the valid
    25        data.
     24       a hook that you define -- a ``done()`` method that gets passed the form
     25       instance.
    2626
    2727The framework enforces the required preview by passing a shared-secret hash to
    2828the preview page via hidden form fields. If somebody tweaks the form parameters
     
    5050
    5151           class SomeModelFormPreview(FormPreview):
    5252
    53                def done(self, request, cleaned_data):
    54                    # Do something with the cleaned_data, then redirect
     53               def done(self, request, form):
     54                   # Do something with form or form.cleaned_data, then redirect
    5555                   # to a "success" page.
    5656                   return HttpResponseRedirect('/form/success')
    5757
    58        This method takes an ``HttpRequest`` object and a dictionary of the form
    59        data after it has been validated and cleaned. It should return an
     58       This method takes an ``HttpRequest`` object and an bound instance of the
     59       form class after having been validated and cleaned. It should return an
    6060       ``HttpResponseRedirect`` that is the end result of the form being
    6161       submitted.
    6262
Back to Top