Ticket #7439: multipart_form_as_last_in_formwizard.diff
File multipart_form_as_last_in_formwizard.diff, 2.6 KB (added by , 15 years ago) |
---|
-
contrib/formtools/wizard.py
42 42 def __repr__(self): 43 43 return "step: %d\nform_list: %s\ninitial_data: %s" % (self.step, self.form_list, self.initial) 44 44 45 def get_form(self, step, data=None ):45 def get_form(self, step, data=None, files=None): 46 46 "Helper method that returns the Form instance for the given step." 47 return self.form_list[step](data, prefix=self.prefix_for_step(step), initial=self.initial.get(step, None))47 return self.form_list[step](data, files, prefix=self.prefix_for_step(step), initial=self.initial.get(step, None)) 48 48 49 49 def num_steps(self): 50 50 "Helper method that returns the number of steps." … … 71 71 # For each previous step, verify the hash and process. 72 72 # TODO: Move "hash_%d" to a method to make it configurable. 73 73 for i in range(current_step): 74 form = self.get_form(i, request.POST )74 form = self.get_form(i, request.POST, request.FILES) 75 75 if request.POST.get("hash_%d" % i, '') != self.security_hash(request, form): 76 76 return self.render_hash_failure(request, i) 77 77 self.process_step(request, form, i) … … 79 79 # Process the current step. If it's valid, go to the next step or call 80 80 # done(), depending on whether any steps remain. 81 81 if request.method == 'POST': 82 form = self.get_form(current_step, request.POST )82 form = self.get_form(current_step, request.POST, request.FILES) 83 83 else: 84 84 form = self.get_form(current_step) 85 85 if form.is_valid(): … … 90 90 # time, as a sanity check, and call done(). 91 91 num = self.num_steps() 92 92 if next_step == num: 93 final_form_list = [self.get_form(i, request.POST ) for i in range(num)]93 final_form_list = [self.get_form(i, request.POST, request.FILES) for i in range(num)] 94 94 95 95 # Validate all the forms. If any of them fail validation, that 96 96 # must mean the validator relied on some other input, such as … … 102 102 103 103 # Otherwise, move along to the next step. 104 104 else: 105 if form.is_multipart(): 106 raise NotImplementedError("Your %s class has not initialized multipart form as last." % self.__class__.__name__) 105 107 form = self.get_form(next_step) 106 108 self.step = current_step = next_step 107 109