def get_context_data(self, form, **kwargs): context = SessionWizardView.get_context_data(self, form, **kwargs) # Check if we are adding a new or editing an existing recipe if 'recipe_id' in self.kwargs: context['new_recipe'] = False else: context['new_recipe'] = True for step in self.steps.all: context['%s_form_valid' % step] = self.form_is_valid(step) return context
def get_context_data(self, form, **kwargs): context = SessionWizardView.get_context_data(self, form, **kwargs) context['passed'] = self.steps.all[:self.steps.index] context['not_passed'] = self.steps.all[self.steps.index:] data = {} form_data = self.get_all_cleaned_data() for step in context['passed']: data[step] = self.form_list[step](data=form_data) context['step_data'] = data return context
def dispatch(self, *args, **kwargs): if 'recipe_id' in self.kwargs: try: self.instance = Recipe.objects.select_related().prefetch_related('uses__unit').get(pk=self.kwargs['recipe_id']) except Recipe.DoesNotExist: raise Http404 if (not self.request.user == self.instance.author_id) and not self.request.user.is_staff: raise PermissionDenied else: self.instance = Recipe() return SessionWizardView.dispatch(self, *args, **kwargs)
def test_init(self): request = get_request() testform = SessionWizardView.as_view([('start', Step1)]) self.assertTrue(isinstance(testform(request), TemplateResponse))
def test_init(self): request = get_request() testform = SessionWizardView.as_view([('start', Step1)]) self.assertTrue(isinstance(testform(request), TemplateResponse))
def get_cleaned_data_for_step(self, step): print SessionWizardView.get_cleaned_data_for_step(self, step) return SessionWizardView.get_cleaned_data_for_step(self, step)