From: Aleksander Łukasz Date: Fri, 18 Oct 2013 12:46:25 +0000 (+0200) Subject: Fixing contact form to work with katalog subdomain X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/0a9ec4c13727704f2394760c23d76559f727f5bd?ds=inline;hp=6f53d6571e16d43f0084f310a69428446ad9b21c Fixing contact form to work with katalog subdomain --- diff --git a/contact/forms.py b/contact/forms.py index e369e95..8fa0149 100644 --- a/contact/forms.py +++ b/contact/forms.py @@ -62,8 +62,8 @@ class ContactForm(forms.Form): site = Site.objects.get_current() dictionary = { 'form_tag': self.form_tag, - 'site_name': site.name, - 'site_domain': site.domain, + 'site_name': getattr(self, 'site_name', site.name), + 'site_domain': getattr(self, 'site_domain', site.domain), 'contact': contact, } context = RequestContext(request) diff --git a/contact/templates/contact/mail_managers_body.txt b/contact/templates/contact/mail_managers_body.txt index 5088b1b..b7f97cf 100644 --- a/contact/templates/contact/mail_managers_body.txt +++ b/contact/templates/contact/mail_managers_body.txt @@ -1,6 +1,6 @@ -{% load pretty_print from contact_tags %}Wypełniono formularz {{ form_tag }} na stronie {{ site_name }}. +{% load pretty_print from contact_tags %}{% load subdomainurls %}Wypełniono formularz {{ form_tag }} na stronie {{ site_name }}. -http://{{ site_domain }}{% url 'admin:contact_contact_change' contact.pk %} +{% url 'admin:contact_contact_change' None contact.pk %} {% for k, v in contact.body.items %} {{ k }}: diff --git a/contact/templates/contact/thanks.html b/contact/templates/contact/thanks.html index 63adb30..f82ebd8 100644 --- a/contact/templates/contact/thanks.html +++ b/contact/templates/contact/thanks.html @@ -1,4 +1,4 @@ -{% extends form.base_template|default:"base.html" %} +{% extends base_template|default:"base.html" %} {% load i18n %} {% block title %}{% trans "Thank you" %}{% endblock %} diff --git a/contact/views.py b/contact/views.py index 26ccf60..245433e 100644 --- a/contact/views.py +++ b/contact/views.py @@ -36,11 +36,14 @@ def form(request, form_tag): def thanks(request, form_tag): - if form_tag not in contact_forms: + try: + form_class = contact_forms[form_tag] + except KeyError: raise Http404 return render(request, - ['contact/%s/thanks.html' % form_tag, 'contact/thanks.html'] + ['contact/%s/thanks.html' % form_tag, 'contact/thanks.html'], + dict(base_template = getattr(form_class, 'base_template', None)) ) diff --git a/edumed/contact_forms.py b/edumed/contact_forms.py index e809e2b..ec34ebf 100644 --- a/edumed/contact_forms.py +++ b/edumed/contact_forms.py @@ -133,6 +133,7 @@ class MILForm(ContactForm): from_title = 'Mil' submit_label = _('Submit') base_template = 'base_mil.html' + site_name = site_domain = 'katalog.nowoczesnapolska.org.pl' name = forms.CharField(label = _('Name and Surname'), max_length = 255) contact = forms.EmailField(label = _('E-mail'), max_length = 255)