From: Michael Tremer Date: Tue, 23 May 2023 13:11:45 +0000 (+0000) Subject: monitorings: Implement controls to force check X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef753044ed62ebe3f5df2c556f3684af2a48d461;p=pbs.git monitorings: Implement controls to force check Signed-off-by: Michael Tremer --- diff --git a/src/templates/monitorings/show.html b/src/templates/monitorings/show.html index f44f152b..50449c27 100644 --- a/src/templates/monitorings/show.html +++ b/src/templates/monitorings/show.html @@ -68,9 +68,13 @@
- +
+ {% raw xsrf_form_html() %} +
+ +
{{ _("Edit") }} diff --git a/src/web/__init__.py b/src/web/__init__.py index 11a6a123..1dba2b1a 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -204,6 +204,7 @@ class Application(tornado.web.Application): # Distro Monitorings (r"/distros/([A-Za-z0-9\-\.]+)/monitorings/([\w\-_]+)", monitorings.ShowHandler), + (r"/distros/([A-Za-z0-9\-\.]+)/monitorings/([\w\-_]+)/check", monitorings.CheckHandler), # Mirrors (r"/mirrors", mirrors.IndexHandler), diff --git a/src/web/monitorings.py b/src/web/monitorings.py index 68b5bc40..570192de 100644 --- a/src/web/monitorings.py +++ b/src/web/monitorings.py @@ -38,6 +38,26 @@ class ShowHandler(base.BaseHandler): self.render("monitorings/show.html", monitoring=monitoring) +class CheckHandler(base.BaseHandler): + async def post(self, slug, name): + # Fetch the distribution + distro = self.backend.distros.get_by_slug(slug) + if not distro: + raise tornado.web.HTTPError(404, "Could not find distro %s" % slug) + + # Fetch the monitoring + monitoring = self.backend.monitorings.get_by_distro_and_name(distro, name) + if not monitoring: + raise tornado.web.HTTPError(404, "Could not find monitoring for %s in %s" % (name, distro)) + + # Perform check + with self.db.transaction(): + await monitoring.check() + + # Redirect back + self.redirect(monitoring.url) + + class ReleasesListModule(ui_modules.UIModule): def render(self, releases, show_empty=True): return self.render_string("monitorings/modules/releases-list.html",