diff --git a/fieldset_forms.py b/fieldset_forms.py index 31af7d3..bcfbafa 100644 --- a/fieldset_forms.py +++ b/fieldset_forms.py @@ -30,17 +30,19 @@ by WTForm. """ - def __init__(self, *args): + def __init__(self, *args, **kwargs): """Initialize a FormsetField.""" - super(FieldsetForm, self).__init__(*args) + super(FieldsetForm, self).__init__(*args, **kwargs) # check if the user specified the wished layout of the form if hasattr(self, 'Meta') and hasattr(self.Meta, 'layout'): msg = "Meta.layout must be iterable" assert hasattr(self.Meta.layout, '__getitem__'), msg self.layout = self.Meta.layout else: - self.layout = self.fields.keys() - + self.layout = [["All"]] + self.layout[0][1:]=(self.fields.keys()) + #raise Exception(self.layout)#debug + def as_div(self): """Render the form as a set of
s.""" output = "" @@ -65,7 +67,7 @@ for field in fields: try: # create a field instance for the bound field - field_instance = self.base_fields[field] + field_instance = self.fields[field] except KeyError: # could not create the instance so throw an exception # msg on a separate line since the line got too long diff --git a/forms.py b/forms.py index 5e5837a..06d3c28 100644 --- a/forms.py +++ b/forms.py @@ -118,18 +118,6 @@ required = True, error_messages = {'required': _('Please enter a name for your list.'), 'invalid': _('Please enter a valid list name.')} - ) - domains = forms.ChoiceField( - widget = forms.Select(), - label = _('@Domain'), - required = True, - choices = ( - ("",_("Please Choose a Domain")), - ("","-"), - ), - error_messages = { - 'required': _("Please choose an existing Domain."), - } ) list_owner = forms.EmailField( label = _('Inital list owner address'), @@ -155,11 +143,25 @@ label = _('Language'), widget = forms.CheckboxSelectMultiple(), choices = languages, - required = False) - def __init__(self,domain_choices): - super(ListNew, self).__init__() - self["domains"].choices = (("test","test2"))#domain_choices #BUG + required = False) + description = forms.CharField( + label = _('Description'), + widget = forms.TextInput(), + required = True) + + web_host = forms.ChoiceField( ) + + def __init__(self,domain_choices, *args, **kwargs): + super(ListNew, self).__init__(*args, **kwargs) + self.fields["web_host"] = forms.ChoiceField( + widget = forms.Select(), + label = _('Web Host'), + required = True, + choices = domain_choices, + error_messages = {'required': _("Choose an existing Domain."),} + ) + class Meta: """ Class to handle the automatic insertion of fieldsets and divs. @@ -168,7 +170,7 @@ the list should be the wished name of the fieldset, the following the fields that should be included in the fieldset. """ - layout = [["List Details", "listname", "domains", "list_owner", "list_type"], + layout = [["List Details", "listname", "web_host", "list_owner", "description", "list_type"], ["Available Languages", "languages"]] class ListSubscribe(forms.Form): diff --git a/templates/mailman-django/new_domain.html b/templates/mailman-django/new_domain.html index 060efdc..980f0e4 100644 --- a/templates/mailman-django/new_domain.html +++ b/templates/mailman-django/new_domain.html @@ -1,40 +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 %} +{% extends "mailman-django/base.html" %} +{% load i18n %} + +{% block content %} + +

{% trans "Add a new Domain" %}

+ +

{% trans "Logout" %}

+ + + + + + + {% if domains %} + {% for domain in domains %} + + + + + + {% endfor %} + {% endif %} +
{% trans "Domain" %}{% trans "Contact Address" %}{% trans "Description" %}
{{ domain.base_url }}{{ domain.contact_address }} + {% if domain.description %} + {{ domain.description }} + {% endif %} +
+ +
+
+ + {{ form.as_div }} + +
+ +
+ +
+{% endblock %} diff --git a/views.py b/views.py index 5a062dc..cc77ece 100644 --- a/views.py +++ b/views.py @@ -76,7 +76,7 @@ 'message': message}) return _login_decorator -#@login_required #TODO +#@login_required #DEBUG def new_domain(request, template = 'mailman-django/new_domain.html'): if request.method == 'POST': form = DomainNew(request.POST) @@ -102,7 +102,7 @@ return render_to_response(template, {'form': form,'domains':existing_domains}) -#@login_required +#@login_required #DEBUG def list_new(request, template = 'mailman-django/lists/new.html'): """ Add a new mailing list. @@ -120,8 +120,14 @@ c = Client('http://localhost:8001/3.0', API_USER, API_PASS) except Exception, e: return HttpResponse(e) - domain = c.get_domain(form.cleaned_data['domains']) + domain = c.get_domain(form.cleaned_data['web_host']) mailing_list = domain.create_list(form.cleaned_data['listname']) + """settings = mailing_list.settings + settings["description"] = form.cleaned_data['description'] + #settings["owner_address"] = form.cleaned_data['list_owner'] #TODO: Readonly + #settings["???"] = form.cleaned_data['list_type'] #TODO not found in REST + #settings["???"] = form.cleaned_data['languages'] #TODO not found in REST + settings.save()""" try: return render_to_response('mailman-django/lists/created.html', {'fqdn_listname': mailing_list.info['fqdn_listname']}) @@ -132,16 +138,10 @@ c = Client('http://localhost:8001/3.0', API_USER, API_PASS) except Exception, e: return HttpResponse(e) - choosable_domains = [("","Choose a Domain")] + choosable_domains = [("",_("Choose a Domain"))] for domain in c.domains: - choosable_domains.append((domain,domain)) - #choosable_domains - test = ( - ("","Please Choose a Domain"), - ("","-"), - ) - form = ListNew(test) - #form["domains"]["choices"]=test + choosable_domains.append((domain.url_host,domain.url_host)) + form = ListNew(choosable_domains) return render_to_response(template, {'form': form})