diff options
Diffstat (limited to 'account/views.py')
-rw-r--r-- | account/views.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/account/views.py b/account/views.py index e6b90b1..3186abb 100644 --- a/account/views.py +++ b/account/views.py @@ -7,6 +7,7 @@ views.py of app 'account' from django.shortcuts import render from django.views.generic.base import TemplateView from django.views.generic.edit import UpdateView +from django.views.generic.list import ListView from django.core.urlresolvers import reverse_lazy from django.http import HttpResponseRedirect @@ -29,6 +30,7 @@ class ProfileView(TemplateView): context['profile'] = profile return context + class UpdateProfileView(UpdateView): form_class = UpdateProfileForm model = UserProfile @@ -66,3 +68,22 @@ class UpdateProfileView(UpdateView): return super(UpdateProfileView, self).form_valid(form) +class ListApprovedView(ListView): + """ + class-based view to show list of approved users + """ + queryset = UserProfile.objects.filter(is_approved='Y') + template_name = 'account/list_approved.html' + # allow queryset/model returns no object, otherwise 404error raised + allow_empty = True + + def get_context_data(self, **kwargs): + """ + add 'user' context + """ + context = super(ListApprovedView, self).get_context_data(**kwargs) + user = self.request.user + context['user'] = user + return context + + |