def create_comment_notifications(self): """Create comment notifications.""" import datetime if self.comments: for comment in self.comments: notification = all_models.Notification( object=comment, send_on=datetime.datetime.utcnow(), notification_type_id=self._get_comment_created_notif_type( ), ) db.session.add(notification)
def add_notification(obj, notif_type_name): """Add notification for object uses notif_type_cache as cache""" from ggrc.models import all_models notif_type_id = all_models.NotificationType.query.filter_by( name=notif_type_name).one().id # I don't like to have flush here, but we need a ID for newly created objects if not obj.id: db.session.flush() db.session.add( all_models.Notification(object=obj, send_on=datetime.datetime.utcnow(), notification_type_id=notif_type_id, runner=all_models.Notification.RUNNER_FAST, modified_by_id=get_current_user_id()))