]> git.openstreetmap.org Git - osqa.git/commitdiff
Converts the welcome message to the new mail system and makes some changes to the...
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 4 Jun 2010 01:43:02 +0000 (01:43 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 4 Jun 2010 01:43:02 +0000 (01:43 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@371 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/actions/user.py
forum/skins/default/templates/auth/email_validation.html
forum/skins/default/templates/notifications/base.html
forum/skins/default/templates/notifications/base_text.html
forum/skins/default/templates/notifications/newmember.html
forum/views/auth.py
forum_modules/localauth/views.py

index 6170a17904df06745b08582ca3df0a9f686a0c48..6c174cee2e92ed989feee691931b69115f702e28 100644 (file)
@@ -1,14 +1,19 @@
 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)),
index 8a2d34fe1ece4c784f4f9c3fa0fb83693f40c38a..8746e5635d368a947062534fe1e1b43edd565571 100644 (file)
@@ -1,21 +1,46 @@
-{% 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 %}
index 05de03faad4a980101cd7f5c9c0fde591c93bd47..9d09f597d3a9e72b4ed433358afff01261db77d2 100644 (file)
 <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>
index 8d31c302f484b9e8df41603889dfb32f2bb215c1..113e5fdf6535eba325254da26be2e49557b681cd 100644 (file)
@@ -3,16 +3,18 @@
 {% 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
index 67fba1ffacc118ae8163e633a5e97812ff1485e9..e189e3d91ca17f26038941b14b3ee2fb84aca8a6 100644 (file)
@@ -15,8 +15,8 @@
     {% 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 %}
index d321c9563ffa4513f436c4603680737ad1b31cf6..442bf01fdb2ddeac30d4cab43dddd31965be357f 100644 (file)
@@ -14,7 +14,7 @@ import datetime
 
 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
@@ -152,9 +152,6 @@ def external_register(request):
             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']
@@ -172,7 +169,7 @@ def external_register(request):
             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'])
@@ -241,14 +238,7 @@ def temp_signin(request, user, code):
                 _("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)
 
index 8df278c456703b5a8c46cfc15bb862a01c6ac5ee..6416feea555affde9901ebddad2dce921ab7ff31 100644 (file)
@@ -5,7 +5,7 @@ from django.utils.translation import ugettext as _
 
 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):
@@ -26,13 +26,12 @@ 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()