]> git.ipfire.org Git - pbs.git/commitdiff
builds: Add page that shows groups
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 May 2023 10:28:23 +0000 (10:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 May 2023 10:28:23 +0000 (10:28 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/buildservice/builds.py
src/templates/builds/groups/show.html [new file with mode: 0644]
src/web/__init__.py
src/web/builds.py

index 7dec3625f0ae37bc5713e656ea73f05ee91075e7..a851be675befe073ae57323837132a3606bac12f 100644 (file)
@@ -183,6 +183,9 @@ dist_templates_builds_DATA = \
 
 templates_buildsdir = $(templatesdir)/builds
 
+dist_templates_builds_groups_DATA = \
+       src/templates/builds/groups/show.html
+
 templates_builds_groupsdir = $(templates_buildsdir)/groups
 
 dist_templates_builds_groups_modules_DATA = \
index b63bc7045a02db81bd1fa43d5cdcd3f1008bf20e..9131cec00f5b7e3a7a4866bebdeef31b4e60cf6b 100644 (file)
@@ -1018,6 +1018,19 @@ class Groups(base.Object):
                        """, id,
                )
 
+       def get_by_uuid(self, uuid):
+               return self._get_group("""
+                       SELECT
+                               *
+                       FROM
+                               build_groups
+                       WHERE
+                               deleted_at IS NULL
+                       AND
+                               uuid = %s
+                       """, uuid,
+               )
+
        def create(self, owner=None):
                """
                        Creates a new Build Group
@@ -1040,9 +1053,15 @@ class Groups(base.Object):
 class Group(base.DataObject):
        table = "build_groups"
 
+       def __str__(self):
+               return self.uuid
+
        def __iter__(self):
                return iter(self.builds)
 
+       def __bool__(self):
+               return True
+
        def __len__(self):
                return len(self.builds)
 
diff --git a/src/templates/builds/groups/show.html b/src/templates/builds/groups/show.html
new file mode 100644 (file)
index 0000000..276d2d7
--- /dev/null
@@ -0,0 +1,33 @@
+{% extends "../../base.html" %}
+
+{% block title %}{{ _("Build Group %s") % group }}{% end block %}
+
+{% block body %}
+       <section class="section">
+               <div class="container">
+                       <nav class="breadcrumb" aria-label="breadcrumbs">
+                               <ul>
+                                       <li>
+                                               <a href="/builds">{{ _("Builds") }}</a>
+                                       </li>
+                                       <li>
+                                               <a href="#">{{ _("Group") }}</a>
+                                       </li>
+                                       <li class="is-active">
+                                               <a href="#" aria-current="page">{{ group }}</a>
+                                       </li>
+                               </ul>
+                       </nav>
+
+                       <h1 class="title is-1">{{ _("Build Group %s") % group }}</h1>
+
+                       {% if group.builds %}
+                               {% module BuildsList(group.builds) %}
+                       {% else %}
+                               <div class="notification is-danger">
+                                       {{ _("This build group does not have any builds") }}
+                               </div>
+                       {% end %}
+               </div>
+       </section>
+{% end block %}
index 8d896e4934fadd5f7002ac4e0381fcd5769c1f27..accb69484c4ffe23cba70bfa903382cd256527f7 100644 (file)
@@ -138,6 +138,9 @@ class Application(tornado.web.Application):
 
                        (r"/api/v1/builds", builds.APIv1IndexHandler),
 
+                       # Build Groups
+                       (r"/builds/groups/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", builds.GroupShowHandler),
+
                        # Queue
                        (r"/queue", jobs.QueueHandler),
 
index 2d7c4b0fe45fd6a93439e05965d4ee7494dfef48..8f0f027b7c64834ed89f358f893d222bbe32be4a 100644 (file)
@@ -171,6 +171,15 @@ class CommentHandler(base.BaseHandler):
                self.redirect("/builds/%s" % build.uuid)
 
 
+class GroupShowHandler(base.BaseHandler):
+       def get(self, uuid):
+               group = self.backend.builds.groups.get_by_uuid(uuid)
+               if not group:
+                       raise tornado.web.HTTPError(404, "Could not find build group %s" % uuid)
+
+               self.render("builds/groups/show.html", group=group)
+
+
 class ListModule(ui_modules.UIModule):
        def render(self, builds):
                return self.render_string("builds/modules/list.html", builds=builds)