Commit 96052492 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Merge branch 'noc-1821' into 'master'

noc/noc#1821 Fix paging on Events UI.

See merge request !6247
parents 0fac6599 91617cd7
Pipeline #36055 passed with stages
in 50 minutes and 51 seconds
......@@ -12,7 +12,7 @@ import re
import orjson
# NOC modules
from import ExtApplication, view
from import ExtDocApplication, view
from import ActiveEvent
from import ArchivedEvent
from import FailedEvent
......@@ -28,13 +28,14 @@ from noc.core.comp import smart_text
from noc.core.translation import ugettext as _
class EventApplication(ExtApplication):
class EventApplication(ExtDocApplication):
fm.event application
title = _("Events")
menu = _("Events")
model = ActiveEvent
icon = "icon_find"
model_map = {"A": ActiveEvent, "F": FailedEvent, "S": ArchivedEvent}
......@@ -46,7 +47,7 @@ class EventApplication(ExtApplication):
ignored_params = ["status", "_dc"]
def __init__(self, *args, **kwargs):
ExtApplication.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
from .plugins.base import EventPlugin
# Load plugins
......@@ -67,30 +68,15 @@ class EventApplication(ExtApplication):
self.plugins[] = o(self)
def cleaned_query(self, q):
q = q.copy()
for p in self.ignored_params:
if p in q:
del q[p]
for p in (
if p in q:
del q[p]
# Normalize parameters
for p in q:
qp = p.split("__")[0]
if qp in self.clean_fields:
q[p] = self.clean_fields[qp].clean(q[p])
q = super().cleaned_query(q)
if "administrative_domain" in q:
a = AdministrativeDomain.objects.get(id=q["administrative_domain"])
q["managed_object__in"] = a.managedobject_set.values_list("id", flat=True)
ad = AdministrativeDomain.objects.get(id=q["administrative_domain"])
q["managed_object__in"] = list(
).values_list("id", flat=True)
del q["administrative_domain"]
if "resource_group" in q:
rgs = ResourceGroup.get_by_id(q["resource_group"])
s = set(
......@@ -102,10 +88,10 @@ class EventApplication(ExtApplication):
q["managed_object__in"] = list(set(q["managed_object__in"]).intersection(s))
q["managed_object__in"] = s
del q["resource_group"]
return q
def instance_to_dict(self, o, fields=None):
def instance_to_dict(self, o, fields=None, nocustom=False):
row_class = None
if o.status in ("A", "S"):
subject = o.subject
......@@ -149,10 +135,6 @@ class EventApplication(ExtApplication):
model = self.model_map[status]
return model.objects
@view(url=r"^$", access="launch", method=["GET"], api=True)
def api_list(self, request):
return self.list_data(request, self.instance_to_dict)
@view(url=r"^(?P<id>[a-z0-9]{24})/$", method=["GET"], api=True, access="launch")
def api_event(self, request, id):
event = get_event(id)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment