aboutsummaryrefslogtreecommitdiffstats
path: root/account
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-05-20 20:58:13 +0800
committerWeitian LI <liweitianux@gmail.com>2014-05-20 20:58:13 +0800
commitf50c9510d7bdcabad39fc2441a37235faf600a39 (patch)
tree678bfe183a61bd9a357fa773c3409532ab5388b9 /account
parent99edd912082815a519fb3823c06961e9fd970ec7 (diff)
downloaddjango-skaschool-f50c9510d7bdcabad39fc2441a37235faf600a39.tar.bz2
small updates to account/models.py
Diffstat (limited to 'account')
-rw-r--r--account/models.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/account/models.py b/account/models.py
index 8df0e94..fba0f48 100644
--- a/account/models.py
+++ b/account/models.py
@@ -18,7 +18,7 @@ from account.extra import ContentTypeRestrictedFileField, OverwriteStorage, file
import os
-###### account models ######
+### UserProfile model {{{
class UserProfile(models.Model):
"""
custom user profile
@@ -235,8 +235,10 @@ class UserProfile(models.Model):
'attachments': [obj.file.url for obj in self.get_userfiles()],
}
return data
+### UserProfile }}}
+### UserFile model {{{
class UserFile(models.Model):
"""
model to deal with user uploaded files
@@ -282,9 +284,10 @@ class UserFile(models.Model):
old_obj.file.delete(save=False)
#
return result
+### UserFile model }}}
-###### signal callback ######
+### registration signal callback {{{
def user_registered_callback(sender, user, request, **kwargs):
"""
callback of signal 'user_registered' from 'django-registration'
@@ -298,10 +301,12 @@ def user_registered_callback(sender, user, request, **kwargs):
profile.identify = request.POST['identify']
profile.save()
-### connect 'user_registered_callback' to signal user_registered
+# connect 'user_registered_callback' to signal user_registered
user_registered.connect(user_registered_callback)
+### user_registered }}}
-### login user after activated
+
+### login user after activated {{{
def login_on_activation(sender, user, request, **kwargs):
"""
Logs in the user after activation
@@ -311,9 +316,10 @@ def login_on_activation(sender, user, request, **kwargs):
# connect 'login_on_activation' to signal user_activated
user_activated.connect(login_on_activation)
+### user_activated }}}
-### connect to signal and sender
+### connect to signal and sender (cleanup uploaded files)
pre_delete.connect(file_cleanup, sender=UserProfile)
pre_delete.connect(file_cleanup, sender=UserFile)