{# Copyright (C) 2010-2023 Edgewall Software This software is licensed as described in the file COPYING, which you should have received as part of this distribution. The terms are also available at https://trac.edgewall.org/wiki/TracLicense. This software consists of voluntary contributions made by many individuals. For the exact contribution history, see the revision history and logs, available at https://trac.edgewall.org/. #} ## Renders a ticket comment. {# Arguments: - change: the change data - hide_buttons=False: hide all buttons (Edit, Reply) - cnum_edit=None: the comment number being edited - edited_comment: the current value of the comment editor - cnum_hist=None: the comment number for which to show a historical content - can_append=False: True if the user is allowed to append to tickets - preview=False: True if rendering a change preview #} # import 'macros.html' as jmacros with context # with # set cnum = to_unicode(change.get('cnum')) # set hide_buttons = hide_buttons|default(false) # set cnum_edit = cnum_edit|default('') # set cnum_hist = cnum_hist|default('') # set can_append = can_append|default(false) # set comment_resource = Resource('comment', cnum, parent=ticket.resource) # set can_edit_comment = 'TICKET_EDIT_COMMENT' in perm(comment_resource) # set preview = preview|default(false) # set show_editor = can_edit_comment and cnum == cnum_edit # set show_history = cnum is equalto(cnum_hist) # set max_version = change.comment_history|max(0) # set comment_version = (as_int(cversion, max_version, 0, max_version) if show_history else max_version) # set show_buttons = (not hide_buttons and not show_editor and comment_version == max_version) # macro commentref(prefix, cnum, cls=none) ${prefix}${cnum} # endmacro ## jinjacheck: "(a h3 div form div div div div )" OK

# set change_replies = replies.get(cnum, []) if 'cnum' in change else [] # if 'replyto' in change: # set refs = commentref(' '|safe, change.replyto, 'in-reply-to') # trans refs in reply to: ${refs} # endtrans {% if change_replies: %}${_(";")}{% endif %} ## don't forget french typographic rules! ## (note that there's space anyway around the ';' for now) # endif # if change_replies: # endif # if 'cnum' in change: ${commentref('comment:', cnum)} # endif # if 'date' in change: ${tag_("by %(author)s, %(date)s", date = pretty_dateinfo(change.date), author = authorinfo(change.author))} # else: ${tag_("by %(author)s", author = authorinfo(change.author))} # endif # if preview or show_editor: # endif

## Per-change controls # if show_buttons:
# if 'cnum' in change and can_append:
# endif # if 'cnum' in change and can_edit_comment:
# endif
# endif ## Property changes # if change.fields: ## for field_name, field in sorted(change.fields.iteritems(), key=lambda item: item[1].label.lower()): # for field_name, field in change.fields.iteritems()|sort(attribute='1.label'): ## FIXME attribute='1.label|lower' # endfor
${ _("%(label)s:", label=field.label)} # if field_name == 'attachment': # set attachment_link ${ field.new} # endset # trans attachment_link ${attachment_link} added # endtrans # else: ${field.rendered} # endif # if preview and field.by == 'user': # set old = (ticket.get_default(field_name) if field.old is sameas(empty) else field.old) () # endif
# endif
## Comment editor # if show_editor:
${jmacros.form_token_input()}
${jmacros.warnings(chrome.warnings, 'trac-preview-warning')} # endif ## Comment display # if cnum == cnum_edit:
# set text = edited_comment if edited_comment is not none else change.comment ${wiki_to_html(context, text, escape_newlines=preserve_newlines)}
# elif show_history:
${wiki_to_html(context, change.comment_history[comment_version].comment, escape_newlines=preserve_newlines)}
# elif change.comment:
${wiki_to_html(context, change.comment, escape_newlines=preserve_newlines)}
# endif # if not show_editor and len(change.comment_history) is greaterthan(1): # with # set date = pretty_dateinfo(change.comment_history[comment_version].date) # set author = authorinfo(change.comment_history[comment_version].author) # if comment_version != max_version: # trans version = comment_version, date, author Version ${version}, edited ${date} by ${author} # endtrans # else: # trans date, author Last edited ${date} by ${author} # endtrans # endif # endwith # if comment_version is greaterthan(0): (${ _("previous")}) # endif # if comment_version is lessthan(max_version): (${ _("next")}) # endif # if comment_version is greaterthan(0): (${ _("diff")}) # endif # endif # endwith