# HG changeset patch # User Sverre Rabbelier # Date 1232407569 0 # Node ID 5afe16b2e86b7e09fde1c120d384c1088cee7c2c # Parent 56eec9c8bb47f7d603c9fc38a8f2ccb4b48b3d40 Send a notifcation if a club application is accepted Patch by: Sverre Rabbelier diff -r 56eec9c8bb47 -r 5afe16b2e86b app/soc/logic/helper/notifications.py --- a/app/soc/logic/helper/notifications.py Mon Jan 19 23:25:49 2009 +0000 +++ b/app/soc/logic/helper/notifications.py Mon Jan 19 23:26:09 2009 +0000 @@ -47,10 +47,14 @@ DEF_INVITATION_MSG_FMT = ugettext_lazy( "Invitation to become a %(role)s for %(group)s.") +DEF_NEW_CLUB_MSG_FMT = ugettext_lazy( + "Your club application for %(name)s has been accepted.") + DEF_WELCOME_MSG_FMT = ugettext_lazy("Welcome to Melange %(name)s,") DEF_GROUP_INVITE_NOTIFICATION_TEMPLATE = 'soc/notification/messages/invitation.html' +DEF_NEW_CLUB_TEMPLATE = 'soc/club/messages/accepted.html' def sendInviteNotification(entity): @@ -85,6 +89,34 @@ sendNotification(to_user, message_properties, subject, template) +def sendNewClubNotification(entity): + """Sends out an invite notification to the applicant of the club + + Args: + entity : An accepted club application + """ + + to_user = entity.applicant + + url = "http://%(host)s/club/create/%(key_name)s" % { + 'host' : os.environ['HTTP_HOST'], + 'key_name': entity.key().name(), + } + + message_properties = { + 'club_name': entity.name, + 'url': url, + } + + subject = DEF_NEW_CLUB_MSG_FMT % { + 'name': entity.name, + } + + template = DEF_NEW_CLUB_TEMPLATE + + sendNotification(to_user, message_properties, subject, template) + + def sendNotification(to_user, message_properties, subject, template): """Sends out an notification to the specified user. diff -r 56eec9c8bb47 -r 5afe16b2e86b app/soc/templates/soc/club/messages/accepted.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/templates/soc/club/messages/accepted.html Mon Jan 19 23:26:09 2009 +0000 @@ -0,0 +1,19 @@ +{% extends "soc/notification/messages/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 %} + +{% block content %} +Your club application for "{{ club_name }}" has been accepted. +Please click here to fill in the necessary information and create your club. +{% endblock %} diff -r 56eec9c8bb47 -r 5afe16b2e86b app/soc/views/models/club_app.py --- a/app/soc/views/models/club_app.py Mon Jan 19 23:25:49 2009 +0000 +++ b/app/soc/views/models/club_app.py Mon Jan 19 23:26:09 2009 +0000 @@ -29,6 +29,7 @@ from soc.logic import accounts from soc.logic import cleaning from soc.logic import dicts +from soc.logic.helper import notifications from soc.logic.models import user as user_logic from soc.models import group_app as group_app_model from soc.views import helper @@ -200,6 +201,7 @@ # the application has been accepted fields['accepted'] = True fields['reviewed'] = True + notifications.sendNewClubNotification(entity) elif accepted_value == 'false': # the application has been denied fields['accepted'] = False