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