$def with(comment=None, comment_str=None) $# Creates a single comment element for the librarian merge requests table. $# $# This template excepts comments in either object (`comment`) or string (`comment_str`) form. $# If a string is passed, it is assumed that the comment was submitted just now, and that the $# commenter is the currently logged-in patron. $# $# Parameters: $# comment : dict : Object that represents a single comment on a merge request. $# comment['message'] : str : The comment $# comment['username'] : str : Username of patron who left the comment $# comment['timestamp'] : datetime : Timestamp of this comment $# comment_str : str : The comment $if comment_str: $ comment_time = _('Just now') $ commenter = ctx.user and ctx.user.key.split('/')[-1] $ owner = 'owner' $ message = comment_str $else: $ comment_timestamp = to_datetime(comment['timestamp']) $ date = comment_timestamp.strftime('%d %b %y') $ time = comment_timestamp.strftime('%X') $ comment_time = '%s %s' % (date, time) $ commenter = comment['username'] $ username = ctx.user and ctx.user.key.split('/')[-1] $ is_commenter = username == commenter $ owner = 'owner' if is_commenter else '' $ message = comment['message']
$commenter $comment_time
$message