Added User welcome message.
Added templates/soc/mail/welcome.html as a template for the message.
Also fixed a cyclic import that was about to happen in notifications.py.
--- a/app/soc/logic/helper/notifications.py Mon Dec 01 12:37:16 2008 +0000
+++ b/app/soc/logic/helper/notifications.py Mon Dec 01 21:03:20 2008 +0000
@@ -23,25 +23,30 @@
import os
+import soc.logic.models as model_logic
from google.appengine.api import users
from django.utils.translation import ugettext_lazy
from soc.logic import mail_dispatcher
-from soc.logic.models import user as user_logic
from soc.views.helper import redirects
DEF_INVITATION_FMT = ugettext_lazy(
"Invitation to become a %(role)s for %(group)s")
+DEF_WELCOME_FMT = ugettext_lazy("Welcome to Melange %(name)s")
+
def sendInviteNotification(entity):
"""Sends out an invite notification to the user the request is for.
Args:
entity : A request containing the information needed to create the message
"""
+
+ # get user logic
+ user_logic = model_logic.user
# get the current user
properties = {'account': users.get_current_user()}
@@ -76,3 +81,36 @@
# send out the message using the default invitation template
mail_dispatcher.sendMailFromTemplate('soc/mail/invitation.html',
messageProperties)
+
+def sendWelcomeMessage(user_entity):
+ """Sends out a welcome message to a user.
+
+ Args:
+ user_entity: User entity which the message should be send to
+ """
+
+ # get user logic
+ user_logic = model_logic.user
+
+ # get the current user
+ properties = {'account': users.get_current_user()}
+ current_user_entity = user_logic.logic.getForFields(properties, unique=True)
+
+ # create the message contents
+ # TODO(Lennard) change the message sender to some sort of no-reply adress that is
+ # probably a setting in sitesettings. (adress must be a developer). This is due
+ # to a GAE limitation that allows only devs or the current user to send an email.
+ # Currently this results in a user receiving the same email twice.
+ messageProperties = {
+ 'to_name': user_entity.name,
+ 'sender_name': current_user_entity.name,
+ 'to': user_entity.account.email(),
+ 'sender': current_user_entity.account.email(),
+ 'subject': DEF_WELCOME_FMT % {
+ 'name': user_entity.name
+ }
+ }
+
+ # send out the message using the default welcome template
+ mail_dispatcher.sendMailFromTemplate('soc/mail/welcome.html',
+ messageProperties)
--- a/app/soc/logic/models/user.py Mon Dec 01 12:37:16 2008 +0000
+++ b/app/soc/logic/models/user.py Mon Dec 01 21:03:20 2008 +0000
@@ -22,6 +22,7 @@
]
+from soc.logic.helper import notifications
from soc.logic.models import base
import soc.models.user
@@ -85,6 +86,11 @@
model.former_accounts.append(model.account)
return True
+
+ def _onCreate(self, entity):
+ """Send out a message to welcome the new user.
+ """
+ notifications.sendWelcomeMessage(entity)
logic = Logic()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/mail/welcome.html Mon Dec 01 21:03:20 2008 +0000
@@ -0,0 +1,22 @@
+{% extends "soc/mail/base.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+{% block content %}
+Welcome to Melange. If you are reading this it means you have successfully registered as user
+on our website. Currently Melange is still being developed, if you run into any trouble you can usually
+find us on #melange on Freenode. If you find any bugs you
+can report them <a href="http://code.google.com/p/soc/issues/list">here</a>.
+{% endblock %}
+{% block signature %}Greetings, <br />The Melange Team{% endblock %}