]> git.ipfire.org Git - pbs.git/commitdiff
builds: Add some simple controls to create comments
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 30 Apr 2023 10:30:38 +0000 (10:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 30 Apr 2023 10:30:38 +0000 (10:30 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/builds/show.html
src/templates/events/modules/list.html
src/templates/events/modules/system-message.html
src/web/__init__.py
src/web/builds.py
src/web/events.py

index 3d97a6b8afb70438321edc7957f218cfe44a08ab..ca81f2279cb39cde3fd4587719f363596e420e13 100644 (file)
                </section>
        {% end %}
 
+       {# Log #}
        <section class="section">
                <h5 class="title is-5">{{ _("Log") }}</h5>
 
                {% module EventsList(build=build, show_build=False) %}
        </section>
+
+       {# Comment - This probably should go into a modal #}
+       <section class="section">
+               <form method="POST" action="/builds/{{ build.uuid }}/comment">
+                       {% raw xsrf_form_html() %}
+
+                       <div class="field">
+                               <label class="label">{{ _("Comment") }}</label>
+                               <div class="control">
+                                       <textarea class="textarea" name="text" rows="8"
+                                               placeholder="{{ _("Comment...") }}"></textarea>
+                               </div>
+                       </div>
+
+                       <div class="field">
+                               <div class="control">
+                                       <button class="button is-link">Submit</button>
+                               </div>
+                       </div>
+               </form>
+       </section>
 {% end block %}
index 1054445dbcd6f5de3c184ee15e831ceb93b9ed19..b2a902e2b6dc4674cfb513ceed06d9a76a5712de 100644 (file)
@@ -1,6 +1,6 @@
 {% for event in events %}
        {% if event.build_comment %}
-               {% module EventBuildComment(event, show_build=show_build) %}
+               {% module EventBuildComment(event, show_build=show_build, show_builder=show_builder) %}
        {% elif event.user or event.by_user %}
                {% module EventUserMessage(event, show_build=show_build, show_builder=show_builder) %}
        {% else %}
index 2b364b97d301fcad4920bede9c773291c7c86419..9062d0d79c376edb3666ae04fe42722e3e9c9d54 100644 (file)
@@ -19,7 +19,9 @@
 
        <div class="media-content">
                <p>
-                       {% if event.type == "build-created" %}
+                       {% if event.type == "build-comment" %}
+                               {{ _("%s Commented") % event.by_user }}
+                       {% elif event.type == "build-created" %}
                                {{ _("Build Created") }}
                        {% elif event.type == "build-deleted" %}
                                {{ _("Build Deleted") }}
index 0e48b99abdc523284d2401ea1966c248888d2f82..795c24eaaa7b96a66d7d8c432d99bf4d956f6ba8 100644 (file)
@@ -125,10 +125,10 @@ class Application(tornado.web.Application):
                        # Builds
                        (r"/builds", builds.IndexHandler),
                        (r"/builds/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", builds.ShowHandler),
+                       (r"/builds/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/comment", builds.CommentHandler),
                        (r"/builds/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/delete", builds.DeleteHandler),
                        (r"/builds/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/watch", builds.WatchHandler),
                        (r"/builds/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/unwatch", builds.UnwatchHandler),
-                       (r"/build/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/comment", builds.BuildDetailCommentHandler),
 
                        (r"/api/v1/builds", builds.APIv1IndexHandler),
 
index c5fc1466b05fe570b46009862caea7f9036ce292..bdcfd2008152fb7712b77d8b9a9a6bf92e9c4e09 100644 (file)
@@ -141,31 +141,21 @@ class UnwatchHandler(base.BaseHandler):
                self.redirect("/builds/%s" % build.uuid)
 
 
-class BuildDetailCommentHandler(base.BaseHandler):
+class CommentHandler(base.BaseHandler):
        @tornado.web.authenticated
        def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
-
                if not build:
-                       raise tornado.web.HTTPError(404, "Build not found")
-
-               vote = self.get_argument("vote", "none")
-
-               if vote == "up":
-                       vote = 1
-               elif vote == "down":
-                       vote = -1
-               else:
-                       vote = 0
+                       raise tornado.web.HTTPError(404, "Could not find build %s" % uuid)
 
-               text = self.get_argument("text", "")
+               text = self.get_argument("text")
 
-               # Add a new comment to the build.
-               if text or vote:
-                       build.comment(self.current_user, text, vote)
+               # Add a new comment to the build
+               with self.db.transaction():
+                       build.comment(self.current_user, text)
 
-               # Redirect to the build detail page.
-               self.redirect("/build/%s" % build.uuid)
+               # Redirect to the build
+               self.redirect("/builds/%s" % build.uuid)
 
 
 class ListModule(ui_modules.UIModule):
index 37cc2e99a7bdb3747f4db8aa890f180754fe2e41..3d9f2ed4acaade93de25e0aee2f39960b87a74b0 100644 (file)
@@ -33,9 +33,10 @@ class ListModule(ui_modules.UIModule):
 
 
 class BuildCommentModule(ui_modules.UIModule):
-       def render(self, event, show_build=False):
+       def render(self, event, show_build=False, show_builder=True):
                return self.render_string("events/modules/build-comment.html",
-                       event=event, comment=event.build_comment, show_build=show_build)
+                       event=event, comment=event.build_comment,
+                       show_build=show_build, show_builder=show_builder)
 
 
 class UserMessageModule(ui_modules.UIModule):