From: Michael Tremer Date: Fri, 12 May 2023 22:07:07 +0000 (+0000) Subject: builds: Add a watchers module to show all watchers X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d542b33c0ee619169bb2df10c1e7bec39e95cffa;p=pbs.git builds: Add a watchers module to show all watchers Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 4a5bea45..0a43f456 100644 --- a/Makefile.am +++ b/Makefile.am @@ -202,7 +202,8 @@ dist_templates_builds_messages_DATA = \ templates_builds_messagesdir = $(templates_buildsdir)/messages dist_templates_builds_modules_DATA = \ - src/templates/builds/modules/list.html + src/templates/builds/modules/list.html \ + src/templates/builds/modules/watchers.html templates_builds_modulesdir = $(templates_buildsdir)/modules diff --git a/src/templates/builds/modules/watchers.html b/src/templates/builds/modules/watchers.html new file mode 100644 index 00000000..29eae193 --- /dev/null +++ b/src/templates/builds/modules/watchers.html @@ -0,0 +1,66 @@ +
+
+
+ {# Watch/Unwatch #} +
+
+ {% if current_user in watchers %} +
+ {% raw xsrf_form_html() %} + + +
+ {% else %} +
+ {% raw xsrf_form_html() %} + + +
+ {% end %} +
+
+ + {# List all watchers #} + {% for watcher in watchers %} + + +
+ {{ watcher }} +
+
+
+ {% end %} +
+
+
diff --git a/src/templates/builds/show.html b/src/templates/builds/show.html index bd6aa6f0..86fbc0c4 100644 --- a/src/templates/builds/show.html +++ b/src/templates/builds/show.html @@ -106,50 +106,8 @@ {% end %} - {# Watch/Unwatch #} - {% if current_user in build.watchers %} -
- {% raw xsrf_form_html() %} - - -
- {% else %} -
- {% raw xsrf_form_html() %} - - -
- {% end %} + {# Watchers #} + {% module BuildWatchers(build) %} diff --git a/src/web/__init__.py b/src/web/__init__.py index 9727b8e8..8c836702 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -46,6 +46,7 @@ class Application(tornado.web.Application): # Builds "BuildsList" : builds.ListModule, + "BuildWatchers" : builds.WatchersModule, # BuildGroups "BuildGroupList" : builds.GroupListModule, diff --git a/src/web/builds.py b/src/web/builds.py index 8f0f027b..407608f0 100644 --- a/src/web/builds.py +++ b/src/web/builds.py @@ -189,3 +189,12 @@ class GroupListModule(ui_modules.UIModule): def render(self, group, limit=None): return self.render_string("builds/groups/modules/list.html", group=group, limit=limit) + + +class WatchersModule(ui_modules.UIModule): + def render(self, build, watchers=None): + if watchers is None: + watchers = build.watchers + + return self.render_string("builds/modules/watchers.html", + build=build, watchers=watchers)