Abhilash Raj has proposed merging lp:~raj-abhilash1/postorius/bug_1201150 into
lp:postorius.
Requested reviews:
Mailman Coders (mailman-coders)
For more details, see:
https://code.launchpad.net/~raj-abhilash1/postorius/bug_1201150/+merge/246850
Fix #1201150
Add django-nose as a testing requirement
--
Your team Mailman Coders is requested to review the proposed merge of
lp:~raj-abhilash1/postorius/bug_1201150 into lp:postorius.
=== modified file 'setup.py'
--- setup.py 2014-04-22 14:35:55 +0000
+++ setup.py 2015-01-18 19:24:47 +0000
@@ -37,5 +37,6 @@
include_package_data = True,
install_requires = ['django>=1.4',
'django-social-auth>=0.7.8',
- 'mailmanclient', ]
+ 'mailmanclient',
+ 'django_nose',]
)
=== modified file 'src/postorius/auth/decorators.py'
--- src/postorius/auth/decorators.py 2014-03-15 21:36:39 +0000
+++ src/postorius/auth/decorators.py 2015-01-18 19:24:47 +0000
@@ -51,14 +51,14 @@
"""
def wrapper(*args, **kwargs):
user = args[0].user
- fqdn_listname = kwargs['fqdn_listname']
+ list_id = kwargs['list_id']
if not user.is_authenticated():
raise PermissionDenied
if user.is_superuser:
return fn(*args, **kwargs)
if getattr(user, 'is_list_owner', None):
return fn(*args, **kwargs)
- mlist = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ mlist = List.objects.get_or_404(fqdn_listname=list_id)
if user.email not in mlist.owners:
raise PermissionDenied
else:
@@ -69,12 +69,12 @@
def list_moderator_required(fn):
"""Check if the logged in user is a moderator of the given list.
- Assumes that the request object is the first arg and that fqdn_listname
+ Assumes that the request object is the first arg and that list_id
is present in kwargs.
"""
def wrapper(*args, **kwargs):
user = args[0].user
- fqdn_listname = kwargs['fqdn_listname']
+ list_id = kwargs['list_id']
if not user.is_authenticated():
raise PermissionDenied
if user.is_superuser:
@@ -83,7 +83,7 @@
return fn(*args, **kwargs)
if getattr(user, 'is_list_moderator', None):
return fn(*args, **kwargs)
- mlist = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ mlist = List.objects.get_or_404(fqdn_listname=list_id)
if user.email not in mlist.moderators and \
user.email not in mlist.owners:
raise PermissionDenied
=== modified file 'src/postorius/templates/postorius/lists/confirm_delete.html'
--- src/postorius/templates/postorius/lists/confirm_delete.html 2015-01-17 17:23:59 +0000
+++ src/postorius/templates/postorius/lists/confirm_delete.html 2015-01-18 19:24:47 +0000
@@ -10,6 +10,6 @@
<p>{% trans "All settings and membership data will be lost!" %}</p>
<form action="{{submit_url}}" method="post"> {% csrf_token %}
<button class="btn btn-danger" type="submit">{% trans "Delete" %} {{ list.fqdn_listname }}</button>
- <a class="btn" href="{% url 'list_summary' fqdn_listname=list.fqdn_listname %}">{% trans "Cancel" %}</a>
+ <a class="btn" href="{% url 'list_summary' list_id=list.list_id %}">{% trans "Cancel" %}</a>
</form>
{% endblock main %}
=== modified file 'src/postorius/templates/postorius/lists/confirm_remove_role.html'
--- src/postorius/templates/postorius/lists/confirm_remove_role.html 2014-04-15 19:12:27 +0000
+++ src/postorius/templates/postorius/lists/confirm_remove_role.html 2015-01-18 19:24:47 +0000
@@ -6,7 +6,7 @@
{% block main %}
<h1>{% trans 'Confirm Remove Role' %}</h1>
<p>{% trans "Are you sure you want to remove?" %}</p>
- <form method="post" action="{% url 'remove_role' fqdn_listname role address %}">
+ <form method="post" action="{% url 'remove_role' list_id role address %}">
{% csrf_token %}
<button class="btn btn-danger" type="submit">{% trans "Remove " %}{{ address }}</button>
<a class="btn" href="{% url 'list_members' fqdn_listname %}">{% trans "Cancel" %}</a>
=== modified file 'src/postorius/templates/postorius/lists/index.html'
--- src/postorius/templates/postorius/lists/index.html 2014-11-03 19:40:41 +0000
+++ src/postorius/templates/postorius/lists/index.html 2015-01-18 19:24:47 +0000
@@ -29,7 +29,7 @@
{% for list in lists %}
<tr>
<td>
- <a href="{% url 'list_summary' fqdn_listname=list.fqdn_listname %}">{{ list.display_name }}</a>
+ <a href="{% url 'list_summary' list_id=list.list_id %}">{{ list.display_name }}</a>
</td>
<td>{{ list.fqdn_listname }}</td>
<td>{{ list.settings.description }}</td>
=== modified file 'src/postorius/templates/postorius/lists/settings.html'
--- src/postorius/templates/postorius/lists/settings.html 2015-01-17 17:23:59 +0000
+++ src/postorius/templates/postorius/lists/settings.html 2015-01-18 19:24:47 +0000
@@ -8,14 +8,14 @@
{% list_nav 'list_settings' 'Settings' %}
<ul class="nav nav-tabs">
{% for section in form_sections %}
- <li {% if section.0 == visible_section %}class="active"{% endif %}><a href="{% url 'list_settings' fqdn_listname=list.fqdn_listname visible_section=section.0 visible_option=None %}">{{section.0}}</a></li>
+ <li {% if section.0 == visible_section %}class="active"{% endif %}><a href="{% url 'list_settings' list_id=list.list_id visible_section=section.0 visible_option=None %}">{{section.0}}</a></li>
{% endfor %}
</ul>
{% if visible_section %}
<table class="well">
- <form class="well" action="{% url 'list_settings' fqdn_listname=list.fqdn_listname visible_section=visible_section visible_option=visible_option %}" method="post" class="list_settings"> {% csrf_token %}
+ <form class="well" action="{% url 'list_settings' list_id=list.list_id visible_section=visible_section visible_option=visible_option %}" method="post" class="list_settings"> {% csrf_token %}
{% for field in form %}
<tr><td>
{{ field.errors }}
=== modified file 'src/postorius/templates/postorius/lists/summary.html'
--- src/postorius/templates/postorius/lists/summary.html 2015-01-09 15:22:37 +0000
+++ src/postorius/templates/postorius/lists/summary.html 2015-01-18 19:24:47 +0000
@@ -17,10 +17,14 @@
{% if user.is_authenticated %}
{% if userSubscribed %}
+<<<<<<< TREE
<a href="{% url 'list_unsubscribe' list.fqdn_listname user.email %}" class="btn btn-danger">{% trans "Unsubscribe" %}</a>
+=======
+ <a href="{% url 'list_unsubscribe' list.user_id user.email %}" class="btn btn-danger">Unsubscribe</a>
+>>>>>>> MERGE-SOURCE
{% else %}
<h2>{% trans 'Subscribe to this list' %}</h2>
- <form action="{% url 'list_subscribe' list.fqdn_listname %}" method="post" class="list_subscribe"> {% csrf_token %}
+ <form action="{% url 'list_subscribe' list.list_id %}" method="post" class="list_subscribe"> {% csrf_token %}
{{subscribe_form.as_p}}
<input class="btn btn-success" type="submit" value="{% trans 'Subscribe' %}" />
</form>
=== modified file 'src/postorius/templates/postorius/menu/list_nav.html'
--- src/postorius/templates/postorius/menu/list_nav.html 2015-01-17 17:23:59 +0000
+++ src/postorius/templates/postorius/menu/list_nav.html 2015-01-18 19:24:47 +0000
@@ -5,21 +5,21 @@
<span class="mm_context"><a href="{% url 'list_index' %}">{% trans 'Mailing Lists' %}</a> » {{ list.fqdn_listname }} » {% trans title %}</span>
{% if user|lower != 'anonymoususer' %}
<ul class="mm_nav">
- <li class="mm_nav_item"><a class="{% nav_active_class current 'list_summary' %}" href="{% url 'list_summary' list.fqdn_listname %}">{% trans "Info" %}</a></li>
- {% if user.is_superuser or user.is_list_owner %}
- <li class="mm_nav_item"><a class="{% nav_active_class current 'list_members' %}" href="{% url 'list_members' list.fqdn_listname %}">{% trans "Members" %}</a></li>
- {% endif %}
- {% if user.is_superuser or user.is_list_moderator %}
- <li class="mm_nav_item"><a class="{% nav_active_class current 'list_held_messages' %}" href="{% url 'list_held_messages' list.fqdn_listname %}">{% trans "Held Messages" %}</a></li>
- {% endif %}
- {% if user.is_superuser or user.is_list_owner %}
- <li class="mm_nav_item"><a class="{% nav_active_class current 'list_settings' %}" href="{% url 'list_settings' list.fqdn_listname %}">{% trans "Settings" %}</a></li>
- {% endif %}
- {% if user.is_superuser or user.is_list_moderator %}
- <li class="mm_nav_item"><a class="{% nav_active_class current 'mass_subscribe' %}" href="{% url 'mass_subscribe' list.fqdn_listname %}">{% trans "Mass Subscribe" %}</a></li>
- {% endif %}
- {% if user.is_superuser or user.is_list_owner %}
- <li class="mm_nav_item"><a class="{% nav_active_class current 'list_delete' %}" href="{% url 'list_delete' list.fqdn_listname %}">{% trans "Delete List" %}</a></li>
+ <li class="mm_nav_item"><a class="{% nav_active_class current 'list_summary' %}" href="{% url 'list_summary' list.list_id %}">{% trans "Info" %}</a></li>
+ {% if user.is_superuser or user.is_list_owner %}
+ <li class="mm_nav_item"><a class="{% nav_active_class current 'list_members' %}" href="{% url 'list_members' list.list_id %}">{% trans "Members" %}</a></li>
+ {% endif %}
+ {% if user.is_superuser or user.is_list_moderator %}
+ <li class="mm_nav_item"><a class="{% nav_active_class current 'list_held_messages' %}" href="{% url 'list_held_messages' list.list_id %}">{% trans "Held Messages" %}</a></li>
+ {% endif %}
+ {% if user.is_superuser or user.is_list_owner %}
+ <li class="mm_nav_item"><a class="{% nav_active_class current 'list_settings' %}" href="{% url 'list_settings' list.list_id %}">{% trans "Settings" %}</a></li>
+ {% endif %}
+ {% if user.is_superuser or user.is_list_moderator %}
+ <li class="mm_nav_item"><a class="{% nav_active_class current 'mass_subscribe' %}" href="{% url 'mass_subscribe' list.list_id %}">{% trans "Mass Subscribe" %}</a></li>
+ {% endif %}
+ {% if user.is_superuser or user.is_list_owner %}
+ <li class="mm_nav_item"><a class="{% nav_active_class current 'list_delete' %}" href="{% url 'list_delete' list.list_id %}">{% trans "Delete List" %}</a></li>
{% endif %}
</ul>
{% endif %}
=== modified file 'src/postorius/tests/test_auth_decorators.py'
--- src/postorius/tests/test_auth_decorators.py 2014-03-15 21:36:39 +0000
+++ src/postorius/tests/test_auth_decorators.py 2015-01-18 19:24:47 +0000
@@ -30,12 +30,12 @@
@list_owner_required
-def dummy_function(request, fqdn_listname):
+def dummy_function(request, list_id):
return True
@list_moderator_required
-def dummy_function_mod_req(request, fqdn_listname):
+def dummy_function_mod_req(request, list_id):
return True
@@ -47,7 +47,7 @@
from postorius.tests.utils import create_mock_list
self.request_factory = RequestFactory()
# create a mock list with members
- list_name = '[email protected]'
+ list_name = 'foolist.example.org'
list_id = 'foolist.example.org'
self.mock_list = create_mock_list(dict(
fqdn_listname=list_name,
@@ -57,22 +57,22 @@
def test_not_authenticated(self, mock_get_list):
"""Should raise PermissionDenied if user is not authenticated."""
mock_get_list.return_value = self.mock_list
- request = self.request_factory.get('/lists/[email protected]/'
+ request = self.request_factory.get('/lists/foolist.example.org/'
'settings/')
request.user = AnonymousUser()
self.assertRaises(PermissionDenied, dummy_function, request,
- fqdn_listname='[email protected]')
+ list_id='foolist.example.org')
@patch.object(Client, 'get_list')
def test_superuser(self, mock_get_list):
"""Should call the dummy method, if user is superuser."""
mock_get_list.return_value = self.mock_list
- request = self.request_factory.get('/lists/[email protected]/'
+ request = self.request_factory.get('/lists/foolist.example.org/'
'settings/')
request.user = User.objects.create_superuser('su1', '[email protected]',
'pwd')
return_value = dummy_function(request,
- fqdn_listname='[email protected]')
+ list_id='foolist.example.org')
self.assertEqual(return_value, True)
@patch.object(Client, 'get_list')
@@ -82,12 +82,12 @@
self.mock_list.owners = ['[email protected]']
mock_get_list.return_value = self.mock_list
# prepare request
- request = self.request_factory.get('/lists/[email protected]/'
+ request = self.request_factory.get('/lists/foolist.example.org/'
'settings/')
request.user = User.objects.create_user('les c', '[email protected]',
'pwd')
self.assertRaises(PermissionDenied, dummy_function, request,
- fqdn_listname='[email protected]')
+ list_id='foolist.example.org')
@patch.object(Client, 'get_list')
def test_list_owner(self, mock_get_list):
@@ -96,12 +96,12 @@
self.mock_list.owners = ['[email protected]']
mock_get_list.return_value = self.mock_list
# prepare request
- request = self.request_factory.get('/lists/[email protected]/'
+ request = self.request_factory.get('/lists/foolist.example.org/'
'settings/')
request.user = User.objects.create_user('les cl', '[email protected]',
'pwd')
return_value = dummy_function(request,
- fqdn_listname='[email protected]')
+ list_id='foolist.example.org')
self.assertEqual(return_value, True)
@@ -113,7 +113,7 @@
from postorius.tests.utils import create_mock_list
self.request_factory = RequestFactory()
# create a mock list with members
- list_name = '[email protected]'
+ list_name = 'foolist.example.org'
list_id = 'foolist.example.org'
self.mock_list = create_mock_list(dict(
fqdn_listname=list_name,
@@ -123,23 +123,23 @@
def test_not_authenticated(self, mock_get_list):
"""Should raise PermissionDenied if user is not authenticated."""
mock_get_list.return_value = self.mock_list
- request = self.request_factory.get('/lists/[email protected]/'
+ request = self.request_factory.get('/lists/foolist.example.org/'
'settings/')
request.user = AnonymousUser()
self.assertRaises(PermissionDenied, dummy_function_mod_req, request,
- fqdn_listname='[email protected]')
+ list_id='foolist.example.org')
@patch.object(Client, 'get_list')
def test_superuser(self, mock_get_list):
"""Should call the dummy method, if user is superuser."""
mock_get_list.return_value = self.mock_list
- request = self.request_factory.get('/lists/[email protected]/'
+ request = self.request_factory.get('/lists/foolist.example.org/'
'settings/')
request.user = User.objects.create_superuser('su2', '[email protected]',
'pwd')
return_value = dummy_function_mod_req(request,
- fqdn_listname=
- '[email protected]')
+ list_id=
+ 'foolist.example.org')
self.assertEqual(return_value, True)
@patch.object(Client, 'get_list')
@@ -149,12 +149,12 @@
self.mock_list.moderators = ['[email protected]']
mock_get_list.return_value = self.mock_list
# prepare request
- request = self.request_factory.get('/lists/[email protected]/'
+ request = self.request_factory.get('/lists/foolist.example.org/'
'settings/')
request.user = User.objects.create_user('les cl2', '[email protected]',
'pwd')
self.assertRaises(PermissionDenied, dummy_function_mod_req, request,
- fqdn_listname='[email protected]')
+ list_id='foolist.example.org')
@patch.object(Client, 'get_list')
def test_list_owner(self, mock_get_list):
@@ -163,13 +163,13 @@
self.mock_list.owners = ['[email protected]']
mock_get_list.return_value = self.mock_list
# prepare request
- request = self.request_factory.get('/lists/[email protected]/'
+ request = self.request_factory.get('/lists/foolist.example.org/'
'settings/')
request.user = User.objects.create_user('les cl3', '[email protected]',
'pwd')
return_value = dummy_function_mod_req(request,
- fqdn_listname=
- '[email protected]')
+ list_id=
+ 'foolist.example.org')
self.assertEqual(return_value, True)
@patch.object(Client, 'get_list')
@@ -179,11 +179,11 @@
self.mock_list.moderators = ['[email protected]']
mock_get_list.return_value = self.mock_list
# prepare request
- request = self.request_factory.get('/lists/[email protected]/'
+ request = self.request_factory.get('/lists/foolist.example.org/'
'settings/')
request.user = User.objects.create_user('les cl4', '[email protected]',
'pwd')
return_value = dummy_function_mod_req(request,
- fqdn_listname=
- '[email protected]')
+ list_id=
+ 'foolist.example.org')
self.assertEqual(return_value, True)
=== modified file 'src/postorius/urls.py'
--- src/postorius/urls.py 2014-11-24 19:49:11 +0000
+++ src/postorius/urls.py 2015-01-18 19:24:47 +0000
@@ -108,7 +108,7 @@
url(r'^lists/new/$', 'list_new', name='list_new'),
url(r'^more_info/(?P<formid>[^/]+)/(?P<helpid>[^/]+)$',
'more_info_tab', name='more_info_tab'),
- url(r'^lists/(?P<fqdn_listname>[^/]+)/', include(per_list_urlpatterns)),
+ url(r'^lists/(?P<list_id>[^/]+)/', include(per_list_urlpatterns)),
url(r'^users/address_activation/$',
AddressActivationView.as_view(),
name='address_activation'),
=== modified file 'src/postorius/views/generic.py'
--- src/postorius/views/generic.py 2014-11-19 11:01:19 +0000
+++ src/postorius/views/generic.py 2015-01-18 19:24:47 +0000
@@ -45,8 +45,8 @@
Sets self.mailing_list to list object if fqdn_listname in **kwargs.
"""
- def _get_list(self, fqdn_listname, page):
- return List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ def _get_list(self, list_id, page):
+ return List.objects.get_or_404(fqdn_listname=list_id)
def _is_list_owner(self, user, mailing_list):
if not user.is_authenticated():
@@ -64,9 +64,9 @@
def dispatch(self, request, *args, **kwargs):
# get the list object.
- if 'fqdn_listname' in kwargs:
+ if 'list_id' in kwargs:
try:
- self.mailing_list = self._get_list(kwargs['fqdn_listname'],
+ self.mailing_list = self._get_list(kwargs['list_id'],
int(kwargs.get('page', 1)))
except MailmanApiError:
return utils.render_api_error(request)
=== modified file 'src/postorius/views/list.py'
--- src/postorius/views/list.py 2014-11-24 20:46:28 +0000
+++ src/postorius/views/list.py 2015-01-18 19:24:47 +0000
@@ -44,8 +44,8 @@
"""Display all members of a given list.
"""
- def _get_list(self, fqdn_listname, page):
- m_list = super(ListMembersView, self)._get_list(fqdn_listname, page)
+ def _get_list(self, list_id, page):
+ m_list = super(ListMembersView, self)._get_list(list_id, page)
m_list.member_page = m_list.get_member_page(25, page)
m_list.member_page_nr = page
m_list.member_page_previous_nr = page - 1
@@ -54,7 +54,7 @@
return m_list
@method_decorator(list_owner_required)
- def post(self, request, fqdn_listname, page=1):
+ def post(self, request, list_id, page=1):
if 'owner_email' in request.POST:
owner_form = NewOwnerForm(request.POST)
if owner_form.is_valid():
@@ -88,7 +88,7 @@
context_instance=RequestContext(request))
@method_decorator(list_owner_required)
- def get(self, request, fqdn_listname, page=1):
+ def get(self, request, list_id, page=1):
owner_form = NewOwnerForm()
moderator_form = NewModeratorForm()
return render_to_response('postorius/lists/members.html',
@@ -102,11 +102,11 @@
'''View the preferences for a single member of a mailing list'''
@method_decorator(list_owner_required)
- def post(self, request, fqdn_listname, email):
+ def post(self, request, list_id, email):
try:
client = utils.get_client()
- mm_member = client.get_member(fqdn_listname, email)
- mm_list = client.get_list(fqdn_listname)
+ mm_member = client.get_member(list_id, email)
+ mm_list = client.get_list(list_id)
preferences_form = UserPreferences(request.POST)
if preferences_form.is_valid():
preferences = mm_member.preferences
@@ -134,11 +134,11 @@
context_instance=RequestContext(request))
@method_decorator(list_owner_required)
- def get(self, request, fqdn_listname, email):
+ def get(self, request, list_id, email):
try:
client = utils.get_client()
- mm_member = client.get_member(fqdn_listname, email)
- mm_list = client.get_list(fqdn_listname)
+ mm_member = client.get_member(list_id, email)
+ mm_list = client.get_list(list_id)
settingsform = UserPreferences(initial=mm_member.preferences)
except MailmanApiError:
return utils.render_api_error(request)
@@ -162,7 +162,7 @@
"""
@method_decorator(list_owner_required)
- def get(self, request, fqdn_listname):
+ def get(self, request, list_id):
return render_to_response('postorius/lists/metrics.html',
{'list': self.mailing_list},
context_instance=RequestContext(request))
@@ -173,7 +173,7 @@
"""Shows common list metrics.
"""
- def get(self, request, fqdn_listname):
+ def get(self, request, list_id):
user_email = getattr(request.user, 'email', None)
userSubscribed = False
try:
@@ -195,7 +195,7 @@
"""Subscribe a mailing list."""
@method_decorator(login_required)
- def post(self, request, fqdn_listname):
+ def post(self, request, list_id):
try:
form = ListSubscribe(request.POST)
if form.is_valid():
@@ -211,7 +211,7 @@
return utils.render_api_error(request)
except HTTPError, e:
messages.error(request, e.msg)
- return redirect('list_summary', self.mailing_list.fqdn_listname)
+ return redirect('list_summary', self.mailing_list.list_id)
class ListUnsubscribeView(MailingListView):
@@ -230,7 +230,7 @@
return utils.render_api_error(request)
except ValueError, e:
messages.error(request, e)
- return redirect('list_summary', self.mailing_list.fqdn_listname)
+ return redirect('list_summary', self.mailing_list.list_id)
class ListMassSubsribeView(MailingListView):
@@ -267,7 +267,7 @@
return utils.render_api_error(request)
except HTTPError, e:
messages.error(request, e)
- return redirect('mass_subscribe', self.mailing_list.fqdn_listname)
+ return redirect('mass_subscribe', self.mailing_list.list_id)
def _get_choosable_domains(request):
@@ -313,7 +313,7 @@
list_settings.save()
messages.success(request, _("List created"))
return redirect("list_summary",
- fqdn_listname=mailing_list.fqdn_listname)
+ list_id=mailing_list.list_id)
# TODO catch correct Error class:
except HTTPError, e:
return render_to_response(
@@ -344,7 +344,7 @@
return utils.render_api_error(request)
choosable_domains = _get_choosable_domains(request)
if request.method == 'POST':
- return redirect("list_summary", fqdn_listname=request.POST["list"])
+ return redirect("list_summary", list_id=request.POST["list"])
else:
return render_to_response(template,
{'error': error,
@@ -354,7 +354,7 @@
@login_required
-def list_subscriptions(request, option=None, fqdn_listname=None,
+def list_subscriptions(request, option=None, list_id=None,
user_email=None,
template='postorius/lists/subscriptions.html',
*args, **kwargs):
@@ -369,11 +369,11 @@
error = None
form_subscribe = None
form_unsubscribe = None
- if request.POST.get('fqdn_listname', ''):
- fqdn_listname = request.POST.get('fqdn_listname', '')
+ if request.POST.get('list_id', ''):
+ list_id = request.POST.get('list_id', '')
# connect REST and catch issues getting the list
try:
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
except AttributeError, e:
return render_to_response('postorius/errors/generic.html',
{'error': 'Mailman REST API not available.'
@@ -444,7 +444,7 @@
initial={'fqdn_listname': fqdn_listname,
'email': request.user.username,
'name': 'unsubscribe'})
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
return render_to_response(template,
{'form_subscribe': form_subscribe,
'form_unsubscribe': form_unsubscribe,
@@ -455,11 +455,11 @@
@list_owner_required
-def list_delete(request, fqdn_listname):
+def list_delete(request, list_id):
"""Deletes a list but asks for confirmation first.
"""
try:
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
except MailmanApiError:
return utils.render_api_error(request)
if request.method == 'POST':
@@ -467,7 +467,7 @@
return redirect("list_index")
else:
submit_url = reverse('list_delete',
- kwargs={'fqdn_listname': fqdn_listname})
+ kwargs={'list_id': list_id})
cancel_url = reverse('list_index',)
return render_to_response(
'postorius/lists/confirm_delete.html',
@@ -477,11 +477,11 @@
@list_owner_required
-def list_held_messages(request, fqdn_listname):
+def list_held_messages(request, list_id):
"""Shows a list of held messages.
"""
try:
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
except MailmanApiError:
return utils.render_api_error(request)
return render_to_response('postorius/lists/held_messages.html',
@@ -490,71 +490,71 @@
@list_owner_required
-def accept_held_message(request, fqdn_listname, msg_id):
+def accept_held_message(request, list_id, msg_id):
"""Accepts a held message.
"""
try:
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
the_list.accept_message(msg_id)
except MailmanApiError:
return utils.render_api_error(request)
except HTTPError, e:
messages.error(request, e.msg)
- return redirect('list_held_messages', the_list.fqdn_listname)
+ return redirect('list_held_messages', the_list.list_id)
messages.success(request, 'The message has been accepted.')
- return redirect('list_held_messages', the_list.fqdn_listname)
+ return redirect('list_held_messages', the_list.list_id)
@list_owner_required
-def discard_held_message(request, fqdn_listname, msg_id):
+def discard_held_message(request, list_id, msg_id):
"""Accepts a held message.
"""
try:
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
the_list.discard_message(msg_id)
except MailmanApiError:
return utils.render_api_error(request)
except HTTPError, e:
messages.error(request, e.msg)
- return redirect('list_held_messages', the_list.fqdn_listname)
+ return redirect('list_held_messages', the_list.list_id)
messages.success(request, 'The message has been discarded.')
- return redirect('list_held_messages', the_list.fqdn_listname)
+ return redirect('list_held_messages', the_list.list_id)
@list_owner_required
-def defer_held_message(request, fqdn_listname, msg_id):
+def defer_held_message(request, list_id, msg_id):
"""Accepts a held message.
"""
try:
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
the_list.defer_message(msg_id)
except MailmanApiError:
return utils.render_api_error(request)
except HTTPError, e:
messages.error(request, e.msg)
- return redirect('list_held_messages', the_list.fqdn_listname)
+ return redirect('list_held_messages', the_list.list_id)
messages.success(request, 'The message has been defered.')
- return redirect('list_held_messages', the_list.fqdn_listname)
+ return redirect('list_held_messages', the_list.list_id)
@list_owner_required
-def reject_held_message(request, fqdn_listname, msg_id):
+def reject_held_message(request, list_id, msg_id):
"""Accepts a held message.
"""
try:
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
the_list.reject_message(msg_id)
except MailmanApiError:
return utils.render_api_error(request)
except HTTPError, e:
messages.error(request, e.msg)
- return redirect('list_held_messages', the_list.fqdn_listname)
+ return redirect('list_held_messages', the_list.list_id)
messages.success(request, 'The message has been rejected.')
- return redirect('list_held_messages', the_list.fqdn_listname)
+ return redirect('list_held_messages', the_list.list_id)
@list_owner_required
-def list_settings(request, fqdn_listname=None, visible_section=None,
+def list_settings(request, list_id=None, visible_section=None,
visible_option=None,
template='postorius/lists/settings.html'):
"""
@@ -572,7 +572,7 @@
visible_section = 'List Identity'
form_sections = []
try:
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
except MailmanApiError:
return utils.render_api_error(request)
# collect all Form sections for the links:
@@ -623,12 +623,12 @@
@user_passes_test(lambda u: u.is_superuser)
-def remove_role(request, fqdn_listname=None, role=None, address=None,
+def remove_role(request, list_id=None, role=None, address=None,
template='postorius/lists/confirm_remove_role.html'):
"""Removes a list moderator or owner.
"""
try:
- the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ the_list = List.objects.get_or_404(fqdn_listname=list_id)
except MailmanApiError:
return utils.render_api_error(request)
@@ -636,12 +636,12 @@
if address not in the_list.owners:
messages.error(request,
_('The user {} is not an owner'.format(address)))
- return redirect("list_members", the_list.fqdn_listname)
+ return redirect("list_members", the_list.list_id)
elif role == 'moderator':
if address not in the_list.moderators:
messages.error(request,
_('The user {} is not a moderator'.format(address)))
- return redirect("list_members", the_list.fqdn_listname)
+ return redirect("list_members", the_list.list_id)
if request.method == 'POST':
try:
@@ -651,13 +651,13 @@
except HTTPError as e:
messages.error(request, _('The {0} could not be removed:'
' {1}'.format(role, e.msg)))
- return redirect("list_members", the_list.fqdn_listname)
+ return redirect("list_members", the_list.list_id)
messages.success(request,
_('The user {0} has been removed as {1}.'
.format(address, role)))
- return redirect("list_members", the_list.fqdn_listname)
+ return redirect("list_members", the_list.list_id)
return render_to_response(template,
{'role': role, 'address': address,
- 'fqdn_listname': the_list.fqdn_listname},
+ 'list_id': the_list.list_id},
context_instance=RequestContext(request))
=== modified file 'src/postorius/views/settings.py'
--- src/postorius/views/settings.py 2014-11-19 11:01:19 +0000
+++ src/postorius/views/settings.py 2015-01-18 19:24:47 +0000
@@ -42,7 +42,6 @@
MailmanApiError, Mailman404Error)
from postorius.forms import *
from postorius.auth.decorators import *
-from postorius.views.generic import MailingListView, MailmanUserView
@login_required
_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders