aboutsummaryrefslogtreecommitdiffstats
path: root/account
diff options
context:
space:
mode:
Diffstat (limited to 'account')
-rw-r--r--account/admin.py101
-rw-r--r--account/migrations/0001_initial.py111
-rw-r--r--account/migrations/0002_auto__add_field_userprofile_is_checkin.py86
-rw-r--r--account/migrations/__init__.py0
-rw-r--r--account/models.py62
-rw-r--r--account/templates/account/profile.html14
6 files changed, 371 insertions, 3 deletions
diff --git a/account/admin.py b/account/admin.py
index fe6fca1..39c1c5c 100644
--- a/account/admin.py
+++ b/account/admin.py
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
from django.contrib import admin
+from django.conf.urls import url
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
+from django.http import HttpResponse
from account.models import UserProfile, UserFile
@@ -15,14 +17,18 @@ class UserProfileAdmin(admin.ModelAdmin):
"""
actions = [
'approve_users',
- 'sponsor_users',
'cancel_approve_users',
- 'cancel_sponsor_users',
'reset_approve_users',
+ 'sponsor_users',
+ 'cancel_sponsor_users',
'reset_sponsor_users',
+ 'users_checkin',
+ 'users_not_checkin',
+ 'users_checkin_reset',
]
list_display = (
'user',
+ 'email',
'realname',
'gender',
'institute',
@@ -33,7 +39,15 @@ class UserProfileAdmin(admin.ModelAdmin):
'attachments',
'is_approved',
'is_sponsored',
+ 'is_checkin',
)
+ # search fields
+ search_fields = [
+ 'user__username',
+ 'user__email',
+ 'realname',
+ 'institute',
+ ]
## custom admin actions
def approve_users(self, request, queryset):
@@ -108,7 +122,52 @@ class UserProfileAdmin(admin.ModelAdmin):
self.message_user(request, msg)
reset_sponsor_users.short_description = _("Reset sponsor users")
+ # control 'is_checkin' field
+ def users_checkin(self, request, queryset):
+ """
+ Mark selected users as checked in.
+ """
+ profiles_updated = queryset.update(is_checkin='Y')
+ if profiles_updated == 1:
+ msg = _("1 user was successfully marked as checkin.")
+ else:
+ msg = _("%(num)s users were successfully marked as checkin." % {'num': profiles_updated})
+ self.message_user(request, msg)
+ users_checkin.short_description = _("Mark users as checked in")
+
+ def users_not_checkin(self, request, queryset):
+ """
+ Mark selected users as NOT checked in.
+ """
+ profiles_updated = queryset.update(is_checkin='N')
+ if profiles_updated == 1:
+ msg = _("1 user was marked as not checkin.")
+ else:
+ msg = _("%(num)s users were marked as not checkin." % {'num': profiles_updated})
+ self.message_user(request, msg)
+ users_not_checkin.short_description = _("Mark users as not checked in")
+
+ def users_checkin_reset(self, request, queryset):
+ """
+ Reset checkin status of selected users.
+ """
+ profiles_updated = queryset.update(is_checkin='X')
+ if profiles_updated == 1:
+ msg = _("1 user was reset status of checkin.")
+ else:
+ msg = _("%(num)s users were reset status of checkin." % {'num': profiles_updated})
+ self.message_user(request, msg)
+ users_checkin_reset.short_description = _("Reset users checkin status")
+
## custom fields
+ def email(self, obj):
+ """
+ return the email of the user profile
+ """
+ user = obj.user
+ return user.email
+ email.short_description = _("E-mail")
+
def transcript_url(self, obj):
"""
return the html code of transcript with url link
@@ -143,7 +202,43 @@ class UserProfileAdmin(admin.ModelAdmin):
return format_html(html)
attachments.short_description = _("Attachments")
-
+ ## added a view to display all userprofile info (csv format)
+ def get_urls(self):
+ urls = super(type(self), self).get_urls()
+ my_urls = [
+ url(r'^csv/$', self.userprofile_csv_view,
+ name='userprofile_csv_view'),
+ ]
+ return my_urls + urls
+
+ def userprofile_csv_view(self, request):
+ """
+ custom admin view to display all userprofile info in csv format
+ """
+ userprofile_objs = UserProfile.objects.all()
+ fieldnames = userprofile_objs[0].dump_fieldnames()
+ fields = [k for k,v in fieldnames.items()]
+ # header
+ header = u''
+ for k in fields:
+ header += u'{0},'.format(fieldnames[k])
+ header += '\n'
+ # contents
+ contents = u''
+ for obj in userprofile_objs:
+ data = obj.dump()
+ cline = u''
+ for k in fields:
+ if k == 'attachments':
+ cline += u'{0},'.format('||'.join(data[k]))
+ else:
+ cline += u'{0},'.format(data[k])
+ cline += '\n'
+ contents += cline
+ return HttpResponse(header+contents, content_type='text/plain')
+
+
+###
admin.site.register(UserProfile, UserProfileAdmin)
admin.site.register(UserFile)
diff --git a/account/migrations/0001_initial.py b/account/migrations/0001_initial.py
new file mode 100644
index 0000000..daf3104
--- /dev/null
+++ b/account/migrations/0001_initial.py
@@ -0,0 +1,111 @@
+# -*- 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):
+ # Adding model 'UserProfile'
+ db.create_table(u'account_userprofile', (
+ (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], unique=True)),
+ ('realname', self.gf('django.db.models.fields.CharField')(max_length=30)),
+ ('gender', self.gf('django.db.models.fields.CharField')(max_length=1)),
+ ('institute', self.gf('django.db.models.fields.CharField')(max_length=100)),
+ ('identify', self.gf('django.db.models.fields.CharField')(max_length=2)),
+ ('reason', self.gf('django.db.models.fields.TextField')()),
+ ('transcript', self.gf('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)),
+ ('supplement', self.gf('django.db.models.fields.TextField')(blank=True)),
+ ('is_approved', self.gf('django.db.models.fields.CharField')(default='C', max_length=1)),
+ ('is_sponsored', self.gf('django.db.models.fields.CharField')(default='C', max_length=1)),
+ ))
+ db.send_create_signal(u'account', ['UserProfile'])
+
+ # Adding model 'UserFile'
+ db.create_table(u'account_userfile', (
+ (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=100)),
+ ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
+ ('file', self.gf('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)),
+ ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+ ('modified_at', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
+ ))
+ db.send_create_signal(u'account', ['UserFile'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'UserProfile'
+ db.delete_table(u'account_userprofile')
+
+ # Deleting model 'UserFile'
+ db.delete_table(u'account_userfile')
+
+
+ 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'}),
+ 'identify': ('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_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'] \ No newline at end of file
diff --git a/account/migrations/0002_auto__add_field_userprofile_is_checkin.py b/account/migrations/0002_auto__add_field_userprofile_is_checkin.py
new file mode 100644
index 0000000..51784e6
--- /dev/null
+++ b/account/migrations/0002_auto__add_field_userprofile_is_checkin.py
@@ -0,0 +1,86 @@
+# -*- 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):
+ # Adding field 'UserProfile.is_checkin'
+ db.add_column(u'account_userprofile', 'is_checkin',
+ self.gf('django.db.models.fields.CharField')(default='X', max_length=1),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'UserProfile.is_checkin'
+ db.delete_column(u'account_userprofile', 'is_checkin')
+
+
+ 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'}),
+ 'identify': ('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'] \ No newline at end of file
diff --git a/account/migrations/__init__.py b/account/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/account/migrations/__init__.py
diff --git a/account/models.py b/account/models.py
index 87ae0b5..8df0e94 100644
--- a/account/models.py
+++ b/account/models.py
@@ -42,6 +42,12 @@ class UserProfile(models.Model):
('N', _("No")),
('C', _("Checking")),
)
+ # status choices for is_checkin
+ CHECKIN_STATUS = (
+ ('Y', _("Yes")),
+ ('N', _("No")),
+ ('X', _("N/A")),
+ )
# choices for identify
IDENTIFIES = (
('OT', _("Other")),
@@ -83,6 +89,8 @@ class UserProfile(models.Model):
choices=APPROVED_STATUS, default='C')
is_sponsored = models.CharField(_("Is sponsored"), max_length=1,
choices=SPONSORED_STATUS, default='C')
+ is_checkin = models.CharField(_("Is checkin"), max_length=1,
+ choices=CHECKIN_STATUS, default='X')
class Meta:
verbose_name = _('user profile')
@@ -160,6 +168,13 @@ class UserProfile(models.Model):
sponsored_dict = dict((k, v) for k, v in self.SPONSORED_STATUS)
return sponsored_dict.get(self.is_sponsored)
+ def get_checkin_value(self):
+ """
+ return the corresponding value of checkin for the user
+ """
+ checkin_dict = dict((k, v) for k, v in self.CHECKIN_STATUS)
+ return checkin_dict.get(self.is_checkin)
+
def get_identify_value(self):
"""
return the corresponding value of identify for the user
@@ -174,6 +189,53 @@ class UserProfile(models.Model):
"""
return self.user.userfile_set.all()
+ ## fields and names of dumped data
+ def dump_fieldnames(self, *args, **kwargs):
+ fields = {
+ 'id': self.user._meta.get_field_by_name('id')[0].verbose_name,
+ 'username': self.user._meta.get_field_by_name('username')[0].verbose_name,
+ 'email': self.user._meta.get_field_by_name('email')[0].verbose_name,
+ '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,
+ '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,
+ 'is_approved': self._meta.get_field_by_name('is_approved')[0].verbose_name,
+ 'is_sponsored': self._meta.get_field_by_name('is_sponsored')[0].verbose_name,
+ 'is_checkin': self._meta.get_field_by_name('is_checkin')[0].verbose_name,
+ 'attachments': _("attachments"),
+ }
+ return fields
+
+ ## dump all data of user profile
+ def dump(self, *args, **kwargs):
+ """
+ Dump all data of the userprofile
+ """
+ if self.transcript:
+ transcript = self.transcript.url
+ else:
+ transcript = None
+ data = {
+ 'id': self.id,
+ 'username': self.user.username,
+ 'email': self.user.email,
+ 'realname': self.realname,
+ 'gender': self.get_gender_value(),
+ 'institute': self.institute,
+ 'identify': self.get_identify_value(),
+ 'reason': self.reason,
+ 'transcript': transcript,
+ 'supplement': self.supplement,
+ 'is_approved': self.get_approved_value(),
+ 'is_sponsored': self.get_sponsored_value(),
+ 'is_checkin': self.get_checkin_value(),
+ 'attachments': [obj.file.url for obj in self.get_userfiles()],
+ }
+ return data
+
class UserFile(models.Model):
"""
diff --git a/account/templates/account/profile.html b/account/templates/account/profile.html
index ad367f1..88e938f 100644
--- a/account/templates/account/profile.html
+++ b/account/templates/account/profile.html
@@ -103,6 +103,20 @@
{% endif %}
</td>
</tr>
+ <tr>
+ <th class="profile-checkin">是否报到</th>
+ <td class="profile-checkin-data">
+ {% if profile.is_checkin == 'Y' %}
+ <span class="glyphicon glyphicon-ok"></span> <span class="label label-success">是</span>
+ {% elif profile.is_checkin == 'N' %}
+ <span class="glyphicon glyphicon-remove"></span> <span class="label label-warning">否</span>
+ {% elif profile.is_checkin == 'X' %}
+ <span class="glyphicon glyphicon-question-sign"></span> <span class="label label-default">不可用</span>
+ {% else %}
+ <span class="glyphicon glyphicon-warning-sign"></span> <span class="label label-danger">系统错误</span>
+ {% endif %}
+ </td>
+ </tr>
{# user uploaded files #}
{% if userfiles %}
<tr>