##// END OF EJS Templates
login: fixed bad routing URL in comments, fixes #4065
marcink -
r328:c62a25e2 stable
parent child Browse files
Show More
@@ -1,312 +1,312 b''
1 1 ## -*- coding: utf-8 -*-
2 2 ## usage:
3 3 ## <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
4 4 ## ${comment.comment_block(comment)}
5 5 ##
6 6 <%namespace name="base" file="/base/base.html"/>
7 7
8 8 <%def name="comment_block(comment, inline=False)">
9 9 <div class="comment ${'comment-inline' if inline else ''}" id="comment-${comment.comment_id}" line="${comment.line_no}" data-comment-id="${comment.comment_id}">
10 10 <div class="meta">
11 11 <div class="author">
12 12 ${base.gravatar_with_user(comment.author.email, 16)}
13 13 </div>
14 14 <div class="date">
15 15 ${h.age_component(comment.modified_at, time_is_local=True)}
16 16 </div>
17 17 <div class="status-change">
18 18 %if comment.pull_request:
19 19 <a href="${h.url('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id)}">
20 20 %if comment.status_change:
21 21 ${_('Vote on pull request #%s') % comment.pull_request.pull_request_id}:
22 22 %else:
23 23 ${_('Comment on pull request #%s') % comment.pull_request.pull_request_id}
24 24 %endif
25 25 </a>
26 26 %else:
27 27 %if comment.status_change:
28 28 ${_('Status change on commit')}:
29 29 %else:
30 30 ${_('Comment on commit')}
31 31 %endif
32 32 %endif
33 33 </div>
34 34 %if comment.status_change:
35 35 <div class="${'flag_status %s' % comment.status_change[0].status}"></div>
36 36 <div title="${_('Commit status')}" class="changeset-status-lbl">
37 37 ${comment.status_change[0].status_lbl}
38 38 </div>
39 39 %endif
40 40 <a class="permalink" href="#comment-${comment.comment_id}"> &para;</a>
41 41
42 42
43 43 <div class="comment-links-block">
44 44
45 45 ## show delete comment if it's not a PR (regular comments) or it's PR that is not closed
46 46 ## only super-admin, repo admin OR comment owner can delete
47 47 %if not comment.pull_request or (comment.pull_request and not comment.pull_request.is_closed()):
48 48 %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or comment.author.user_id == c.rhodecode_user.user_id:
49 49 <div onClick="deleteComment(${comment.comment_id})" class="delete-comment"> ${_('Delete')}</div>
50 50 %if inline:
51 51 <div class="comment-links-divider"> | </div>
52 52 %endif
53 53 %endif
54 54 %endif
55 55
56 56 %if inline:
57 57
58 58 <div id="prev_c_${comment.comment_id}" class="comment-previous-link" title="${_('Previous comment')}">
59 59 <a class="arrow_comment_link disabled"><i class="icon-left"></i></a>
60 60 </div>
61 61
62 62 <div id="next_c_${comment.comment_id}" class="comment-next-link" title="${_('Next comment')}">
63 63 <a class="arrow_comment_link disabled"><i class="icon-right"></i></a>
64 64 </div>
65 65 %endif
66 66
67 67 </div>
68 68 </div>
69 69 <div class="text">
70 70 ${comment.render(mentions=True)|n}
71 71 </div>
72 72 </div>
73 73 </%def>
74 74
75 75 <%def name="comment_block_outdated(comment)">
76 76 <div class="comments" id="comment-${comment.comment_id}">
77 77 <div class="comment comment-wrapp">
78 78 <div class="meta">
79 79 <div class="author">
80 80 ${base.gravatar_with_user(comment.author.email, 16)}
81 81 </div>
82 82 <div class="date">
83 83 ${h.age_component(comment.modified_at, time_is_local=True)}
84 84 </div>
85 85 %if comment.status_change:
86 86 <span class="changeset-status-container">
87 87 <span class="changeset-status-ico">
88 88 <div class="${'flag_status %s' % comment.status_change[0].status}"></div>
89 89 </span>
90 90 <span title="${_('Commit status')}" class="changeset-status-lbl"> ${comment.status_change[0].status_lbl}</span>
91 91 </span>
92 92 %endif
93 93 <a class="permalink" href="#comment-${comment.comment_id}">&para;</a>
94 94 ## show delete comment if it's not a PR (regular comments) or it's PR that is not closed
95 95 ## only super-admin, repo admin OR comment owner can delete
96 96 %if not comment.pull_request or (comment.pull_request and not comment.pull_request.is_closed()):
97 97 <div class="comment-links-block">
98 98 %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or comment.author.user_id == c.rhodecode_user.user_id:
99 99 <div data-comment-id=${comment.comment_id} class="delete-comment">${_('Delete')}</div>
100 100 %endif
101 101 </div>
102 102 %endif
103 103 </div>
104 104 <div class="text">
105 105 ${comment.render(mentions=True)|n}
106 106 </div>
107 107 </div>
108 108 </div>
109 109 </%def>
110 110
111 111 <%def name="comment_inline_form()">
112 112 <div id="comment-inline-form-template" style="display: none;">
113 113 <div class="comment-inline-form ac">
114 114 %if c.rhodecode_user.username != h.DEFAULT_USER:
115 115 ${h.form('#', class_='inline-form', method='get')}
116 116 <div id="edit-container_{1}" class="clearfix">
117 117 <div class="comment-title pull-left">
118 118 ${_('Create a comment on line {1}.')}
119 119 </div>
120 120 <div class="comment-help pull-right">
121 121 ${(_('Comments parsed using %s syntax with %s support.') % (
122 122 ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
123 123 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
124 124 )
125 125 )|n
126 126 }
127 127 </div>
128 128 <div style="clear: both"></div>
129 129 <textarea id="text_{1}" name="text" class="comment-block-ta ac-input"></textarea>
130 130 </div>
131 131 <div id="preview-container_{1}" class="clearfix" style="display: none;">
132 132 <div class="comment-help">
133 133 ${_('Comment preview')}
134 134 </div>
135 135 <div id="preview-box_{1}" class="preview-box"></div>
136 136 </div>
137 137 <div class="comment-footer">
138 138 <div class="comment-button hide-inline-form-button cancel-button">
139 139 ${h.reset('hide-inline-form', _('Cancel'), class_='btn hide-inline-form', id_="cancel-btn_{1}")}
140 140 </div>
141 141 <div class="action-buttons">
142 142 <input type="hidden" name="f_path" value="{0}">
143 143 <input type="hidden" name="line" value="{1}">
144 144 <button id="preview-btn_{1}" class="btn btn-secondary">${_('Preview')}</button>
145 145 <button id="edit-btn_{1}" class="btn btn-secondary" style="display: none;">${_('Edit')}</button>
146 146 ${h.submit('save', _('Comment'), class_='btn btn-success save-inline-form')}
147 147 </div>
148 148 ${h.end_form()}
149 149 </div>
150 150 %else:
151 151 ${h.form('', class_='inline-form comment-form-login', method='get')}
152 152 <div class="pull-left">
153 153 <div class="comment-help pull-right">
154 ${_('You need to be logged in to comment.')} <a href="${h.url('login_home',came_from=h.url.current())}">${_('Login now')}</a>
154 ${_('You need to be logged in to comment.')} <a href="${h.route_path('login', _query={'came_from': h.url.current()})}">${_('Login now')}</a>
155 155 </div>
156 156 </div>
157 157 <div class="comment-button pull-right">
158 158 ${h.reset('hide-inline-form', _('Hide'), class_='btn hide-inline-form')}
159 159 </div>
160 160 <div class="clearfix"></div>
161 161 ${h.end_form()}
162 162 %endif
163 163 </div>
164 164 </div>
165 165 </%def>
166 166
167 167
168 168 ## generates inlines taken from c.comments var
169 169 <%def name="inlines(is_pull_request=False)">
170 170 %if is_pull_request:
171 171 <h2 id="comments">${ungettext("%d Pull Request Comment", "%d Pull Request Comments", len(c.comments)) % len(c.comments)}</h2>
172 172 %else:
173 173 <h2 id="comments">${ungettext("%d Commit Comment", "%d Commit Comments", len(c.comments)) % len(c.comments)}</h2>
174 174 %endif
175 175 %for path, lines_comments in c.inline_comments:
176 176 % for line, comments in lines_comments.iteritems():
177 177 <div style="display: none;" class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}">
178 178 ## for each comment in particular line
179 179 %for comment in comments:
180 180 ${comment_block(comment, inline=True)}
181 181 %endfor
182 182 </div>
183 183 %endfor
184 184 %endfor
185 185
186 186 </%def>
187 187
188 188 ## generate inline comments and the main ones
189 189 <%def name="generate_comments(include_pull_request=False, is_pull_request=False)">
190 190 ## generate inlines for this changeset
191 191 ${inlines(is_pull_request)}
192 192
193 193 %for comment in c.comments:
194 194 <div id="comment-tr-${comment.comment_id}">
195 195 ## only render comments that are not from pull request, or from
196 196 ## pull request and a status change
197 197 %if not comment.pull_request or (comment.pull_request and comment.status_change) or include_pull_request:
198 198 ${comment_block(comment)}
199 199 %endif
200 200 </div>
201 201 %endfor
202 202 ## to anchor ajax comments
203 203 <div id="injected_page_comments"></div>
204 204 </%def>
205 205
206 206 ## MAIN COMMENT FORM
207 207 <%def name="comments(post_url, cur_status, is_pull_request=False, is_compare=False, change_status=True, form_extras=None)">
208 208 %if is_compare:
209 209 <% form_id = "comments_form_compare" %>
210 210 %else:
211 211 <% form_id = "comments_form" %>
212 212 %endif
213 213
214 214
215 215 %if is_pull_request:
216 216 <div class="pull-request-merge">
217 217 %if c.allowed_to_merge:
218 218 <div class="pull-request-wrap">
219 219 <div class="pull-right">
220 220 ${h.secure_form(url('pullrequest_merge', repo_name=c.repo_name, pull_request_id=c.pull_request.pull_request_id), id='merge_pull_request_form')}
221 221 <span data-role="merge-message">${c.pr_merge_msg} ${c.approval_msg if c.approval_msg else ''}</span>
222 222 <% merge_disabled = ' disabled' if c.pr_merge_status is False else '' %>
223 223 <input type="submit" id="merge_pull_request" value="${_('Merge Pull Request')}" class="btn${merge_disabled}"${merge_disabled}>
224 224 ${h.end_form()}
225 225 </div>
226 226 </div>
227 227 %else:
228 228 <div class="pull-request-wrap">
229 229 <div class="pull-right">
230 230 <span>${c.pr_merge_msg} ${c.approval_msg if c.approval_msg else ''}</span>
231 231 </div>
232 232 </div>
233 233 %endif
234 234 </div>
235 235 %endif
236 236 <div class="comments">
237 237 %if c.rhodecode_user.username != h.DEFAULT_USER:
238 238 <div class="comment-form ac">
239 239 ${h.secure_form(post_url, id_=form_id)}
240 240 <div id="edit-container" class="clearfix">
241 241 <div class="comment-title pull-left">
242 242 %if is_pull_request:
243 243 ${(_('Create a comment on this Pull Request.'))}
244 244 %elif is_compare:
245 245 ${(_('Create comments on this Commit range.'))}
246 246 %else:
247 247 ${(_('Create a comment on this Commit.'))}
248 248 %endif
249 249 </div>
250 250 <div class="comment-help pull-right">
251 251 ${(_('Comments parsed using %s syntax with %s support.') % (
252 252 ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
253 253 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
254 254 )
255 255 )|n
256 256 }
257 257 </div>
258 258 <div style="clear: both"></div>
259 259 ${h.textarea('text', class_="comment-block-ta")}
260 260 </div>
261 261
262 262 <div id="preview-container" class="clearfix" style="display: none;">
263 263 <div class="comment-title">
264 264 ${_('Comment preview')}
265 265 </div>
266 266 <div id="preview-box" class="preview-box"></div>
267 267 </div>
268 268
269 269 <div id="comment_form_extras">
270 270 %if form_extras and isinstance(form_extras, (list, tuple)):
271 271 % for form_ex_el in form_extras:
272 272 ${form_ex_el|n}
273 273 % endfor
274 274 %endif
275 275 </div>
276 276 <div class="comment-footer">
277 277 %if change_status:
278 278 <div class="status_box">
279 279 <select id="change_status" name="changeset_status">
280 280 <option></option> # Placeholder
281 281 %for status,lbl in c.commit_statuses:
282 282 <option value="${status}" data-status="${status}">${lbl}</option>
283 283 %if is_pull_request and change_status and status in ('approved', 'rejected'):
284 284 <option value="${status}_closed" data-status="${status}">${lbl} & ${_('Closed')}</option>
285 285 %endif
286 286 %endfor
287 287 </select>
288 288 </div>
289 289 %endif
290 290 <div class="action-buttons">
291 291 <button id="preview-btn" class="btn btn-secondary">${_('Preview')}</button>
292 292 <button id="edit-btn" class="btn btn-secondary" style="display:none;">${_('Edit')}</button>
293 293 <div class="comment-button">${h.submit('save', _('Comment'), class_="btn btn-success comment-button-input")}</div>
294 294 </div>
295 295 </div>
296 296 ${h.end_form()}
297 297 </div>
298 298 %endif
299 299 </div>
300 300 <script>
301 301 // init active elements of commentForm
302 302 var commitId = templateContext.commit_data.commit_id;
303 303 var pullRequestId = templateContext.pull_request_data.pull_request_id;
304 304 var lineNo;
305 305
306 306 var mainCommentForm = new CommentForm(
307 307 "#${form_id}", commitId, pullRequestId, lineNo, true);
308 308
309 309 mainCommentForm.initStatusChangeSelector();
310 310
311 311 </script>
312 312 </%def>
General Comments 0
You need to be logged in to leave comments. Login now