コード例 #1
0
ファイル: handler.py プロジェクト: sand8080/helixauth
 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
ファイル: handler.py プロジェクト: sand8080/helixauth
 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()
コード例 #3
0
ファイル: handler.py プロジェクト: sand8080/helixauth
    def get_notifications(self, data, req_info, session, curs=None):
        f = NotificatonFilter(session.environment_id,
            data['filter_params'], data['paging_params'],
            data.get('ordering_params'))
        notifs, total = f.filter_counted(curs)

        def viewer(obj):
            result = obj.to_dict()
            result.pop('environment_id')
            result = mapping.objects.deserialize_field(result,
                'serialized_messages', 'messages')
            return result
        return response_ok(notifications=self.objects_info(notifs, viewer), total=total)
コード例 #4
0
ファイル: notifier.py プロジェクト: sand8080/helixauth
 def _get_notification(self, n_p, env_id, event_name, curs):
     n_f = NotificatonFilter(env_id, {'event': event_name,
         'type': Notification.TYPE_EMAIL}, {}, None)
     try:
         notif = n_f.filter_one_obj(curs)
         if notif.is_active:
             n_p.add_step(n_p.STEP_EVENT_NOTIFICATION_ENABLED)
         else:
             n_p.add_step(n_p.STEP_EVENT_NOTIFICATION_DISABLED)
             raise NotificatoinPreparingError()
         return notif
     except NotificatonNotFound:
         n_p.add_step(n_p.STEP_UNKNOWN_EVENT)
     raise NotificatoinPreparingError()