from django.utils.translation import ugettext as _
from django.db.models import F
from forum.models.action import ActionProxy
-from forum.models import Award, Badge
+from forum.models import Award, Badge, ValidationHash
from forum import settings
from forum.settings import APP_SHORT_NAME
+from forum.utils.mail import send_email, send_template_email
class UserJoinsAction(ActionProxy):
def repute_users(self):
self.repute(self.user, int(settings.INITIAL_REP))
+ def process_action(self):
+ hash = ValidationHash.objects.create_new(self.user, 'email', [self.user.email])
+ send_template_email([self.user], "auth/email_validation.html", {'validation_code': hash})
+
def describe(self, viewer=None):
return _("%(user)s as joined the %(app_name)s Q&A community") % {
'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
-{% extends "email_base.html" %}
-{% load i18n %}
-{% load extra_tags %}
-{% load email_tags %}
+{% load i18n extra_tags email_tags %}
-{% block content %}
- <p>{% trans "Greetings from the Q&A forum" %},</p>
+{% declare %}
+ prefix = settings.EMAIL_SUBJECT_PREFIX
+ app_name = settings.APP_SHORT_NAME
- <p>{% trans "To make use of the Forum, please follow the link below:" %}</p>
+ exclude_greeting = True
+ exclude_finetune = True
+{% enddeclare %}
- <a href="{% fullurl auth_validate_email user=user.id,code=validation_code %}">{% fullurl auth_validate_email user=user.id,code=validation_code %}</a>
+{% email %}
+ {% subject %}{% blocktrans %}{{ prefix }} Welcome to {{ app_name }}{% endblocktrans %}{% endsubject %}
- <p>{% trans "Following the link above will help us verify your email address." %}</p>
+ {% htmlcontent notifications/base.html %}
+ <p style="{{ p_style }}}">
+ {% blocktrans %}Howdy and welcome to {{ app_name }}. We know you're busy, so we'll keep this real simple.{% endblocktrans %} %},
+ </p>
- <p>{% blocktrans %}If you beleive that this message was sent in mistake -
- no further action is needed. Just ingore this email, we apologize
- for any inconvenience{% endblocktrans %}</p>
+ <p style="{{ p_style }}}">{% trans "Here's your login info (store it in a cool dry place):" %}</p>
+
+ <p style="{{ p_style }}}">{% trans "Username: " %} {{ recipient.username }}<br />
+ <b>{% trans "Password: As IF we would send your password in cleartext!" %}</b></p>
+
+ <p style="{{ p_style }}}">{% trans "The following link will help us verify your email address:" %}</p>
+
+ <a style="{{ a_style }}}" href="{% fullurl auth_validate_email user=recipient.id,code=validation_code %}">{% trans "Validate my email address" %}</a>
+
+ <p style="{{ p_style }}}">{% trans "If the above link is not clickable, copy and paste this url into your web browser's address bar:" %}</p>
+
+ <p style="{{ p_style }}">{% fullurl auth_validate_email user=recipient.id,code=validation_code %}</p>
+ {% endhtmlcontent %}
+
+{% textcontent notifications/base_text.html %}
+{% blocktrans %}Howdy and welcome to {{ app_name }}. We know you're busy, so we'll keep this real simple.{% endblocktrans %} %},
+{% trans "Here's your login info (store it in a cool dry place):" %}
+
+{% trans "Username: " %} {{ recipient.username }}
+{% trans "Password: As IF we would send your password in cleartext!" %}
+
+{% trans "Copy and paste this url into your web browser's address bar to help us verify your email address:" %}
+
+{% fullurl auth_validate_email user=recipient.id,code=validation_code %}
+{% endtextcontent %}
+
+{% endemail %}
- <p>{% blocktrans %}Sincerely,<br />
- Forum Administrator{% endblocktrans %}</p>
-{% endblock %}
<tbody><tr><td style="padding:20px;">
<img src="{{ settings.APP_URL }}{{ settings.APP_LOGO }}" alt="{{settings.APP_TITLE}}" />
<hr style="{{ hr_style }}" />
+{% if not exclude_greeting %}
<p style="{{ p_style }}">{% trans "Hello" %} {{ recipient.username }},</p>
-{% block content %}
-{% endblock%}
+{% endif %}
+{% block content %}{% endblock%}
<p style="{{ p_style }}">Thanks,<br />{{settings.APP_SHORT_NAME}}</p>
+{% if not exclude_finetune %}
<p style="{{ p_style }}">P.S. You can always fine-tune which notifications you receive
<a href="{{ settings.APP_URL }}{% url user_subscriptions id=recipient.id %}" style="{{ a_style }}">here</a>.
+{% endif %}
</p>
<hr style="{{ hr_style }}" />
<p style="{{ p_style }}"><small style="{{ small_style }}">{{ settings.EMAIL_FOOTER_TEXT }}</small></p>
{% declare %}
postal_address = "DZone, Inc. 140 Preston Executive Drive, Cary NC 27513, USA"
{% enddeclare %}
-
+{% if not exclude_greeting %}
{% trans "Hello" %} {{ recipient.username }},
+{% endif %}
-{% block content %}
-{% endblock%}
+{% block content %}{% endblock%}
{% trans "Thanks" %},
{{settings.APP_SHORT_NAME}}
+{% if not exclude_finetune %}
{% trans "P.S. You can always fine-tune which notifications you receive here:" %}
{{ settings.APP_URL }}{% url user_subscriptions id=recipient.id %}
+{% endif %}
{{ postal_address }}
\ No newline at end of file
{% htmlcontent notifications/base.html %}
<p style="{{ p_style }}">
{% blocktrans %}
- {{ newmember_link }} has just joined {{ app_name }}. You can visit {{ newmember_name }}'s profile using the following link: <br />
- <a href="{{ app_url }}{{ newmember_url }}">{{ newmember_name }} profile</a>
+ {{ newmember_link }} has just joined {{ app_name }}.
+ View <a style="{{ a_style }}" href="{{ app_url }}{{ newmember_url }}">{{ newmember_name }}'s profile</a>.
{% endblocktrans %}
</p>
{% endhtmlcontent %}
from forum.authentication.forms import SimpleRegistrationForm, SimpleEmailSubscribeForm, \
TemporaryLoginRequestForm, ChangePasswordForm, SetPasswordForm
-from forum.utils.mail import send_email
+from forum.utils.mail import send_email, send_template_email
from forum.authentication.base import InvalidAuthentication
from forum.authentication import AUTH_PROVIDERS
user_.save()
UserJoinsAction(user=user_, ip=request.META['REMOTE_ADDR']).save()
- if not user_.email_isvalid:
- send_validation_email(user_)
-
try:
assoc_key = request.session['assoc_key']
auth_provider = request.session['auth_provider']
del request.session['assoc_key']
del request.session['auth_provider']
- return login_and_forward(request, user_)
+ return login_and_forward(request, user_, _("A welcome email has been sent to your email address. "))
else:
provider_class = AUTH_PROVIDERS[request.session['auth_provider']].consumer
user_data = provider_class.get_user_data(request.session['assoc_key'])
_("You are logged in with a temporary access key, please take the time to fix your issue with authentication."))
else:
raise Http404()
-
-def send_validation_email(user):
- hash = ValidationHash.objects.create_new(user, 'email', [user.email])
- send_email(_("Email Validation"), [(user.username, user.email)], "auth/email_validation.html", {
- 'validation_code': hash,
- 'user': user
- })
-
+
def validate_email(request, user, code):
user = get_object_or_404(User, id=user)
from forms import ClassicRegisterForm
from forum.authentication.forms import SimpleEmailSubscribeForm
-from forum.views.auth import login_and_forward, send_validation_email
+from forum.views.auth import login_and_forward
from forum.actions import UserJoinsAction
def register(request):
user_.save()
UserJoinsAction(user=user_, ip=request.META['REMOTE_ADDR']).save()
-
- send_validation_email(user_)
+
if email_feeds_form.cleaned_data['subscribe'] == 'n':
user_.subscription_settings.enable_notifications = False
user_.subscription_settings.save()
- return login_and_forward(request, user_, None, _("A validation email has been sent to your email address. "))
+ return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
else:
form = ClassicRegisterForm(initial={'next':'/'})
email_feeds_form = SimpleEmailSubscribeForm()