]> git.ipfire.org Git - pbs.git/commitdiff
builds: Fix comments
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 Feb 2025 15:53:44 +0000 (15:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 Feb 2025 15:53:44 +0000 (15:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/templates/events/macros.html
src/web/builds.py

index 73b01f056442f713b5fbbf6341b9f7106926dc8d..d6cf373112c4dd386cd8d84a8c0222643a0da201 100644 (file)
@@ -585,20 +585,21 @@ class Build(database.Base, database.BackendMixin, database.SoftDeleteMixin):
 
        ## Comment stuff
 
-       async def comment(self, *args, **kwargs):
+       async def comment(self, **kwargs):
                """
                        Submits a comment
                """
                # Create a new comment
                comment = await self.db.insert(
-                       BuildComment, *args, **kwargs,
+                       BuildComment, build=self, **kwargs,
                )
 
                # Notify
                await comment.notify()
 
-       comments = sqlalchemy.orm.relationship("BuildComment", back_populates="build")
-       # XXX filter out deleted and order
+       comments = sqlalchemy.orm.relationship(
+               "BuildComment", back_populates="build", lazy="selectin",
+       )
 
        # Deleted By ID
 
index 8445a5533da3f0c3fcc8fcb63a4750e3417c43c2..1d5c41b8573da6d21927a91adbc44455fa78b957 100644 (file)
                        <p>
                                <strong>
                                        {% if event.type == "build-comment" %}
-                                               {{ event.by_user }}
+                                               {{ _("%s commented") % event.user }}
                                        {% elif event.type == "build-created" %}
                                                {{ _("Build Created") }}
                                        {% elif event.type == "build-deleted" %}
                                </p>
                        {% endif %}
 
-                       {% block content %}{% endblock %}
+                       {# Content #}
+                       {% if event.type == "build-comment" %}
+                               {{ Text(event.build_comment.text) }}
+                       {% endif %}
 
                        <nav class="level">
                                <div class="level-left">
index 5fe0f9f1c0e6d5e5375f27c66d9ea105e52712e0..759323b268f22c4b6507ba0f2f0509298bd9017a 100644 (file)
@@ -222,15 +222,16 @@ class UnwatchHandler(base.BaseHandler):
 class CommentHandler(base.BaseHandler):
        @base.authenticated
        async def post(self, uuid):
-               build = self.backend.builds.get_by_uuid(uuid)
+               build = await self.backend.builds.get_by_uuid(uuid)
                if not build:
                        raise tornado.web.HTTPError(404, "Could not find build %s" % uuid)
 
-               text = self.get_argument("text")
-
                # Add a new comment to the build
-               with self.db.transaction():
-                       await build.comment(self.current_user, text)
+               async with await self.db.transaction():
+                       await build.comment(
+                               text = self.get_argument("text"),
+                               user = self.current_user,
+                       )
 
                # Redirect to the build
                self.redirect("/builds/%s" % build.uuid)