]> git.ipfire.org Git - pbs.git/commitdiff
builds: Add a watchers module to show all watchers
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 May 2023 22:07:07 +0000 (22:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 May 2023 22:07:07 +0000 (22:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/builds/modules/watchers.html [new file with mode: 0644]
src/templates/builds/show.html
src/web/__init__.py
src/web/builds.py

index 4a5bea45a288d7853a0c12dc4a38d3719dec43df..0a43f4567ee6a4c336fa889535c27eef002e2319 100644 (file)
@@ -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 (file)
index 0000000..29eae19
--- /dev/null
@@ -0,0 +1,66 @@
+<div class="block">
+       <div class="level">
+               <div class="level-left">
+                       {# Watch/Unwatch #}
+                       <div class="level-item">
+                               <div class="buttons are-small">
+                                       {% if current_user in watchers %}
+                                               <form method="POST" action="/builds/{{ build.uuid }}/unwatch">
+                                                       {% raw xsrf_form_html() %}
+
+                                                       <button class="button is-primary is-outlined">
+                                                               <span class="icon is-small">
+                                                                       <i class="fa-solid fa-eye"></i>
+                                                               </span>
+
+                                                               <span>
+                                                                       {% if len(watchers) == 1 %}
+                                                                               {{ _("You are watching this build") }}
+                                                                       {% else %}
+                                                                               {{ _("You and one other are watching this build",
+                                                                                       "You and %(num)s others are watching this build",
+                                                                                       len(watchers)) % { "num" : len(watchers) }
+                                                                               }}
+                                                                       {% end %}
+                                                               </span>
+                                                       </button>
+                                               </form>
+                                       {% else %}
+                                               <form method="POST" action="/builds/{{ build.uuid }}/watch">
+                                                       {% raw xsrf_form_html() %}
+
+                                                       <button class="button is-primary">
+                                                               <span class="icon is-small">
+                                                                       <i class="fa-regular fa-eye"></i>
+                                                               </span>
+
+                                                               <span>
+                                                                       {% if watchers %}
+                                                                               {{ _("One person is watching this build",
+                                                                                       "%(num)s persons are watching this build",
+                                                                                       len(watchers)) % { "num" : len(watchers) }
+                                                                               }}
+                                                                       {% else %}
+                                                                               {{ _("Watch this build") }}
+                                                                       {% end %}
+                                                               </span>
+                                                       </button>
+                                               </form>
+                                       {% end %}
+                               </div>
+                       </div>
+
+                       {# List all watchers #}
+                       {% for watcher in watchers %}
+                               <a class="level-item" href="/users/{{ watcher.name }}" title="{{ watcher }}">
+                                       <span class="icon">
+                                               <figure class="image">
+                                                       <img class="is-rounded" src="{{ watcher.avatar(32) }}"
+                                                               alt="{{ watcher }}">
+                                               </figure>
+                                       </span>
+                               </a>
+                       {% end %}
+               </div>
+       </div>
+</div>
index bd6aa6f068c77e944aa0645061f01d75ae619d5f..86fbc0c470b2bc2f22f86f221f731d5422024c3f 100644 (file)
                                                {% end %}
                                        </div>
 
-                                       {# Watch/Unwatch #}
-                                       {% if current_user in build.watchers %}
-                                               <form method="POST" action="/builds/{{ build.uuid }}/unwatch">
-                                                       {% raw xsrf_form_html() %}
-
-                                                       <button class="button is-primary is-outlined">
-                                                               <span class="icon is-small">
-                                                                       <i class="fa-solid fa-eye"></i>
-                                                               </span>
-
-                                                               <span>
-                                                                       {% if len(build.watchers) == 1 %}
-                                                                               {{ _("You are watching this build") }}
-                                                                       {% else %}
-                                                                               {{ _("You and one other are watching this build",
-                                                                                       "You and %(num)s others are watching this build",
-                                                                                       len(build.watchers)) % { "num" : len(build.watchers) }
-                                                                               }}
-                                                                       {% end %}
-                                                               </span>
-                                                       </button>
-                                               </form>
-                                       {% else %}
-                                               <form method="POST" action="/builds/{{ build.uuid }}/watch">
-                                                       {% raw xsrf_form_html() %}
-
-                                                       <button class="button is-primary">
-                                                               <span class="icon is-small">
-                                                                       <i class="fa-regular fa-eye"></i>
-                                                               </span>
-
-                                                               <span>
-                                                                       {% if build.watchers %}
-                                                                               {{ _("One person is watching this build",
-                                                                                       "%(num)s persons are watching this build",
-                                                                                       len(build.watchers)) % { "num" : len(build.watchers) }
-                                                                               }}
-                                                                       {% else %}
-                                                                               {{ _("Watch this build") }}
-                                                                       {% end %}
-                                                               </span>
-                                                       </button>
-                                               </form>
-                                       {% end %}
+                                       {# Watchers #}
+                                       {% module BuildWatchers(build) %}
                                </div>
                        </div>
                </div>
index 9727b8e89641e85bf69cff00cfa9faf54b5a9094..8c836702cbfa5922586110fdce4265d746ba5fb0 100644 (file)
@@ -46,6 +46,7 @@ class Application(tornado.web.Application):
 
                                # Builds
                                "BuildsList"         : builds.ListModule,
+                               "BuildWatchers"      : builds.WatchersModule,
 
                                # BuildGroups
                                "BuildGroupList"     : builds.GroupListModule,
index 8f0f027b7c64834ed89f358f893d222bbe32be4a..407608f0022a3018f1312553883dd925f9ea4855 100644 (file)
@@ -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)