aboutsummaryrefslogtreecommitdiff
path: root/src/django_pgpmailman/views/list.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/django_pgpmailman/views/list.py')
-rw-r--r--src/django_pgpmailman/views/list.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/django_pgpmailman/views/list.py b/src/django_pgpmailman/views/list.py
index bbe2547..d887d7a 100644
--- a/src/django_pgpmailman/views/list.py
+++ b/src/django_pgpmailman/views/list.py
@@ -29,7 +29,8 @@ from django.utils.translation import ugettext_lazy as _
from django.views.generic import FormView
from six.moves.urllib.error import HTTPError
-from django_pgpmailman.decorators import list_view
+from django_pgpmailman.decorators import (list_view, list_class_view,
+ member_role_required)
from django_pgpmailman.forms import (ListSignatureSettingsForm,
ListEncryptionSettingsForm,
ListMiscSettingsForm)
@@ -37,8 +38,7 @@ from django_pgpmailman.plugin import get_pgp_plugin
def pgp_list_index(request):
- return render(request,
- 'django_pgpmailman/index.html',
+ return render(request, 'django_pgpmailman/index.html',
{'lists': get_pgp_plugin().lists})
@@ -48,7 +48,18 @@ def pgp_list_summary(request, pgp_list):
{'pgp_list': pgp_list})
-# TODO: proper list owner auth
+@list_view
+def pgp_list_pubkey(request, pgp_list):
+ pubkey = pgp_list.pubkey
+ pubkey_file = ContentFile(str(pubkey))
+ response = HttpResponse(pubkey_file, 'application/pgp-keys')
+ response['Content-Length'] = pubkey_file.size
+ response[
+ 'Content-Disposition'] = 'attachment; filename="%s.asc"' % pgp_list.list_id
+ return response
+
+
+@method_decorator(login_required, name='dispatch')
class ListSettings(FormView):
properties = None
@@ -65,9 +76,9 @@ class ListSettings(FormView):
data['mlist'] = self.pgp_list.mlist
return data
- @method_decorator(login_required)
+ @list_class_view
+ @member_role_required('owner')
def dispatch(self, request, *args, **kwargs):
- self.pgp_list = get_pgp_plugin().get_list(kwargs['list_id'])
return super(ListSettings, self).dispatch(request, *args, **kwargs)
def form_valid(self, form):
@@ -122,20 +133,8 @@ class ListKeyManagementView(ListSettings):
pass
-# TODO: proper list owner auth
@login_required
@list_view
def pgp_list_key_management(request, pgp_list):
return render(request, 'django_pgpmailman/list/key_management.html',
{'pgp_list': pgp_list})
-
-
-@list_view
-def pgp_list_pubkey(request, pgp_list):
- pubkey = pgp_list.pubkey
- pubkey_file = ContentFile(str(pubkey))
- response = HttpResponse(pubkey_file, 'application/pgp-keys')
- response['Content-Length'] = pubkey_file.size
- response[
- 'Content-Disposition'] = 'attachment; filename="%s.asc"' % pgp_list.list_id
- return response