diff --git a/context_processors.py b/context_processors.py index 9512680..327f68a 100644 --- a/context_processors.py +++ b/context_processors.py @@ -1,22 +1,24 @@ -#WEB List selector → TODO → MOVE to Context Processors - try: - web_host = request.META["HTTP_HOST"].split(":")#TODO Django DEV only ! - web_host = web_host[0] - except: - web_host = request.META["HTTP_HOST"] - d = c.get_domain(None,web_host) - domainname= d.email_host - domain_lists = [] - for list in c.lists: - if list.host_name == domainname: - domain_lists.append(list) - - - - LISTS: domains - - -return [(lists,domain.... +from mailman.client import Client +from settings import API_USER, API_PASS - - +def lists_of_domain(request): + """ This function is a wrapper to render a list of all + available List registered to the current request URL + """ + #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"] + #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 + domain_lists = [] + for list in c.lists: + if list.host_name == domainname: + domain_lists.append(list) + #return a Dict with the key used in templates + return {"lists":domain_lists} diff --git a/views.py b/views.py index 3d16c6a..1e86aa1 100644 --- a/views.py +++ b/views.py @@ -17,7 +17,7 @@ # GNU Mailman. If not, see . from django.http import HttpResponse, HttpResponseRedirect -from django.template import Context, loader +from django.template import Context, loader, RequestContext from django.shortcuts import render_to_response, redirect from django.core.urlresolvers import reverse from django.utils.translation import gettext as _ @@ -105,7 +105,7 @@ except Exception, e: return HttpResponse(e) - return render_to_response(template, {'form': form,'domains':existing_domains}) + return render_to_response(template, {'form': form,'domains':existing_domains},context_instance=RequestContext(request)) @login_required def administration(request, template = 'mailman-django/lists/new.html'):