From f50c9510d7bdcabad39fc2441a37235faf600a39 Mon Sep 17 00:00:00 2001 From: Weitian LI Date: Tue, 20 May 2014 20:58:13 +0800 Subject: small updates to account/models.py --- account/models.py | 16 +++++++++++----- 1 file 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) -- cgit v1.2.2