aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--account/models.py31
-rw-r--r--account/templates/account/profile.html5
2 files changed, 35 insertions, 1 deletions
diff --git a/account/models.py b/account/models.py
index 9f2fff7..d9fb8ea 100644
--- a/account/models.py
+++ b/account/models.py
@@ -17,8 +17,8 @@ class UserProfile(models.Model):
"""
custom user profile
connected with signal 'user_registered' sent by 'django-registration'
+ NOTE: keep this model fields consistent with 'user_registered_callback'
"""
- # XXX: keep consistent with GENDERS in 'forms.UserRegForm'
GENDERS = (
('M', _("Male")),
('F', _("Female")),
@@ -84,6 +84,34 @@ class UserProfile(models.Model):
"""
return self.objects.filter(is_sponsored='Y')
+ def get_gender_value(self):
+ """
+ return the corresponding value of user's gender
+ """
+ genders_dict = dict((k, v) for k, v in self.GENDERS)
+ return genders_dict.get(self.gender)
+
+ def get_approved_value(self):
+ """
+ return the corresponding value of is_approved for the user
+ """
+ approved_dict = dict((k, v) for k, v in self.APPROVED_STATUS)
+ return approved_dict.get(self.is_approved)
+
+ def get_sponsored_value(self):
+ """
+ return the corresponding value of is_sponsored for the user
+ """
+ sponsored_dict = dict((k, v) for k, v in self.SPONSORED_STATUS)
+ return sponsored_dict.get(self.is_sponsored)
+
+ def get_identify_value(self):
+ """
+ return the corresponding value of identify for the user
+ """
+ identifies_dict = dict((k, v) for k, v in self.IDENTIFIES)
+ return identifies_dict.get(self.identify)
+
###### signal callback ######
def user_registered_callback(sender, user, request, **kwargs):
@@ -96,6 +124,7 @@ def user_registered_callback(sender, user, request, **kwargs):
profile.realname = request.POST['realname']
profile.gender = request.POST['gender']
profile.institute = request.POST['institute']
+ profile.identify = request.POST['identify']
profile.save()
### connect 'user_registered_callback' to signal
diff --git a/account/templates/account/profile.html b/account/templates/account/profile.html
index e8d295c..4f5532d 100644
--- a/account/templates/account/profile.html
+++ b/account/templates/account/profile.html
@@ -1,6 +1,7 @@
{% extends 'base.html' %}
{% load staticfiles %}
{% load url from future %}
+{% load i18n %}
{% load bootstrap3 %}
{# login template #}
@@ -43,6 +44,10 @@
<td class="profile-institute-data">{{ profile.institute }}</td>
</tr>
<tr>
+ <th class="profile-identify">身份</th>
+ <td class="profile-identify-data">{% trans profile.get_identify_value %}</td>
+ </tr>
+ <tr>
<th class="profile-approval">是否审定</th>
<td class="profile-approval-data">
{% if profile.is_approved == 'Y' %}