diff --git a/context_processors.py b/context_processors.py index 912b63f..b048163 100644 --- a/context_processors.py +++ b/context_processors.py @@ -1,30 +1,29 @@ from mailman.client import Client from settings import API_USER, API_PASS +from django.utils.translation import gettext as _ +from urllib2 import HTTPError def lists_of_domain(request): """ This function is a wrapper to render a list of all available List registered to the current request URL """ domain_lists = [] - try: + message = "" + if "HTTP_HOST" in request.META.keys() : #get the URL - try: - web_host = request.META["HTTP_HOST"].split(":")#TODO Django DEV only ! - web_host = web_host[0] - except: - web_host = request.META["HTTP_HOST"] + web_host = request.META["HTTP_HOST"].split(":")[0] #querry the Domain object - c = Client('http://localhost:8001/3.0', API_USER, API_PASS) - d = c.get_domain(None,web_host) - #workaround LP:802971 - domainname= d.email_host - - for list in c.lists: - if list.host_name == domainname: - domain_lists.append(list) - except: - raise Exception("No Domain Found or HTTP_HOST missing in reqeust") - pass #in case there is not http_host (e.g. during testing) + try: + c = Client('http://localhost:8001/3.0', API_USER, API_PASS) + d = c.get_domain(None,web_host) + #workaround LP:802971 + domainname= d.email_host + for list in c.lists: + if list.host_name == domainname: + domain_lists.append(list) + except HTTPError, e: + domain_lists = c.lists + message = str(e.code) + _(" - Accesing from an unregistered Domain - showing all lists") #return a Dict with the key used in templates - return {"lists":domain_lists} + return {"lists":domain_lists, "message":message} diff --git a/templates/mailman-django/lists/index.html b/templates/mailman-django/lists/index.html index 3a236ae..0cc8657 100644 --- a/templates/mailman-django/lists/index.html +++ b/templates/mailman-django/lists/index.html @@ -17,7 +17,7 @@ {{ list.real_name }} {{ list.fqdn_listname }} - {%trans "Info / Subscribe" %} + {%trans "Info / Subscribe" %} {%trans "Settings" %} diff --git a/templates/mailman-django/menu/subscriptions.html b/templates/mailman-django/menu/subscriptions.html index 1940bad..55fc81a 100644 --- a/templates/mailman-django/menu/subscriptions.html +++ b/templates/mailman-django/menu/subscriptions.html @@ -2,7 +2,7 @@ {% block menu_subscriptions %} {% if fqdn_listname %} - {% trans "Subscriptions" %} + {% trans "Subscriptions" %}