From 46b4f8407f40cfcc0abf6c6e4fbc8fcbee00151d Mon Sep 17 00:00:00 2001 From: Alvin Li Date: Sat, 5 Oct 2013 02:12:28 +0800 Subject: * 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 --- 97suifangqa/apps/sfaccount/models.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to '97suifangqa/apps/sfaccount/models.py') 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() # }}} -- cgit v1.2.2