diff --git a/src/postorius/templates/postorius/lists/index.html b/src/postorius/templates/postorius/lists/index.html index 4e520f6..a79ecbd 100644 --- a/src/postorius/templates/postorius/lists/index.html +++ b/src/postorius/templates/postorius/lists/index.html @@ -8,7 +8,11 @@ {% if user.is_superuser %}
+ {% if domain_count < 2 %} + {% trans "Create New Domain" %} + {% else %} {% trans "Create New List" %} + {% endif %}
{% endif %} diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 44b14a8..6b39495 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -184,6 +184,16 @@ messages.error(request, e) return redirect('mass_subscribe', self.mailing_list.fqdn_listname) +def _get_choosable_domains(): + try: + domains = Domain.objects.all() + except MailmanApiError: + return utils.render_api_error(request) + choosable_domains = [("", _("Choose a Domain"))] + for domain in domains: + choosable_domains.append((domain.mail_host, + domain.mail_host)) + return choosable_domains @login_required @user_passes_test(lambda u: u.is_superuser) @@ -199,14 +209,7 @@ """ mailing_list = None if request.method == 'POST': - try: - domains = Domain.objects.all() - except MailmanApiError: - return utils.render_api_error(request) - choosable_domains = [("", _("Choose a Domain"))] - for domain in domains: - choosable_domains.append((domain.mail_host, - domain.mail_host)) + choosable_domains = _get_choosable_domains() form = ListNew(choosable_domains, request.POST) if form.is_valid(): #grab domain @@ -234,13 +237,7 @@ else: messages.success(_("New List created")) else: - try: - domains = Domain.objects.all() - except MailmanApiError: - return utils.render_api_error(request) - choosable_domains = [("", _("Choose a Domain"))] - for domain in domains: - choosable_domains.append((domain.mail_host, domain.mail_host)) + choosable_domains = _get_choosable_domains() form = ListNew(choosable_domains, initial={'list_owner': request.user.email}) return render_to_response(template, {'form': form}, @@ -259,12 +256,14 @@ lists = List.objects.all(only_public=only_public) except MailmanApiError: return utils.render_api_error(request) + choosable_domains = _get_choosable_domains() if request.method == 'POST': return redirect("list_summary", fqdn_listname=request.POST["list"]) else: return render_to_response(template, {'error': error, - 'lists': lists}, + 'lists': lists, + 'domain_count': len(choosable_domains)}, context_instance=RequestContext(request))