##// END OF EJS Templates
notifications: use an explicit FK mark when creating notifications, previous way was prone to cache problems.
marcink -
r2897:1a98e88c default
parent child Browse files
Show More
@@ -155,6 +155,7 b' class TestNotificationsController(TestCo'
155 155 notification = NotificationModel().create(
156 156 created_by=cur_user, notification_subject=subject,
157 157 notification_body=notif_body, recipients=[cur_user, u1, u2])
158 Session().commit()
158 159
159 160 response = self.app.get(
160 161 route_path('notifications_show',
@@ -3909,16 +3909,18 b' class Notification(Base, BaseModel):'
3909 3909 notification.type_ = type_
3910 3910 notification.created_on = datetime.datetime.now()
3911 3911
3912 # For each recipient link the created notification to his account
3912 3913 for u in recipients:
3913 3914 assoc = UserNotification()
3915 assoc.user_id = u.user_id
3914 3916 assoc.notification = notification
3915 3917
3916 3918 # if created_by is inside recipients mark his notification
3917 3919 # as read
3918 3920 if u.user_id == created_by.user_id:
3919 3921 assoc.read = True
3920
3921 u.notifications.append(assoc)
3922 Session().add(assoc)
3923
3922 3924 Session().add(notification)
3923 3925
3924 3926 return notification
General Comments 0
You need to be logged in to leave comments. Login now