# HG changeset patch # User Lennard de Rijk # Date 1237156325 0 # Node ID 8b71f4e58f39aa12a9c81899a4596b71fe408e1c # Parent 660bdc99239c84b15f19d531cb7a143362c98813 Changed notifications helper to properly use the fact that from_user is not a required property. The list template has changed to reflect this. The naming is open for discussion but note that if it is decided to change it that it also needs to be changed in the public.html template. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 660bdc99239c -r 8b71f4e58f39 app/soc/logic/helper/notifications.py --- a/app/soc/logic/helper/notifications.py Sun Mar 15 20:58:39 2009 +0000 +++ b/app/soc/logic/helper/notifications.py Sun Mar 15 22:32:05 2009 +0000 @@ -86,7 +86,9 @@ template = DEF_GROUP_INVITE_NOTIFICATION_TEMPLATE - sendNotification(to_user, message_properties, subject, template) + from_user = model_logic.user.logic.getForCurrentAccount() + + sendNotification(to_user, from_user, message_properties, subject, template) def sendNewGroupNotification(entity, params): @@ -118,23 +120,28 @@ template = DEF_NEW_GROUP_TEMPLATE - sendNotification(to_user, message_properties, subject, template) + sendNotification(to_user, None, message_properties, subject, template) -def sendNotification(to_user, message_properties, subject, template): - """Sends out an notification to the specified user. +def sendNotification(to_user, from_user, message_properties, subject, template): + """Sends out a notification to the specified user. Args: to_user : user to which the notification will be send - message_properties : email message properties + from_user: user from who sends the notifications (None iff sent by site) + message_properties : message properties subject : subject of notification email template : template used for generating notification """ - from_user = model_logic.user.logic.getForCurrentAccount() + if from_user: + sender_name = from_user.name + else: + site_entity = model_logic.site.logic.getSingleton() + sender_name = 'The %s Team' %(site_entity.site_name) new_message_properties = { - 'sender_name': from_user.name, + 'sender_name': sender_name, 'to_name': to_user.name, } diff -r 660bdc99239c -r 8b71f4e58f39 app/soc/templates/soc/notification/list/row.html --- a/app/soc/templates/soc/notification/list/row.html Sun Mar 15 20:58:39 2009 +0000 +++ b/app/soc/templates/soc/notification/list/row.html Sun Mar 15 22:32:05 2009 +0000 @@ -1,7 +1,13 @@
{{ list.item.from_user.name }} + href="{{ list.redirect }}"> + {% if list.item.from_user %} + {{ list.item.from_user.name }} + {% else %} + Anonymous + {% endif %} +
{{ list.item.subject }}