예제 #1
0
 def load_new_notifications(self, data, req_info, session, curs=None):
     f = NotificatonFilter(session.environment_id, {}, {}, None)
     objs = f.filter_objs(curs, for_update=True)
     e_names_cur = [o.event for o in objs]
     e_names_to_load = [e_name for e_name in message.EVENTS if e_name not in e_names_cur]
     env_f = EnvironmentFilter({'id': session.environment_id}, {}, None)
     env = env_f.filter_one_obj(curs)
     self._create_default_notifications(curs, env, e_names_to_load)
     return response_ok(loaded=len(e_names_to_load))
예제 #2
0
 def reset_notifications(self, data, req_info, session, curs=None):
     n_ids = data['ids']
     f = NotificatonFilter(session.environment_id, {'ids': n_ids},
         {}, None)
     objs = f.filter_objs(curs, for_update=True)
     n = Notifier()
     for o in objs:
         if o.type == Notification.TYPE_EMAIL:
             msg_struct = n.default_email_notif_struct(o.event)
             o.serialized_messages = json.dumps(msg_struct)
             mapping.save(curs, o)
     return response_ok()