aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-04-29 11:04:43 +0800
committerWeitian LI <liweitianux@gmail.com>2014-04-29 11:04:43 +0800
commit4bbb74401354c118ddbc0aebf131a5253ba5f48b (patch)
treead3a21ebecaded6ce0e68a32ae3fb30e4fc81990
parent95e8fd215f04941e9de214f42b4572c12a9d17ff (diff)
downloaddjango-skaschool-4bbb74401354c118ddbc0aebf131a5253ba5f48b.tar.bz2
Replaced get_object_or_404 with query in ListApprovedView, thus admin
can browser approved user list normally.
-rw-r--r--account/templates/account/list_approved.html2
-rw-r--r--account/views.py6
2 files changed, 6 insertions, 2 deletions
diff --git a/account/templates/account/list_approved.html b/account/templates/account/list_approved.html
index 6295765..a58312b 100644
--- a/account/templates/account/list_approved.html
+++ b/account/templates/account/list_approved.html
@@ -15,7 +15,7 @@
<h2>审定名单</h2>
<br>
{# alert if the user not approved #}
- {% if profile.is_approved == 'N' %}
+ {% if profile and profile.is_approved == 'N' %}
<div class="alert alert-warning">
很抱歉,您未能被批准参加本次SKA暑期学校,感谢您的关注和参与。
</div>
diff --git a/account/views.py b/account/views.py
index 14be14c..1380203 100644
--- a/account/views.py
+++ b/account/views.py
@@ -135,7 +135,11 @@ class ListApprovedView(ListView):
"""
context = super(ListApprovedView, self).get_context_data(**kwargs)
user = self.request.user
- profile = get_object_or_404(UserProfile, user=user)
+ profile_qset = user.userprofile_set.all()
+ if profile_qset:
+ profile = profile_qset[0]
+ else:
+ profile = None
context['user'] = user
context['profile'] = profile
return context