aboutsummaryrefslogtreecommitdiff
path: root/src/django_pgpmailman/decorators.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/django_pgpmailman/decorators.py')
-rw-r--r--src/django_pgpmailman/decorators.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/django_pgpmailman/decorators.py b/src/django_pgpmailman/decorators.py
index 5f994b6..7e700a0 100644
--- a/src/django_pgpmailman/decorators.py
+++ b/src/django_pgpmailman/decorators.py
@@ -21,14 +21,14 @@ from django.http import Http404
from six import wraps
from six.moves.urllib_error import HTTPError
-from django_pgpmailman.plugin import get_pgp_plugin
+from django_pgpmailman.plugin import get_plugin, get_client
def list_view(fn):
@wraps(fn)
def wrapper(request, *args, **kwargs):
try:
- pgp_list = get_pgp_plugin().get_list(kwargs.pop('list_id'))
+ pgp_list = get_plugin().get_list(kwargs.pop('list_id'))
except HTTPError:
raise Http404
return fn(request, pgp_list, *args, **kwargs)
@@ -39,7 +39,7 @@ def list_view(fn):
def list_class_view(fn):
@wraps(fn)
def wrapper(self, request, *args, **kwargs):
- self.pgp_list = get_pgp_plugin().get_list(kwargs.pop('list_id'))
+ self.pgp_list = get_plugin().get_list(kwargs.pop('list_id'))
return fn(self, request, *args, **kwargs)
return wrapper
@@ -68,3 +68,17 @@ def member_role_required(*roles):
return wrapped
return wrapper
+
+
+def user_class_view(fn):
+ @wraps(fn)
+ def wrapper(self, request, *args, **kwargs):
+ client = get_client()
+ user = request.user
+ try:
+ self.mm_user = client.get_user(address=user.email)
+ except HTTPError:
+ self.mm_user = client.create_user(user.email, user.get_full_name())
+ return fn(self, request, *args, **kwargs)
+
+ return wrapper