class SubscriberEdit(View): template_name = 'templates/admin/subscriber/edit.html' __context = Context() __subscriber = SubscriberModule() __correlation_id = None @login_if_not_authenticated def get(self, request, subscriber_id): self.__correlation_id = request.META[ "X-Correlation-ID"] if "X-Correlation-ID" in request.META else "" subscriber = self.__subscriber.get_one_by_id(subscriber_id) if not subscriber: raise Http404("Subscriber not found.") self.__context.autoload_options() self.__context.autoload_user( request.user.id if request.user.is_authenticated else None) self.__context.push({ "page_title": _("Edit Subscriber · %s") % self.__context.get( "app_name", os.getenv("APP_NAME", "Silverback")), "subscriber": subscriber }) return render(request, self.template_name, self.__context.get())
def incident_update(incident_update_id, user_id): incident_update_notification_module = IncidentUpdateNotificationModule() subscriber_module = SubscriberModule() task_module = TaskModule() for subscriber in subscriber_module.get_iterator(): notification = incident_update_notification_module.is_subscriber_notified( incident_update_id, subscriber.id) if notification: # Send notification.id to the queue again task_module.delay("notify_subscriber", {"notification_id": notification.id}, user_id) else: # Create new notification and send to queue new_notification = incident_update_notification_module.insert_one({ "status": "pending", "incident_update_id": incident_update_id, "subscriber_id": subscriber.id }) if new_notification: # Send new_notification.id to the Queue task_module.delay("notify_subscriber", {"notification_id": new_notification.id}, user_id) return {"status": "passed", "result": "{}", "notify_type": "passed"}
def __init__(self): self.__request = Request() self.__response = Response() self.__helpers = Helpers() self.__form = Form() self.__subscriber = SubscriberModule() self.__logger = self.__helpers.get_logger(__name__) self.__form.add_validator(ExtraRules())
def __init__(self): self.__request = Request() self.__response = Response() self.__helpers = Helpers() self.__form = Form() self.__incident_update = IncidentUpdateModule() self.__task = Task_Module() self.__notification = NotificationModule() self.__subscriber = SubscriberModule() self.__logger = self.__helpers.get_logger(__name__) self.__form.add_validator(ExtraRules())
def get(self, request): self.__subscriber = SubscriberModule() self.autoload_options() self.autoload_user( request.user.id if request.user.is_authenticated else None) self.context_push({ "page_title": _("Add an Subscriber · %s") % self.context_get("app_name", os.getenv("APP_NAME", "Silverback")) }) return render(request, self.template_name, self.context_get())
def get(self, request): self.__context = Context() self.__subscriber = SubscriberModule() self.__correlation_id = request.META[ "X-Correlation-ID"] if "X-Correlation-ID" in request.META else "" self.__context.autoload_options() self.__context.autoload_user( request.user.id if request.user.is_authenticated else None) self.__context.push({ "page_title": _("Add an Subscriber · %s") % self.__context.get("app_name", os.getenv("APP_NAME", "Silverback")) }) return render(request, self.template_name, self.__context.get())
def get(self, request, subscriber_id): self.__subscriber = SubscriberModule() subscriber = self.__subscriber.get_one_by_id(subscriber_id) if not subscriber: raise Http404("Subscriber not found.") self.autoload_options() self.autoload_user( request.user.id if request.user.is_authenticated else None) self.context_push({ "page_title": _("Edit Subscriber · %s") % self.context_get("app_name", os.getenv("APP_NAME", "Silverback")), "subscriber": subscriber }) return render(request, self.template_name, self.context_get())
class SubscriberList(View): template_name = 'templates/admin/subscriber/list.html' __context = Context() __subscriber = SubscriberModule() __correlation_id = None @login_if_not_authenticated def get(self, request): self.__correlation_id = request.META[ "X-Correlation-ID"] if "X-Correlation-ID" in request.META else "" self.__context.autoload_options() self.__context.autoload_user( request.user.id if request.user.is_authenticated else None) self.__context.push({ "page_title": _("Subscribers · %s") % self.__context.get("app_name", os.getenv("APP_NAME", "Silverback")) }) return render(request, self.template_name, self.__context.get())
def incident_update(incident_update_id, user_id, correlation_id=""): logger = Helpers().get_logger(__name__) logger.info( _("Worker started processing incident_update task with parameters %(parameters)s {'correlationId':'%(correlationId)s'}" ) % { "parameters": json.dumps({}), "correlationId": correlation_id }) incident_update_notification_module = IncidentUpdateNotificationModule() subscriber_module = SubscriberModule() task_module = TaskModule() for subscriber in subscriber_module.get_iterator(): notification = incident_update_notification_module.is_subscriber_notified( incident_update_id, subscriber.id) if notification: # Send notification.id to the queue again task_module.delay("notify_subscriber", {"notification_id": notification.id}, user_id) else: # Create new notification and send to queue new_notification = incident_update_notification_module.insert_one({ "status": "pending", "incident_update_id": incident_update_id, "subscriber_id": subscriber.id }) if new_notification: # Send new_notification.id to the Queue task_module.delay("notify_subscriber", {"notification_id": new_notification.id}, user_id) return {"status": "passed", "result": "{}", "notify_type": "passed"}
def verify_subscriber(subscriber_id, correlation_id=""): logger = Helpers().get_logger(__name__) logger.info( _("Worker started processing verify_subscriber task with parameters %(parameters)s {'correlationId':'%(correlationId)s'}" ) % { "parameters": json.dumps({}), "correlationId": correlation_id }) subscriber_module = SubscriberModule() subscriber = subscriber_module.get_one_by_id(subscriber_id) if not subscriber: return {"status": "passed", "result": "{}"} if subscriber.type == SubscriberModule.EMAIL: result = __verify_email() elif subscriber.type == SubscriberModule.PHONE: result = __verify_phone() elif subscriber.type == SubscriberModule.ENDPOINT: result = __verify_endpoint() return result
def __init__(self): self.__subscriber = SubscriberModule()