예제 #1
0
class IncidentEdit(View):

    template_name = 'templates/admin/incident/edit.html'
    __context = Context()
    __incident = IncidentModule()
    __incident_update = IncidentUpdateModule()
    __component = ComponentModule()
    __component_group = ComponentGroupModule()
    __correlation_id = None

    @login_if_not_authenticated
    def get(self, request, incident_id):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        incident = self.__incident.get_one_by_id(incident_id)

        if not incident:
            raise Http404("Incident 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 Incident · %s") % self.__context.get(
                "app_name", os.getenv("APP_NAME", "Silverback")),
            "incident":
            incident
        })

        return render(request, self.template_name, self.__context.get())
예제 #2
0
class IncidentAdd(View):

    template_name = 'templates/admin/incident/add.html'
    __context = Context()
    __incident = IncidentModule()
    __incident_update = IncidentUpdateModule()
    __component = ComponentModule()
    __component_group = ComponentGroupModule()
    __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":
            _("Add an Incident · %s") %
            self.__context.get("app_name", os.getenv("APP_NAME", "Silverback"))
        })

        return render(request, self.template_name, self.__context.get())
예제 #3
0
 def __init__(self):
     self.__request = Request()
     self.__response = Response()
     self.__helpers = Helpers()
     self.__form = Form()
     self.__incident = IncidentModule()
     self.__logger = self.__helpers.get_logger(__name__)
     self.__form.add_validator(ExtraRules())
예제 #4
0
    def get(self, request, incident_id, update_id):

        self.__context = Context()
        self.__incident = IncidentModule()
        self.__incident_update = IncidentUpdateModule()
        self.__incident_update_component = IncidentUpdateComponentModule()
        self.__component = ComponentModule()
        self.__component_group = ComponentGroupModule()
        self.__incident_update_notification = IncidentUpdateNotificationModule(
        )
        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        incident = self.__incident.get_one_by_id(incident_id)

        if not incident:
            raise Http404("Incident not found.")

        update = self.__incident_update.get_one_by_id(update_id)

        if not update:
            raise Http404("Incident update not found.")

        update["datetime"] = update["datetime"].strftime("%b %d %Y %H:%M:%S")
        update["message"] = markdown2.markdown(update["message"])
        update[
            "notified_subscribers"] = self.__incident_update_notification.count_by_update_status(
                update["id"], IncidentUpdateNotificationModule.SUCCESS)
        update[
            "failed_subscribers"] = self.__incident_update_notification.count_by_update_status(
                update["id"], IncidentUpdateNotificationModule.FAILED)

        components = self.__format_components(self.__component.get_all())
        affected_components = self.__format_affected_components(
            self.__incident_update_component.get_all(update_id))

        self.__context.autoload_options()
        self.__context.autoload_user(
            request.user.id if request.user.is_authenticated else None)
        self.__context.push({
            "page_title":
            _("View Incident Update  · %s") % self.__context.get(
                "app_name", os.getenv("APP_NAME", "Silverback")),
            "update":
            update,
            "incident":
            incident,
            "components":
            components,
            "affected_components":
            affected_components
        })

        return render(request, self.template_name, self.__context.get())
예제 #5
0
 def __init__(self):
     self.__request = Request()
     self.__response = Response()
     self.__helpers = Helpers()
     self.__form = Form()
     self.__incident = IncidentModule()
     self.__incident_update = IncidentUpdateModule()
     self.__task = Task_Module()
     self.__notification = NotificationModule()
     self.__subscriber = SubscriberModule()
     self.__incident_update_notification = IncidentUpdateNotificationModule()
     self.__logger = self.__helpers.get_logger(__name__)
     self.__form.add_validator(ExtraRules())
예제 #6
0
    def get(self, request):

        self.__incident = IncidentModule()
        self.__incident_update = IncidentUpdateModule()
        self.__component = ComponentModule()
        self.__component_group = ComponentGroupModule()
        self.autoload_options()
        self.autoload_user(
            request.user.id if request.user.is_authenticated else None)
        self.context_push({
            "page_title":
            _("Add an Incident · %s") %
            self.context_get("app_name", os.getenv("APP_NAME", "Silverback"))
        })

        return render(request, self.template_name, self.context_get())
예제 #7
0
    def get(self, request):

        self.__context = Context()
        self.__incident = IncidentModule()
        self.__incident_update = IncidentUpdateModule()
        self.__component = ComponentModule()
        self.__component_group = ComponentGroupModule()
        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":
            _("Incidents · %s") %
            self.__context.get("app_name", os.getenv("APP_NAME", "Silverback"))
        })

        return render(request, self.template_name, self.__context.get())
예제 #8
0
    def get(self, request, incident_id):

        self.__incident = IncidentModule()
        self.__incident_update = IncidentUpdateModule()
        self.__component = ComponentModule()
        self.__component_group = ComponentGroupModule()
        incident = self.__incident.get_one_by_id(incident_id)

        if not incident:
            raise Http404("Incident not found.")

        self.autoload_options()
        self.autoload_user(
            request.user.id if request.user.is_authenticated else None)
        self.context_push({
            "page_title":
            _("Edit Incident · %s") %
            self.context_get("app_name", os.getenv("APP_NAME", "Silverback")),
            "incident":
            incident
        })

        return render(request, self.template_name, self.context_get())
예제 #9
0
 def __init__(self):
     self.__incident = IncidentModule()