comparison rhodecode/model/notification.py @ 1722:e7eef7a1db6a beta

#235 forking page repo group selection - group is selected as parent repo - refactoring of session behavior to get more atomic operations in models
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 26 Nov 2011 00:11:32 +0200
parents 7ff304d3028f
children 64e91067b996
comparison
equal deleted inserted replaced
1721:05dbebede0d8 1722:e7eef7a1db6a
33 from pylons.i18n.translation import _ 33 from pylons.i18n.translation import _
34 34
35 from rhodecode.lib import helpers as h 35 from rhodecode.lib import helpers as h
36 from rhodecode.model import BaseModel 36 from rhodecode.model import BaseModel
37 from rhodecode.model.db import Notification, User, UserNotification 37 from rhodecode.model.db import Notification, User, UserNotification
38 from rhodecode.lib.celerylib import run_task
39 from rhodecode.lib.celerylib.tasks import send_email
40 38
41 log = logging.getLogger(__name__) 39 log = logging.getLogger(__name__)
42 40
43 41
44 class NotificationModel(BaseModel): 42 class NotificationModel(BaseModel):
72 :param subject: 70 :param subject:
73 :param body: 71 :param body:
74 :param recipients: list of int, str or User objects 72 :param recipients: list of int, str or User objects
75 :param type_: type of notification 73 :param type_: type of notification
76 """ 74 """
75 from rhodecode.lib.celerylib import tasks, run_task
77 76
78 if not getattr(recipients, '__iter__', False): 77 if not getattr(recipients, '__iter__', False):
79 raise Exception('recipients must be a list of iterable') 78 raise Exception('recipients must be a list of iterable')
80 79
81 created_by_obj = self.__get_user(created_by) 80 created_by_obj = self.__get_user(created_by)
98 type_ = EmailNotificationModel.TYPE_CHANGESET_COMMENT 97 type_ = EmailNotificationModel.TYPE_CHANGESET_COMMENT
99 email_body = body 98 email_body = body
100 email_body_html = EmailNotificationModel()\ 99 email_body_html = EmailNotificationModel()\
101 .get_email_tmpl(type_, **{'subject':subject, 100 .get_email_tmpl(type_, **{'subject':subject,
102 'body':h.rst(body)}) 101 'body':h.rst(body)})
103 run_task(send_email, rec.email, email_subject, email_body, 102 run_task(tasks.send_email, rec.email, email_subject, email_body,
104 email_body_html) 103 email_body_html)
105 104
106 return notif 105 return notif
107 106
108 def delete(self, user, notification): 107 def delete(self, user, notification):