def done(self, form_list, **kwargs): cleaned_data = self.get_cleaned_data_for_step(self.steps.first) email = cleaned_data['email'] answer = check_answer(email.raw_message) if answer: resposta = copy.deepcopy(email) resposta.id = None resposta.message = answer resposta.parent = email resposta.full_clean() resposta.save() messages.success(self.request, _(u'Your reply was automatically sent.')) else: messages.warning(self.request, _(u'The answer to your question was not found.')) return redirect(reverse('mail:processing'))
def get_context_data(self, form, **kwargs): context = super(ProcessingWizard, self).get_context_data(form=form, **kwargs) if self.steps.current == 'step_one': emails = Email.emails.unreplied().filter(tags__tag=EMAIL_TAGS.QUESTION) context.update({'emails': emails}) elif self.steps.current == 'step_two': cleaned_data = self.get_cleaned_data_for_step(self.steps.first) email = cleaned_data['email'] context.update({'email': email}) elif self.steps.current == 'step_four': cleaned_data = self.get_cleaned_data_for_step(self.steps.first) email = cleaned_data['email'] answer = check_answer(email.raw_message) context.update({'email': email.raw_message, 'answer': answer}) return context