## 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
<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">
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)