aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/apps/sfaccount
diff options
context:
space:
mode:
Diffstat (limited to '97suifangqa/apps/sfaccount')
-rw-r--r--97suifangqa/apps/sfaccount/README.txt16
-rw-r--r--97suifangqa/apps/sfaccount/models.py16
-rw-r--r--97suifangqa/apps/sfaccount/tasks.py7
-rw-r--r--97suifangqa/apps/sfaccount/templates/sfaccount/activation_email_body.html13
-rw-r--r--97suifangqa/apps/sfaccount/templates/sfaccount/activation_email_body.txt4
-rw-r--r--97suifangqa/apps/sfaccount/views.py2
6 files changed, 42 insertions, 16 deletions
diff --git a/97suifangqa/apps/sfaccount/README.txt b/97suifangqa/apps/sfaccount/README.txt
index 44eda9e..c55a405 100644
--- a/97suifangqa/apps/sfaccount/README.txt
+++ b/97suifangqa/apps/sfaccount/README.txt
@@ -5,19 +5,21 @@ newly registered user.
REF:
(1) use Celery in Django with a Redis backend
http://killtheyak.com/django-celery-redis/
+(2) django-siteuser
HOWTO run:
-1) pip install django-celery redis
-2) OS install package 'redis' (maybe 'redis-server')
+1) # pip install django-celery redis
+2) for system, install package 'redis' (maybe 'redis-server')
3) add 'djcelery' to 'INSTALLED_APPS'
4) add settings for 'redis' & 'djcelery' in 'settings.py'
- SF_MAIL
-5) system: $ redis-server
-6) ./manage.py syncdb
-7) ./manage.py celeryd worker -E
+5) ajust 'SF_MAIL' settings in 'mail_settings.py'
+6) $ redis-server
+7) $ ./manage.py syncdb
+8) $ ./manage.py celeryd worker -E
+9) $ ./manage.py celerycam (for monitoring)
TEST:
a) ./manage.py shell
>>> from sfaccount.tasks import send_mail
- >>> send_mail(to, subject, body)
+ >>> send_mail(to, subject, body_text, body_html)
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()
# }}}
diff --git a/97suifangqa/apps/sfaccount/tasks.py b/97suifangqa/apps/sfaccount/tasks.py
index 94b520a..1613646 100644
--- a/97suifangqa/apps/sfaccount/tasks.py
+++ b/97suifangqa/apps/sfaccount/tasks.py
@@ -5,6 +5,9 @@ from celery import task
from sfaccount.functional import send_mail as _send_mail
@task
-def send_mail(to, subject, content_text, content_html):
- _send_mail(to, subject, content_text, content_html)
+def send_mail(to, subject, content_text=None, content_html=None):
+ _send_mail(to=to,
+ subject=subject,
+ content_text=content_text,
+ content_html=content_html)
diff --git a/97suifangqa/apps/sfaccount/templates/sfaccount/activation_email_body.html b/97suifangqa/apps/sfaccount/templates/sfaccount/activation_email_body.html
new file mode 100644
index 0000000..9792ad5
--- /dev/null
+++ b/97suifangqa/apps/sfaccount/templates/sfaccount/activation_email_body.html
@@ -0,0 +1,13 @@
+{% autoescape off %}
+<p>尊敬的 {{ username }},<p>
+
+<p>欢迎您加入97随访(97suifang.com)。<p>
+
+<p>
+您的激活码为 {{ activation_key }},请在 {{ expiration_days }} 天内激活账户,直接打开以下链接进行激活:<br />
+http://www.97suifang.com/accounts/activate/{{ activation_key }}/
+</p>
+<br />
+
+<p>97随访 团队</p>
+{% endautoescape %}
diff --git a/97suifangqa/apps/sfaccount/templates/sfaccount/activation_email_body.txt b/97suifangqa/apps/sfaccount/templates/sfaccount/activation_email_body.txt
index 32be3e9..b479ff0 100644
--- a/97suifangqa/apps/sfaccount/templates/sfaccount/activation_email_body.txt
+++ b/97suifangqa/apps/sfaccount/templates/sfaccount/activation_email_body.txt
@@ -1,9 +1,9 @@
尊敬的 {{ username }},
-感谢您注册97随访(97suifang.com)。
+欢迎您加入97随访(97suifang.com)。
您的激活码为 {{ activation_key }},请在 {{ expiration_days }} 天内激活账户,直接打开以下链接进行激活:
http://www.97suifang.com/accounts/activate/{{ activation_key }}/
-97随访
+97随访 团队
diff --git a/97suifangqa/apps/sfaccount/views.py b/97suifangqa/apps/sfaccount/views.py
index 94670a6..9cc2868 100644
--- a/97suifangqa/apps/sfaccount/views.py
+++ b/97suifangqa/apps/sfaccount/views.py
@@ -50,7 +50,7 @@ def signup_view(request):
password=cd['password1'],
send_email=True
)
- return HttpResponseRedirect(request.REQUEST.get('next'))
+ return HttpResponseRedirect(reverse('activate'))
else:
form = AccountForm()