implemented context processor for Lists choice
1 parent 240a725 commit ce1591369242be7c40b382eaaae7f447d0795aca
@benste benste authored on 29 Jun 2011
Showing 2 changed files
View
61
context_processors.py
#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}
 
View
4
views.py
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
 
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 _
import re
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'):
"""