##// END OF EJS Templates
drafts: fixes in draft comments for non-pr view
milka -
r4550:647f7e13 default
parent child Browse files
Show More
@@ -380,6 +380,7 b' class RepoCommitsView(RepoAppView):'
380
380
381 c = self.load_default_context()
381 c = self.load_default_context()
382 status = self.request.POST.get('changeset_status', None)
382 status = self.request.POST.get('changeset_status', None)
383 is_draft = str2bool(self.request.POST.get('draft'))
383 text = self.request.POST.get('text')
384 text = self.request.POST.get('text')
384 comment_type = self.request.POST.get('comment_type')
385 comment_type = self.request.POST.get('comment_type')
385 resolves_comment_id = self.request.POST.get('resolves_comment_id', None)
386 resolves_comment_id = self.request.POST.get('resolves_comment_id', None)
@@ -400,7 +401,8 b' class RepoCommitsView(RepoAppView):'
400
401
401 commit_ids = multi_commit_ids or [commit_id]
402 commit_ids = multi_commit_ids or [commit_id]
402
403
403 comment = None
404 data = {}
405 # Multiple comments for each passed commit id
404 for current_id in filter(None, commit_ids):
406 for current_id in filter(None, commit_ids):
405 comment = CommentsModel().create(
407 comment = CommentsModel().create(
406 text=text,
408 text=text,
@@ -413,8 +415,10 b' class RepoCommitsView(RepoAppView):'
413 if status else None),
415 if status else None),
414 status_change_type=status,
416 status_change_type=status,
415 comment_type=comment_type,
417 comment_type=comment_type,
418 is_draft=is_draft,
416 resolves_comment_id=resolves_comment_id,
419 resolves_comment_id=resolves_comment_id,
417 auth_user=self._rhodecode_user
420 auth_user=self._rhodecode_user,
421 send_email=not is_draft, # skip notification for draft comments
418 )
422 )
419 is_inline = comment.is_inline
423 is_inline = comment.is_inline
420
424
@@ -442,22 +446,20 b' class RepoCommitsView(RepoAppView):'
442 'repo_commit', repo_name=self.db_repo_name,
446 'repo_commit', repo_name=self.db_repo_name,
443 commit_id=current_id))
447 commit_id=current_id))
444
448
445 commit = self.db_repo.get_commit(current_id)
449 # skip notifications for drafts
446 CommentsModel().trigger_commit_comment_hook(
450 if not is_draft:
447 self.db_repo, self._rhodecode_user, 'create',
451 commit = self.db_repo.get_commit(current_id)
448 data={'comment': comment, 'commit': commit})
452 CommentsModel().trigger_commit_comment_hook(
453 self.db_repo, self._rhodecode_user, 'create',
454 data={'comment': comment, 'commit': commit})
449
455
450 # finalize, commit and redirect
451 Session().commit()
452
453 data = {}
454 if comment:
455 comment_id = comment.comment_id
456 comment_id = comment.comment_id
456 data[comment_id] = {
457 data[comment_id] = {
457 'target_id': target_elem_id
458 'target_id': target_elem_id
458 }
459 }
459 c.co = comment
460 c.co = comment
460 c.at_version_num = 0
461 c.at_version_num = 0
462 c.is_new = True
461 rendered_comment = render(
463 rendered_comment = render(
462 'rhodecode:templates/changeset/changeset_comment_block.mako',
464 'rhodecode:templates/changeset/changeset_comment_block.mako',
463 self._get_template_context(c), self.request)
465 self._get_template_context(c), self.request)
@@ -465,15 +467,20 b' class RepoCommitsView(RepoAppView):'
465 data[comment_id].update(comment.get_dict())
467 data[comment_id].update(comment.get_dict())
466 data[comment_id].update({'rendered_text': rendered_comment})
468 data[comment_id].update({'rendered_text': rendered_comment})
467
469
468 comment_broadcast_channel = channelstream.comment_channel(
470 # skip channelstream for draft comments
469 self.db_repo_name, commit_obj=commit)
471 if not is_draft:
472 comment_broadcast_channel = channelstream.comment_channel(
473 self.db_repo_name, commit_obj=commit)
470
474
471 comment_data = data
475 comment_data = data
472 comment_type = 'inline' if is_inline else 'general'
476 comment_type = 'inline' if is_inline else 'general'
473 channelstream.comment_channelstream_push(
477 channelstream.comment_channelstream_push(
474 self.request, comment_broadcast_channel, self._rhodecode_user,
478 self.request, comment_broadcast_channel, self._rhodecode_user,
475 _('posted a new {} comment').format(comment_type),
479 _('posted a new {} comment').format(comment_type),
476 comment_data=comment_data)
480 comment_data=comment_data)
481
482 # finalize, commit and redirect
483 Session().commit()
477
484
478 return data
485 return data
479
486
General Comments 0
You need to be logged in to leave comments. Login now