diff --git a/forms.py b/forms.py index 5f8da00..5e5837a 100644 --- a/forms.py +++ b/forms.py @@ -17,6 +17,7 @@ # GNU Mailman. If not, see . from django import forms +from django.core.validators import validate_email from django.utils.translation import gettext as _ from fieldset_forms import FieldsetForm @@ -25,20 +26,23 @@ def validate(self, value): "Check if value consists of a valid email domain." mail = "mail@"+value - super(forms.EmailField, self).validate(mail) + super(DomainField, self).validate(mail) + validate_email(mail) + class ListNameField(forms.EmailField): def validate(self, value): "Check if value consists of a valid email prefix." mail = value+"@example.net" - super(forms.EmailField, self).validate(mail) + super(ListNameField, self).validate(mail) + validate_email(mail) #Fieldsets for use within the views class DomainNew(FieldsetForm): """ Form field to add a new domain """ - domain_name = DomainField( + domain_name = forms.CharField( label = _('Domain Name'), error_messages = {'required': _('Please a domain name'), 'invalid': _('Please enter a valid domain name.')}, @@ -53,6 +57,10 @@ label = _('Description'), required = False ) + + def clean_domain_name(self): + domain_name = self.cleaned_data['domain_name'] + validate_email('mail@' + domain_name) class Meta: """ diff --git a/templates/mailman-django/new_domain.html b/templates/mailman-django/new_domain.html new file mode 100644 index 0000000..060efdc --- /dev/null +++ b/templates/mailman-django/new_domain.html @@ -0,0 +1,40 @@ +{% extends "mailman-django/base.html" %} +{% load i18n %} + +{% block content %} + +

{% trans "Add a new Domain" %}

+ +

{% trans "Logout" %}

+ +{% if domains %} + + + + + + + {% for domain in domains %} + + + + + + {% endfor %} +
{% trans "Domain" %}{% trans "Contact Address" %}{% trans "Description" %}
{{ domain.base_url }}{{ domain.contact_address }} + {% if domain.description %} + {{ domain.description }} + {% endif %} +
+{% endif %} +
+
+ + {{ form.as_div }} + +
+ +
+ +
+{% endblock %}