Mercurial > kallithea
comparison rhodecode/controllers/changeset.py @ 3695:45df84d36b44 beta
Implemented preview for comments
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 06 Apr 2013 02:49:42 +0200 |
parents | ec6354949623 |
children | b950b884ab87 |
comparison
equal
deleted
inserted
replaced
3694:34093903b505 | 3695:45df84d36b44 |
---|---|
35 | 35 |
36 from rhodecode.lib.vcs.exceptions import RepositoryError, \ | 36 from rhodecode.lib.vcs.exceptions import RepositoryError, \ |
37 ChangesetDoesNotExistError | 37 ChangesetDoesNotExistError |
38 | 38 |
39 import rhodecode.lib.helpers as h | 39 import rhodecode.lib.helpers as h |
40 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | 40 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator,\ |
41 NotAnonymous | |
41 from rhodecode.lib.base import BaseRepoController, render | 42 from rhodecode.lib.base import BaseRepoController, render |
42 from rhodecode.lib.utils import action_logger | 43 from rhodecode.lib.utils import action_logger |
43 from rhodecode.lib.compat import OrderedDict | 44 from rhodecode.lib.compat import OrderedDict |
44 from rhodecode.lib import diffs | 45 from rhodecode.lib import diffs |
45 from rhodecode.model.db import ChangesetComment, ChangesetStatus | 46 from rhodecode.model.db import ChangesetComment, ChangesetStatus |
318 return self.index(revision, method='patch') | 319 return self.index(revision, method='patch') |
319 | 320 |
320 def changeset_download(self, revision): | 321 def changeset_download(self, revision): |
321 return self.index(revision, method='download') | 322 return self.index(revision, method='download') |
322 | 323 |
324 @NotAnonymous() | |
323 @jsonify | 325 @jsonify |
324 def comment(self, repo_name, revision): | 326 def comment(self, repo_name, revision): |
325 status = request.POST.get('changeset_status') | 327 status = request.POST.get('changeset_status') |
326 change_status = request.POST.get('change_changeset_status') | 328 change_status = request.POST.get('change_changeset_status') |
327 text = request.POST.get('text') | 329 text = request.POST.get('text') |
380 data.update({'rendered_text': | 382 data.update({'rendered_text': |
381 render('changeset/changeset_comment_block.html')}) | 383 render('changeset/changeset_comment_block.html')}) |
382 | 384 |
383 return data | 385 return data |
384 | 386 |
387 @NotAnonymous() | |
388 def preview_comment(self): | |
389 if not request.environ.get('HTTP_X_PARTIAL_XHR'): | |
390 raise HTTPBadRequest() | |
391 text = request.POST.get('text') | |
392 if text: | |
393 return h.rst_w_mentions(text) | |
394 return '' | |
395 | |
396 @NotAnonymous() | |
385 @jsonify | 397 @jsonify |
386 def delete_comment(self, repo_name, comment_id): | 398 def delete_comment(self, repo_name, comment_id): |
387 co = ChangesetComment.get(comment_id) | 399 co = ChangesetComment.get(comment_id) |
388 owner = co.author.user_id == c.rhodecode_user.user_id | 400 owner = co.author.user_id == c.rhodecode_user.user_id |
389 if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner: | 401 if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner: |