| |
---|
| | import logging |
---|
| | |
---|
| | |
---|
| | from django.conf import settings |
---|
| | from django.contrib import messages |
---|
| | from django.contrib.auth import logout, authenticate, login |
---|
| | from django.contrib.auth.decorators import login_required, permission_required |
---|
| | from django.contrib.auth.forms import AuthenticationForm |
---|
| | from django.contrib.auth.models import User |
---|
| |
---|
| | |
---|
| | @login_required |
---|
| | @permission_required('server_admin') |
---|
| | def domain_new(request, template = 'mailmanweb/domain_new.html'): |
---|
| | message = None |
---|
| | if request.method == 'POST': |
---|
| | form = DomainNew(request.POST) |
---|
| | if form.is_valid(): |
---|
| | domain = Domain(mail_host=form.cleaned_data['mail_host'], |
---|
| |
---|
| | domain.save() |
---|
| | except MailmanApiError: |
---|
| | return utils.render_api_error(request) |
---|
| | except HTTPError, e: |
---|
| | message=e |
---|
| | messages.error(request,e) |
---|
| | else: |
---|
| | messages.success(request,_("New Domain registered")) |
---|
| | return redirect("domain_index") |
---|
| | else: |
---|
| | form = DomainNew() |
---|
| | return render_to_response(template, |
---|
| | {'form': form,'message': message}, |
---|
| | {'form': form}, |
---|
| | context_instance=RequestContext(request)) |
---|
| | |
---|
| | @login_required |
---|
| | def administration(request): |
---|
| |
---|
| | correct the list gets created and otherwise the form with the data |
---|
| | filled in before the last POST request is returned. The user must |
---|
| | be logged in to create a new list. |
---|
| | """ |
---|
| | error = None |
---|
| | message = None |
---|
| | mailing_list = None |
---|
| | if request.method == 'POST': |
---|
| | try: |
---|
| | domains = Domain.objects.all() |
---|
| |
---|
| | list_settings["owner_address"] = form.cleaned_data['list_owner'] |
---|
| | #settings["???"] = form.cleaned_data['languages'] #TODO not found in REST: |
---|
| | list_settings["advertised"] = form.cleaned_data['advertised'] |
---|
| | list_settings.save() |
---|
| | messages.success(_("List created")) |
---|
| | return redirect("list_summary",fqdn_listname=mailing_list.fqdn_listname) |
---|
| | #TODO catch correct Error class: |
---|
| | except HTTPError, e: |
---|
| | messages.error(request,e) |
---|
| | return render_to_response('mailmanweb/errors/generic.html', |
---|
| | {'error':e}, |
---|
| | context_instance=RequestContext(request)) |
---|
| | else: |
---|
| | messages.success(_("New List created")) |
---|
| | else: |
---|
| | try: |
---|
| | domains = Domain.objects.all() |
---|
| | except MailmanApiError: |
---|
| |
---|
| | choosable_domains = [("",_("Choose a Domain"))] |
---|
| | for domain in domains: |
---|
| | choosable_domains.append((domain.mail_host,domain.mail_host)) |
---|
| | form = ListNew(choosable_domains,initial={'list_owner': request.user.username}) |
---|
| | return render_to_response(template, {'form': form, error:None}, |
---|
| | return render_to_response(template, {'form': form}, |
---|
| | context_instance=RequestContext(request)) |
---|
| | |
---|
| | def list_index(request, template = 'mailmanweb/lists/index.html'): |
---|
| | """Show a table of all public mailing lists. |
---|
| |
---|
| | |