diff --git a/seahub/templates/registration/activation_email.html b/seahub/templates/registration/activation_email.html new file mode 100644 index 0000000000..6dfdd7743a --- /dev/null +++ b/seahub/templates/registration/activation_email.html @@ -0,0 +1,21 @@ +{% extends 'email_base.html' %} + +{% load i18n %} + +{% block email_con %} + +{% autoescape off %} + +

{% trans "Hi," %}

+ +

+{% blocktrans %}You (or someone pretending to be you) have asked to register an account at {{ site_name }}. If this wasn't you, please ignore this email and your address will be removed from our records.{% endblocktrans %} +
+{% blocktrans %}To activate this account, please click the following link within the next {{ expiration_days }} days: {% endblocktrans %} +
+{{ url_base }}{% url 'registration_activate' activation_key %} +

+ +{% endautoescape %} + +{% endblock %} diff --git a/seahub/templates/registration/activation_email.txt b/seahub/templates/registration/activation_email.txt index b85e5eead2..1f0afcea00 100644 --- a/seahub/templates/registration/activation_email.txt +++ b/seahub/templates/registration/activation_email.txt @@ -1,4 +1,18 @@ -您好, 感谢注册 {{ site.name }}。 +{% load i18n %} +{% blocktrans with site_name=site.name %} +You (or someone pretending to be you) have asked to register an account at +{{ site_name }}. If this wasn't you, please ignore this email +and your address will be removed from our records. +{% endblocktrans %} +{% blocktrans %} +To activate this account, please click the following link within the next +{{ expiration_days }} days: +{% endblocktrans %} -请点击下面的链接激活您的帐号 -http://{{ site.name }}{{ SITE_ROOT }}accounts/activate/{{ activation_key }}/ +http{% if request.is_secure %}s{% endif %}://{{ request.get_host }}{% url 'registration_activate' activation_key %} +http://{{site.domain}}{% url 'registration_activate' activation_key %} + +{% blocktrans with site_name=site.name %} +Sincerely, +{{ site_name }} Management +{% endblocktrans %} diff --git a/seahub/templates/registration/activation_email_subject.txt b/seahub/templates/registration/activation_email_subject.txt index 52868e78b4..24f477cbb8 100644 --- a/seahub/templates/registration/activation_email_subject.txt +++ b/seahub/templates/registration/activation_email_subject.txt @@ -1 +1 @@ -请激活您的帐号,完成注册。 +{% load i18n %}{% trans "Account activation on" %} {{ site.name }} diff --git a/thirdpart/registration/models.py b/thirdpart/registration/models.py index 144c538f11..6ed61aaf12 100644 --- a/thirdpart/registration/models.py +++ b/thirdpart/registration/models.py @@ -11,7 +11,7 @@ from django.template.loader import render_to_string from django.utils.translation import ugettext_lazy as _ from seahub.base.accounts import User - +from seahub.utils import send_html_email SHA1_RE = re.compile('^[a-f0-9]{40}$') @@ -279,13 +279,10 @@ class RegistrationProfile(models.Model): ctx_dict) # Email subject *must not* contain newlines subject = ''.join(subject.splitlines()) - - message = render_to_string('registration/activation_email.txt', - ctx_dict) - try: user = User.objects.get(id=self.emailuser_id) - user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL) + send_html_email(subject, 'registration/activation_email.html', + ctx_dict, None, [user.username]) except User.DoesNotExist: pass