From: Michael Tremer Date: Sun, 30 Apr 2023 10:30:38 +0000 (+0000) Subject: builds: Add some simple controls to create comments X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb548d3739b9dd534749f5ad9e2a7002df25aa41;p=pbs.git builds: Add some simple controls to create comments Signed-off-by: Michael Tremer --- diff --git a/src/templates/builds/show.html b/src/templates/builds/show.html index 3d97a6b8..ca81f227 100644 --- a/src/templates/builds/show.html +++ b/src/templates/builds/show.html @@ -213,9 +213,31 @@ {% end %} + {# Log #}
{{ _("Log") }}
{% module EventsList(build=build, show_build=False) %}
+ + {# Comment - This probably should go into a modal #} +
+
+ {% raw xsrf_form_html() %} + +
+ +
+ +
+
+ +
+
+ +
+
+
+
{% end block %} diff --git a/src/templates/events/modules/list.html b/src/templates/events/modules/list.html index 1054445d..b2a902e2 100644 --- a/src/templates/events/modules/list.html +++ b/src/templates/events/modules/list.html @@ -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 %} diff --git a/src/templates/events/modules/system-message.html b/src/templates/events/modules/system-message.html index 2b364b97..9062d0d7 100644 --- a/src/templates/events/modules/system-message.html +++ b/src/templates/events/modules/system-message.html @@ -19,7 +19,9 @@

- {% 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") }} diff --git a/src/web/__init__.py b/src/web/__init__.py index 0e48b99a..795c24ea 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -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), diff --git a/src/web/builds.py b/src/web/builds.py index c5fc1466..bdcfd200 100644 --- a/src/web/builds.py +++ b/src/web/builds.py @@ -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): diff --git a/src/web/events.py b/src/web/events.py index 37cc2e99..3d9f2ed4 100644 --- a/src/web/events.py +++ b/src/web/events.py @@ -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):