## usage: ## <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/> ## ${comment.comment_block(comment)} ## <%namespace name="base" file="/base/base.mako"/> <%! from rhodecode.lib import html_filters %> <%def name="comment_block(comment, inline=False, active_pattern_entries=None, is_new=False)"> <% from rhodecode.model.comment import CommentsModel comment_model = CommentsModel() comment_ver = comment.get_index_version(getattr(c, 'versions', [])) latest_ver = len(getattr(c, 'versions', [])) visible_for_user = True if comment.draft: visible_for_user = comment.user_id == c.rhodecode_user.user_id %> % if inline: <% outdated_at_ver = comment.outdated_at_version(c.at_version_num) %> % else: <% outdated_at_ver = comment.older_than_version(c.at_version_num) %> % endif % if visible_for_user:
% if comment.draft:
DRAFT
% elif is_new:
NEW
% endif
## TODO COMMENT % if comment.comment_type == 'todo': % if comment.resolved: % else:
${comment.comment_type}
% endif ## NOTE COMMENT % else: ## RESOLVED NOTE % if comment.resolved_comment: ## STATUS CHANGE NOTE % elif not comment.is_inline and comment.status_change: <% if comment.pull_request: status_change_title = 'Status of review for pull request !{}'.format(comment.pull_request.pull_request_id) else: status_change_title = 'Status of review for commit {}'.format(h.short_id(comment.commit_id)) %>
${comment.review_status_lbl}
% else:
${(comment.comment_type or 'note')}
% endif % endif
## NOTE 0 and .. => because we disable it for now until UI ready % if 0 and comment.status_change: % endif ## Since only author can see drafts, we don't show it % if not comment.draft:
${base.gravatar_with_user(comment.author.email, 16, tooltip=True)}
% endif
${h.age_component(comment.modified_at, time_is_local=True)}
% if comment.pull_request and comment.pull_request.author.user_id == comment.author.user_id: ${_('author')} % endif <% comment_version_selector = 'comment_versions_{}'.format(comment.comment_id) %> % if comment.history:
% else: %endif
${h.render(comment.text, renderer=comment.renderer, mentions=True, repo_name=getattr(c, 'repo_name', None), active_pattern_entries=active_pattern_entries)}
% endif ## generate main comments <%def name="generate_comments(comments, include_pull_request=False, is_pull_request=False)"> <% active_pattern_entries = h.get_active_pattern_entries(getattr(c, 'repo_name', None)) %>
%for comment in comments:
## only render comments that are not from pull request, or from ## pull request and a status change %if not comment.pull_request or (comment.pull_request and comment.status_change) or include_pull_request: ${comment_block(comment, active_pattern_entries=active_pattern_entries)} %endif
%endfor ## to anchor ajax comments
<%def name="comments(post_url, cur_status, is_pull_request=False, is_compare=False, change_status=True, form_extras=None)">
<% if is_pull_request: placeholder = _('Leave a comment on this Pull Request.') elif is_compare: placeholder = _('Leave a comment on {} commits in this range.').format(len(form_extras)) else: placeholder = _('Leave a comment on this Commit.') %> % if c.rhodecode_user.username != h.DEFAULT_USER:
## template generated for injection ${comment_form(form_type='general', review_statuses=c.commit_statuses, form_extras=form_extras)}
## inject form here
% else: ## form state when not logged in
${_('You need to be logged in to leave comments.')} ${_('Login now')}
% endif
<%def name="comment_form(form_type, form_id='', lineno_id='{1}', review_statuses=None, form_extras=None)"> ## comment injected based on assumption that user is logged in
${_('Mark as')}: