diff options
author | Alvin Li <liweitianux@gmail.com> | 2013-10-05 02:12:28 +0800 |
---|---|---|
committer | Alvin Li <liweitianux@gmail.com> | 2013-10-05 02:12:28 +0800 |
commit | 46b4f8407f40cfcc0abf6c6e4fbc8fcbee00151d (patch) | |
tree | 57538c2540662dc2c9749d4e1e58cd9bcb472c9e /97suifangqa/apps/sfaccount/models.py | |
parent | f552b41f4b337e6844f71c29ff177915abbfa417 (diff) | |
download | 97dev-46b4f8407f40cfcc0abf6c6e4fbc8fcbee00151d.tar.bz2 |
* improved 'signup' function for sfaccount
* changed 'redirect url' for 'sfaccount.views.signup_view'
* improved 'sfaccount.models.Account', added 'delete_account()' method;
added 'html' type email templates for activation email
Diffstat (limited to '97suifangqa/apps/sfaccount/models.py')
-rw-r--r-- | 97suifangqa/apps/sfaccount/models.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/97suifangqa/apps/sfaccount/models.py b/97suifangqa/apps/sfaccount/models.py index bb1fe29..72904c4 100644 --- a/97suifangqa/apps/sfaccount/models.py +++ b/97suifangqa/apps/sfaccount/models.py @@ -124,7 +124,7 @@ class Account(models.Model): # {{{ return u'< Account: %s, %s, %s >' % (self.user.username, type, state) - def activation_key_expired(self): + def activation_key_expired(self): # {{{ """ determine whether the activation key has expired @@ -148,8 +148,9 @@ class Account(models.Model): # {{{ now_utc = datetime.datetime.utcnow().replace(tzinfo=utc) return self.user.is_active or ( self.user.date_joined + expiration_days <= now_utc) + # }}} - def send_activation_email(self): + def send_activation_email(self): # {{{ """ send an activation email to the newly registered user """ @@ -160,10 +161,17 @@ class Account(models.Model): # {{{ } subject = render_to_string('sfaccount/activation_email_subject.txt', ctx_dict) subject = ''.join(subject.splitlines()) - body_text = render_to_string('sfaccount/activation_email_body.txt', ctx_dict).encode('utf-8') + body_text = render_to_string('sfaccount/activation_email_body.txt', ctx_dict) + body_html = render_to_string('sfaccount/activation_email_body.html', ctx_dict) to = self.user.email # send email - send_mail.delay(to, subject, body_text, None) + send_mail.delay(to, subject, body_text, body_html) + # }}} + + def delete_account(self): + user = self.user + user.delete() + self.delete() # }}} |