diff --git a/forms.py b/forms.py index 44c2e5a..aeeee34 100644 --- a/forms.py +++ b/forms.py @@ -24,7 +24,7 @@ """ Form field to add a new domain """ - domain_name = forms.CharField( + domain_name = forms.CharField( #todo MAIL → add domain, check post ! label = _('Domain Name'), required = True, ) @@ -52,7 +52,7 @@ """ Form fields to add a new list. Languages are hard coded which should be replaced by a REST lookup of available languages. - """ + """ languages = (("Arabic", "Arabic"), ("Catalan", "Catalan"), ("Chinese (China)", "Chinese (China)"), @@ -97,12 +97,13 @@ widget = forms.Select(), label = _('@Domain'), required = True, - choices = ( ("",("Please Choose a Domain")), - ("example.com",("http://example.com")),#NEEDS to be REST API Call + choices = ( + ("","Please Choose a Domain"), + ("","-"), ), error_messages = { 'required': _("Please choose an existing Domain."), - } + } ) list_owner = forms.EmailField( label = _('Inital list owner address'), @@ -129,6 +130,9 @@ widget = forms.CheckboxSelectMultiple(), choices = languages, required = False) + def __init__(self,domain_choices): + super(ListNew, self).__init__() + self["domains"].choices = (("test","test2"))#domain_choices #BUG class Meta: """ diff --git a/views.py b/views.py index 7738cdd..a782258 100644 --- a/views.py +++ b/views.py @@ -87,6 +87,7 @@ except Exception, e: return HttpResponse(e) domain = c.create_domain(domain_name) + #email_host ; url_host might differ #TODO domain.contact_address = form.cleaned_data['contact_address'] domain.description = form.cleaned_data['description'] @@ -114,27 +115,31 @@ form = ListNew(request.POST) if form.is_valid(): try: - c = Client('http://localhost:8001/3.0', API_USER, API_PASS) - + 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']) mailing_list = domain.create_list(form.cleaned_data['listname']) - try: return render_to_response('mailman-django/lists/created.html', {'fqdn_listname': mailing_list.info['fqdn_listname']}) except Exception, e: return HttpResponse(e) - else: - form = ListNew() try: c = Client('http://localhost:8001/3.0', API_USER, API_PASS) - #form.domains.choices = c.domains except Exception, e: return HttpResponse(e) - + 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 return render_to_response(template, {'form': form})