def serve(self, request): if self.slug == 'contact-us' and request.method == 'POST': contact_form = ContactForm(request.POST) if contact_form.is_valid(): try: contact_form.save() except SMTPException: messages.error( request, _('There was a problem submitting your contact ' 'details.')) log.error('Internal Server Error: %s', request.path, exc_info=sys.exc_info(), extra={ 'status_code': 500, 'request': request }) else: messages.success( request, _("Your contact details have been submitted.")) redirect(self.url) return super(RTEIAncillaryPage, self).serve(request)
def get_context(self, request): context = super(RTEIAncillaryPage, self).get_context(request) if self.slug == 'contact-us': if request.method == 'POST': contact_form = ContactForm(request.POST) else: contact_form = ContactForm() context['contact_form'] = contact_form return context
def get_context(self, request): context = super(RTEIAncillaryPage, self).get_context(request) if self.slug == 'contact-us': if request.method == 'POST': contact_form = ContactForm(request.POST) else: contact_form = ContactForm() context['contact_form'] = contact_form elif self.slug in ['supporters', 'civil-society-partners']: context['listing'] = True return context
def serve(self, request): if self.slug == 'contact-us' and request.method == 'POST': contact_form = ContactForm(request.POST) if contact_form.is_valid(): try: contact_form.save() except SMTPException: messages.error( request, _('There was a problem submitting your contact details.')) log.error('Internal Server Error: %s', request.path, exc_info=sys.exc_info(), extra={ 'status_code': 500, 'request': request }) else: messages.success( request, _("Your contact details have been submitted.")) redirect(self.url) return super(RTEIAncillaryPage, self).serve(request)