aboutsummaryrefslogtreecommitdiffstats
path: root/account
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-06-03 00:22:28 +0800
committerWeitian LI <liweitianux@gmail.com>2014-06-03 00:22:28 +0800
commit2288c7f4dca08aa4519b80ace852be8c0526d992 (patch)
tree935e4e5c7223c4e4954d515b4fd6c5d647dac158 /account
parent6d4f8d6cffc00edb4d0adb8ad6351b0830b86369 (diff)
downloaddjango-skaschool-2288c7f4dca08aa4519b80ace852be8c0526d992.tar.bz2
Fixed a type 'identify' and updated 'list_approved' display contents
* changed 'identify' to 'identity' in Model 'UserProfile' * updated forms.py, admin.py, profile.html related to 'identity' * added South migration for renaming field 'identify' to 'identity' * updated display contents of 'list_approved': removed 'identity' column * updated 'institute' field name to 'institute (and major)' * updated related translations
Diffstat (limited to 'account')
-rw-r--r--account/admin.py2
-rw-r--r--account/forms.py15
-rw-r--r--account/migrations/0003_auto__rename_field_userprofile_identify_to_identity.py84
-rw-r--r--account/models.py28
-rw-r--r--account/templates/account/list_approved.html4
-rw-r--r--account/templates/account/profile.html4
6 files changed, 110 insertions, 27 deletions
diff --git a/account/admin.py b/account/admin.py
index 46498eb..3ed5276 100644
--- a/account/admin.py
+++ b/account/admin.py
@@ -36,7 +36,7 @@ class UserProfileAdmin(admin.ModelAdmin):
'realname',
'gender',
'institute',
- 'identify',
+ 'identity',
'reason',
'transcript_url',
'supplement',
diff --git a/account/forms.py b/account/forms.py
index cb0b6b2..daa6683 100644
--- a/account/forms.py
+++ b/account/forms.py
@@ -21,13 +21,12 @@ class UserRegForm(RegistrationFormUniqueEmail):
based on 'django-registration' RegistrationFormUniqueEmail
add fields 'realname', 'gender', 'institute' and 'captcha'
"""
- # XXX: keep consistent with GENDERS in 'models.UserProfile'
GENDERS = UserProfile.GENDERS
- IDENTIFIES = UserProfile.IDENTIFIES
+ IDENTITIES = UserProfile.IDENTITIES
realname = forms.CharField(max_length=30, label=_("Name"))
gender = forms.ChoiceField(choices=GENDERS, label=_("Gender"))
- institute = forms.CharField(max_length=100, label=_("Institute"))
- identify = forms.ChoiceField(choices=IDENTIFIES, label=_("Identify"))
+ institute = forms.CharField(max_length=100, label=_("Institute (and major)"))
+ identity = forms.ChoiceField(choices=IDENTITIES, label=_("Identity"))
captcha = ReCaptchaField(label=_("Captcha"),
attrs={'theme': 'clean'})
@@ -42,7 +41,7 @@ class UserRegForm(RegistrationFormUniqueEmail):
# 'realname',
# 'gender',
# 'institute',
- # 'identify',
+ # 'identity',
# ]
@@ -110,7 +109,7 @@ class UpdateProfileForm(forms.ModelForm):
'realname',
'gender',
'institute',
- 'identify',
+ 'identity',
'reason',
'transcript',
'supplement',
@@ -128,7 +127,7 @@ class UpdateProfileForm(forms.ModelForm):
'email',
'gender',
'institute',
- 'identify',
+ 'identity',
'reason',
'transcript',
'supplement',
@@ -141,7 +140,7 @@ class UpdateProfileForm(forms.ModelForm):
form_data = self.cleaned_data
user = form_data.get('user')
profile = user.userprofile_set.get(user=user)
- profile.identify = form_data.get('identify', profile.identify)
+ profile.identity = form_data.get('identity', profile.identity)
transcript = self.cleaned_data.get('transcript', False)
if (profile.is_transcript_required() and (not transcript)):
raise forms.ValidationError(_("Transcript is required."), code='required')
diff --git a/account/migrations/0003_auto__rename_field_userprofile_identify_to_identity.py b/account/migrations/0003_auto__rename_field_userprofile_identify_to_identity.py
new file mode 100644
index 0000000..ae02a3b
--- /dev/null
+++ b/account/migrations/0003_auto__rename_field_userprofile_identify_to_identity.py
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+from south.utils import datetime_utils as datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Rename field 'identify' to 'identity'
+ db.rename_column(u'account_userprofile', 'identify', 'identity')
+
+
+ def backwards(self, orm):
+ # Rename field 'identity' to 'identify'
+ db.rename_column(u'account_userprofile', 'identity', 'identify')
+
+
+ models = {
+ u'account.userfile': {
+ 'Meta': {'ordering': "['user', 'id']", 'object_name': 'UserFile'},
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'file': ('account.extra.ContentTypeRestrictedFileField', [], {'content_types': "['application/gzip', 'application/msword', 'application/pdf', 'application/postscript', 'application/rar', 'application/vnd.ms-excel', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.presentation', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/wps-office.doc', 'application/wps-office.dps', 'application/wps-office.et', 'application/wps-office.ppt', 'application/wps-office.pptx', 'application/wps-office.wps', 'application/wps-office.xls', 'application/zip', 'application/x-7z-compressed', 'application/x-bzip2', 'application/x-dvi', 'application/x-latex', 'application/x-rar-compressed', 'application/x-tar', 'image/bmp', 'image/gif', 'image/jpeg', 'image/png', 'image/tiff', 'text/csv', 'text/plain', 'text/rtf', 'text/x-markdown', 'text/x-tex']", 'max_upload_size': '10485760', 'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
+ },
+ u'account.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ 'gender': ('django.db.models.fields.CharField', [], {'max_length': '1'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'identity': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
+ 'institute': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'is_approved': ('django.db.models.fields.CharField', [], {'default': "'C'", 'max_length': '1'}),
+ 'is_checkin': ('django.db.models.fields.CharField', [], {'default': "'X'", 'max_length': '1'}),
+ 'is_sponsored': ('django.db.models.fields.CharField', [], {'default': "'C'", 'max_length': '1'}),
+ 'realname': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
+ 'reason': ('django.db.models.fields.TextField', [], {}),
+ 'supplement': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'transcript': ('account.extra.ContentTypeRestrictedFileField', [], {'content_types': "['application/gzip', 'application/msword', 'application/pdf', 'application/postscript', 'application/rar', 'application/vnd.ms-excel', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.presentation', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/wps-office.doc', 'application/wps-office.dps', 'application/wps-office.et', 'application/wps-office.ppt', 'application/wps-office.pptx', 'application/wps-office.wps', 'application/wps-office.xls', 'application/zip', 'application/x-7z-compressed', 'application/x-bzip2', 'application/x-dvi', 'application/x-latex', 'application/x-rar-compressed', 'application/x-tar', 'image/bmp', 'image/gif', 'image/jpeg', 'image/png', 'image/tiff', 'text/csv', 'text/plain', 'text/rtf', 'text/x-markdown', 'text/x-tex']", 'max_upload_size': '10485760', 'null': 'True', 'max_length': '100', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'unique': 'True'})
+ },
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ }
+ }
+
+ complete_apps = ['account']
diff --git a/account/models.py b/account/models.py
index fba0f48..0565731 100644
--- a/account/models.py
+++ b/account/models.py
@@ -48,8 +48,8 @@ class UserProfile(models.Model):
('N', _("No")),
('X', _("N/A")),
)
- # choices for identify
- IDENTIFIES = (
+ # choices for identity
+ IDENTITIES = (
('OT', _("Other")),
('UG', _("Undergraudate (junior and below)")),
('U4', _("Undergraudate (senior)")),
@@ -70,9 +70,9 @@ class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True, verbose_name=_("User"))
realname = models.CharField(_("Name"), max_length=30)
gender = models.CharField(_("Gender"), max_length=1, choices=GENDERS)
- institute = models.CharField(_("Institute"), max_length=100)
- identify = models.CharField(_("Identify"), max_length=2,
- choices=IDENTIFIES)
+ institute = models.CharField(_("Institute (and major)"), max_length=100)
+ identity = models.CharField(_("Identity"), max_length=2,
+ choices=IDENTITIES)
# reasons to participate
reason = models.TextField(_("Why attend"))
# transcript: needed if undergraudate (junior and below)
@@ -123,10 +123,10 @@ class UserProfile(models.Model):
def is_transcript_required(self):
"""
- if 'identify' is UG (undergraduate junior and below); then
+ if 'identity' is UG (undergraduate junior and below); then
transcript is required, return True. Otherwise, return False
"""
- if (self.identify == 'UG'):
+ if (self.identity == 'UG'):
return True
else:
return False
@@ -175,12 +175,12 @@ class UserProfile(models.Model):
checkin_dict = dict((k, v) for k, v in self.CHECKIN_STATUS)
return checkin_dict.get(self.is_checkin)
- def get_identify_value(self):
+ def get_identity_value(self):
"""
- return the corresponding value of identify for the user
+ return the corresponding value of identity for the user
"""
- identifies_dict = dict((k, v) for k, v in self.IDENTIFIES)
- return identifies_dict.get(self.identify)
+ identifies_dict = dict((k, v) for k, v in self.IDENTITIES)
+ return identifies_dict.get(self.identity)
def get_userfiles(self):
"""
@@ -198,7 +198,7 @@ class UserProfile(models.Model):
'realname': self._meta.get_field_by_name('realname')[0].verbose_name,
'gender': self._meta.get_field_by_name('gender')[0].verbose_name,
'institute': self._meta.get_field_by_name('institute')[0].verbose_name,
- 'identify': self._meta.get_field_by_name('identify')[0].verbose_name,
+ 'identity': self._meta.get_field_by_name('identity')[0].verbose_name,
'reason': self._meta.get_field_by_name('reason')[0].verbose_name,
'transcript': self._meta.get_field_by_name('transcript')[0].verbose_name,
'supplement': self._meta.get_field_by_name('supplement')[0].verbose_name,
@@ -225,7 +225,7 @@ class UserProfile(models.Model):
'realname': self.realname,
'gender': self.get_gender_value(),
'institute': self.institute,
- 'identify': self.get_identify_value(),
+ 'identity': self.get_identity_value(),
'reason': self.reason,
'transcript': transcript,
'supplement': self.supplement,
@@ -298,7 +298,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.identity = request.POST['identity']
profile.save()
# connect 'user_registered_callback' to signal user_registered
diff --git a/account/templates/account/list_approved.html b/account/templates/account/list_approved.html
index 8c2587d..0db16af 100644
--- a/account/templates/account/list_approved.html
+++ b/account/templates/account/list_approved.html
@@ -25,7 +25,7 @@
<tr>
<th class="col-md-1 list-number">序号</th>
<th class="col-md-2 list-name">姓名</th>
- {# <th class="col-md-3 list-identify">身份</th> #}
+ {# <th class="col-md-3 list-identity">身份</th> #}
<th class="col-md-6 list-institute">单位(及专业)</th>
</tr>
</thead>
@@ -35,7 +35,7 @@
<tr{% if approved_profile.user == user %} class="success"{% endif %}>
<td>{{ forloop.counter }}</td>
<td>{{ approved_profile.realname }}</td>
- {# <td>{% trans approved_profile.get_identify_value %}</td> #}
+ {# <td>{% trans approved_profile.get_identity_value %}</td> #}
<td>{{ approved_profile.institute }}</td>
</tr>
{% endfor %}
diff --git a/account/templates/account/profile.html b/account/templates/account/profile.html
index 88e938f..d2b73e7 100644
--- a/account/templates/account/profile.html
+++ b/account/templates/account/profile.html
@@ -58,8 +58,8 @@
<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>
+ <th class="profile-identity">身份</th>
+ <td class="profile-identity-data">{% trans profile.get_identity_value %}</td>
</tr>
<tr>
<th class="profile-reason">为什么参加</th>