aboutsummaryrefslogtreecommitdiff
path: root/src/django_pgpmailman/views/user.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/django_pgpmailman/views/user.py')
-rw-r--r--src/django_pgpmailman/views/user.py40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/django_pgpmailman/views/user.py b/src/django_pgpmailman/views/user.py
index ecc1b9e..cc1dbc3 100644
--- a/src/django_pgpmailman/views/user.py
+++ b/src/django_pgpmailman/views/user.py
@@ -16,9 +16,41 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
from django.contrib.auth.decorators import login_required
-from django.shortcuts import render
+from django.utils.decorators import method_decorator
+from django.views.generic import TemplateView
+from six.moves.urllib_error import HTTPError
+from django_pgpmailman.decorators import user_class_view
+from django_pgpmailman.plugin import get_plugin
-@login_required
-def pgp_user_profile(request):
- return render(request, 'django_pgpmailman/user/summary.html')
+
+class UserSummaryView(TemplateView):
+ template_name = 'django_pgpmailman/user/summary.html'
+
+ @method_decorator(login_required)
+ @user_class_view
+ def dispatch(self, request, *args, **kwargs):
+ return super(UserSummaryView, self).dispatch(request, *args, **kwargs)
+
+ def get_context_data(self, **kwargs):
+ data = super(UserSummaryView, self).get_context_data(**kwargs)
+ addresses = []
+ for address in self.mm_user.addresses:
+ try:
+ addresses.append(get_plugin().get_address(address.email))
+ except HTTPError:
+ pass
+ data['addresses'] = addresses
+ return data
+
+#
+# class UserSummaryView(FormView):
+# template_name = 'django_pgpmailman/user/summary.html'
+#
+# @method_decorator(login_required)
+# @user_class_view
+# def dispatch(self, request, *args, **kwargs):
+# return super(UserSummaryView, self).dispatch(request, *args, **kwargs)
+#
+# def get_form_class(self):
+# return formset_factory(AddressForm, )