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
--- /dev/null
+<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>
{% 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>
# Builds
"BuildsList" : builds.ListModule,
+ "BuildWatchers" : builds.WatchersModule,
# BuildGroups
"BuildGroupList" : builds.GroupListModule,
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)