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