annotate kallithea/model/comment.py @ 6230:cd6176c0634a

db: PullRequest/Repository/RepoGroup/UserGroup: change 'user' to 'owner' Rename the 'user' and 'user_id' fields on the four classes to something more informative. The database column names remain unchanged for now; a later Alembic script can fix the name of these and other columns to match their Python name. This might break rcextensions, though, and external scripts that use the HTML form interface.
author Søren Løvborg <sorenl@unity3d.com>
date Wed, 14 Sep 2016 16:24:05 +0200
parents 8b75085c2c02
children d1ed15ef8714
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 # This program is free software: you can redistribute it and/or modify
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 # it under the terms of the GNU General Public License as published by
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 # (at your option) any later version.
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 #
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # This program is distributed in the hope that it will be useful,
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 # GNU General Public License for more details.
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 #
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # You should have received a copy of the GNU General Public License
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
14 """
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
15 kallithea.model.comment
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
16 ~~~~~~~~~~~~~~~~~~~~~~~
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
17
4212
24c0d584ba86 General renaming to Kallithea
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4211
diff changeset
18 comments model for Kallithea
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
19
4211
1948ede028ef RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4208
diff changeset
20 This file was forked by the Kallithea project in July 2014.
1948ede028ef RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4208
diff changeset
21 Original author and date, and relevant copyright and licensing information is below:
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
22 :created_on: Nov 11, 2011
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
23 :author: marcink
4211
1948ede028ef RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4208
diff changeset
24 :copyright: (c) 2013 RhodeCode GmbH, and others.
4208
ad38f9f93b3b Correct licensing information in individual files.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4187
diff changeset
25 :license: GPLv3, see LICENSE.md for more details.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
26 """
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 import logging
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1703
diff changeset
30 from pylons.i18n.translation import _
5054
74b5e0318d4e compat: import defaultdict from collections, sqlalchemy 0.8.0 dropped the shim
Andrew Shadura <andrew@shadura.me>
parents: 4791
diff changeset
31 from collections import defaultdict
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1703
diff changeset
32
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
33 from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
34 from kallithea.lib import helpers as h
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
35 from kallithea.model import BaseModel
4422
d51a6f5e57d1 cleanup: remove unused Python imports, found with pyflakes
Mads Kiilerich <madski@unity3d.com>
parents: 4404
diff changeset
36 from kallithea.model.db import ChangesetComment, User, \
2440
1bc579bcd67a - pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents: 2439
diff changeset
37 Notification, PullRequest
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
38 from kallithea.model.notification import NotificationModel
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
39 from kallithea.model.meta import Session
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 log = logging.getLogger(__name__)
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 class ChangesetCommentsModel(BaseModel):
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
46 def _get_notification_data(self, repo, comment, user, comment_text,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
47 line_no=None, revision=None, pull_request=None,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
48 status_change=None, closing_pr=False):
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
49 """
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
50 :returns: tuple (subj,body,recipients,notification_type,email_kwargs)
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
51 """
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
52 # make notification
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
53 body = comment_text # text of the comment
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
54 line = ''
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
55 if line_no:
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
56 line = _('on line %s') % line_no
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
57
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
58 #changeset
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
59 if revision:
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
60 notification_type = Notification.TYPE_CHANGESET_COMMENT
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
61 cs = repo.scm_instance.get_changeset(revision)
5305
72e0fe2e3278 cleanup: remove unnecessary '%s'%s formatting
Mads Kiilerich <madski@unity3d.com>
parents: 5245
diff changeset
62 desc = cs.short_id
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
63
4446
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
64 threading = ['%s-rev-%s@%s' % (repo.repo_name, revision, h.canonical_hostname())]
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
65 if line_no: # TODO: url to file _and_ line number
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
66 threading.append('%s-rev-%s-line-%s@%s' % (repo.repo_name, revision, line_no,
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
67 h.canonical_hostname()))
4445
f9bc28c44f30 urls: introduce canonical_url config setting
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
68 comment_url = h.canonical_url('changeset_home',
4384
0529498575ce notifications: insert 'References' mail headers to help MUA threading
Mads Kiilerich <madski@unity3d.com>
parents: 4381
diff changeset
69 repo_name=repo.repo_name,
0529498575ce notifications: insert 'References' mail headers to help MUA threading
Mads Kiilerich <madski@unity3d.com>
parents: 4381
diff changeset
70 revision=revision,
4445
f9bc28c44f30 urls: introduce canonical_url config setting
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
71 anchor='comment-%s' % comment.comment_id)
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
72 subj = safe_unicode(
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
73 h.link_to('Re changeset: %(desc)s %(line)s' % \
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
74 {'desc': desc, 'line': line},
4384
0529498575ce notifications: insert 'References' mail headers to help MUA threading
Mads Kiilerich <madski@unity3d.com>
parents: 4381
diff changeset
75 comment_url)
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
76 )
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
77 # get the current participants of this changeset
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
78 recipients = ChangesetComment.get_users(revision=revision)
5438
68011c4e6f33 pull requests: call it 'owner' instead of 'author'
Mads Kiilerich <madski@unity3d.com>
parents: 5306
diff changeset
79 # add changeset author if it's known locally
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
80 cs_author = User.get_from_cs_author(cs.author)
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
81 if not cs_author:
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
82 #use repo owner if we cannot extract the author correctly
6056
3a221939a19f notifications: make more template strings available for mails
Mads Kiilerich <madski@unity3d.com>
parents: 5877
diff changeset
83 # FIXME: just use committer name even if not a user
6230
cd6176c0634a db: PullRequest/Repository/RepoGroup/UserGroup: change 'user' to 'owner'
Søren Løvborg <sorenl@unity3d.com>
parents: 6135
diff changeset
84 cs_author = repo.owner
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
85 recipients += [cs_author]
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
86 email_kwargs = {
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
87 'status_change': status_change,
5499
f24851239566 pull requests: blame the right user when an admin adds reviewers to other peoples PRs
Mads Kiilerich <madski@unity3d.com>
parents: 5460
diff changeset
88 'cs_comment_user': user.full_name_and_username,
4445
f9bc28c44f30 urls: introduce canonical_url config setting
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
89 'cs_target_repo': h.canonical_url('summary_home', repo_name=repo.repo_name),
4384
0529498575ce notifications: insert 'References' mail headers to help MUA threading
Mads Kiilerich <madski@unity3d.com>
parents: 4381
diff changeset
90 'cs_comment_url': comment_url,
6135
8b75085c2c02 mails: restructure notification mail content
Mads Kiilerich <madski@unity3d.com>
parents: 6119
diff changeset
91 'cs_url': h.canonical_url('changeset_home', repo_name=repo.repo_name, revision=revision),
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
92 'raw_id': revision,
4381
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
93 'message': cs.message,
6058
bd5d70b6f445 email: add relevant title to subject of emails
Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
parents: 6057
diff changeset
94 'message_short': h.shorter(cs.message, 50, firstline=True),
6056
3a221939a19f notifications: make more template strings available for mails
Mads Kiilerich <madski@unity3d.com>
parents: 5877
diff changeset
95 'cs_author': cs_author,
4381
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
96 'repo_name': repo.repo_name,
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
97 'short_id': h.short_id(revision),
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
98 'branch': cs.branch,
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
99 'comment_username': user.username,
4446
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
100 'threading': threading,
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
101 }
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
102 #pull request
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
103 elif pull_request:
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
104 notification_type = Notification.TYPE_PULL_REQUEST_COMMENT
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
105 desc = comment.pull_request.title
4381
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
106 _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':')
6056
3a221939a19f notifications: make more template strings available for mails
Mads Kiilerich <madski@unity3d.com>
parents: 5877
diff changeset
107 _other_ref_type, other_ref_name, _other_rev = comment.pull_request.other_ref.split(':')
4446
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
108 threading = ['%s-pr-%s@%s' % (pull_request.other_repo.repo_name,
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
109 pull_request.pull_request_id,
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
110 h.canonical_hostname())]
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
111 if line_no: # TODO: url to file _and_ line number
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
112 threading.append('%s-pr-%s-line-%s@%s' % (pull_request.other_repo.repo_name,
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
113 pull_request.pull_request_id, line_no,
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
114 h.canonical_hostname()))
4447
e30401bac6e1 pull requests: show more helpful URLs
Mads Kiilerich <madski@unity3d.com>
parents: 4446
diff changeset
115 comment_url = pull_request.url(canonical=True,
4445
f9bc28c44f30 urls: introduce canonical_url config setting
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
116 anchor='comment-%s' % comment.comment_id)
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
117 subj = safe_unicode(
5089
196c46444d98 pullrequests: add PullRequest.nice_id method
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5086
diff changeset
118 h.link_to('Re pull request %(pr_nice_id)s: %(desc)s %(line)s' % \
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
119 {'desc': desc,
5089
196c46444d98 pullrequests: add PullRequest.nice_id method
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5086
diff changeset
120 'pr_nice_id': comment.pull_request.nice_id(),
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
121 'line': line},
4384
0529498575ce notifications: insert 'References' mail headers to help MUA threading
Mads Kiilerich <madski@unity3d.com>
parents: 4381
diff changeset
122 comment_url)
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
123 )
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
124 # get the current participants of this pull request
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
125 recipients = ChangesetComment.get_users(pull_request_id=
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
126 pull_request.pull_request_id)
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
127 # add pull request author
5438
68011c4e6f33 pull requests: call it 'owner' instead of 'author'
Mads Kiilerich <madski@unity3d.com>
parents: 5306
diff changeset
128 recipients += [pull_request.owner]
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
129
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
130 # add the reviewers to notification
5763
20a094053606 pullrequests: optimize iteration over reviewers - avoid fetching users one by one
Mads Kiilerich <madski@unity3d.com>
parents: 5598
diff changeset
131 recipients += pull_request.get_reviewer_users()
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
132
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
133 #set some variables for email notification
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
134 email_kwargs = {
3780
1de8abd9a4e1 emails: try to improve wording and layout - 1st iteration
Mads Kiilerich <madski@unity3d.com>
parents: 3430
diff changeset
135 'pr_title': pull_request.title,
6058
bd5d70b6f445 email: add relevant title to subject of emails
Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
parents: 6057
diff changeset
136 'pr_title_short': h.shorter(pull_request.title, 50),
5089
196c46444d98 pullrequests: add PullRequest.nice_id method
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5086
diff changeset
137 'pr_nice_id': pull_request.nice_id(),
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
138 'status_change': status_change,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
139 'closing_pr': closing_pr,
4384
0529498575ce notifications: insert 'References' mail headers to help MUA threading
Mads Kiilerich <madski@unity3d.com>
parents: 4381
diff changeset
140 'pr_comment_url': comment_url,
6135
8b75085c2c02 mails: restructure notification mail content
Mads Kiilerich <madski@unity3d.com>
parents: 6119
diff changeset
141 'pr_url': pull_request.url(canonical=True),
5499
f24851239566 pull requests: blame the right user when an admin adds reviewers to other peoples PRs
Mads Kiilerich <madski@unity3d.com>
parents: 5460
diff changeset
142 'pr_comment_user': user.full_name_and_username,
4445
f9bc28c44f30 urls: introduce canonical_url config setting
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
143 'pr_target_repo': h.canonical_url('summary_home',
f9bc28c44f30 urls: introduce canonical_url config setting
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
144 repo_name=pull_request.other_repo.repo_name),
6056
3a221939a19f notifications: make more template strings available for mails
Mads Kiilerich <madski@unity3d.com>
parents: 5877
diff changeset
145 'pr_target_branch': other_ref_name,
3a221939a19f notifications: make more template strings available for mails
Mads Kiilerich <madski@unity3d.com>
parents: 5877
diff changeset
146 'pr_source_repo': h.canonical_url('summary_home',
3a221939a19f notifications: make more template strings available for mails
Mads Kiilerich <madski@unity3d.com>
parents: 5877
diff changeset
147 repo_name=pull_request.org_repo.repo_name),
3a221939a19f notifications: make more template strings available for mails
Mads Kiilerich <madski@unity3d.com>
parents: 5877
diff changeset
148 'pr_source_branch': org_ref_name,
3a221939a19f notifications: make more template strings available for mails
Mads Kiilerich <madski@unity3d.com>
parents: 5877
diff changeset
149 'pr_owner': pull_request.owner,
6059
d4061c6cc0e2 notifications: tweak PR mail subject lines
Mads Kiilerich <madski@unity3d.com>
parents: 6058
diff changeset
150 'pr_owner_username': pull_request.owner.username,
4381
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
151 'repo_name': pull_request.other_repo.repo_name,
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
152 'comment_username': user.username,
4446
5e7c69707f08 notifications: fix threading - use line number
Mads Kiilerich <madski@unity3d.com>
parents: 4445
diff changeset
153 'threading': threading,
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
154 }
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
155
4381
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
156 return subj, body, recipients, notification_type, email_kwargs
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
157
2541
1c2ba03c42b4 Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents: 2522
diff changeset
158 def create(self, text, repo, user, revision=None, pull_request=None,
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
159 f_path=None, line_no=None, status_change=None, closing_pr=False,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
160 send_email=True):
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
161 """
5085
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
162 Creates a new comment for either a changeset or a pull request.
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
163 status_change and closing_pr is only for the optional email.
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1734
diff changeset
164
5085
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
165 Returns the created comment.
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
166 """
5068
140f2811fc6f comments: avoid storing 'No comments' text when changing status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5054
diff changeset
167 if not status_change and not text:
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
168 log.warning('Missing text for comment, skipping...')
5198
93e055489e68 pullrequsts: really create a comment when creating a PR and setting status to 'under review'
Mads Kiilerich <madski@unity3d.com>
parents: 5089
diff changeset
169 return None
2150
a8c9c0094ddf White space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2109
diff changeset
170
2541
1c2ba03c42b4 Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents: 2522
diff changeset
171 repo = self._get_repo(repo)
1c2ba03c42b4 Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents: 2522
diff changeset
172 user = self._get_user(user)
2443
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
173 comment = ChangesetComment()
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
174 comment.repo = repo
2541
1c2ba03c42b4 Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents: 2522
diff changeset
175 comment.author = user
2443
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
176 comment.text = text
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
177 comment.f_path = f_path
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
178 comment.line_no = line_no
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
179
5306
63bed817308c cleanup: check for None object identity in cases where that is what the 'contract' says
Mads Kiilerich <madski@unity3d.com>
parents: 5305
diff changeset
180 if revision is not None:
1677
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1675
diff changeset
181 comment.revision = revision
5306
63bed817308c cleanup: check for None object identity in cases where that is what the 'contract' says
Mads Kiilerich <madski@unity3d.com>
parents: 5305
diff changeset
182 elif pull_request is not None:
6119
91b38dc6d891 model: refactor and simplify _get_instance
Søren Løvborg <sorenl@unity3d.com>
parents: 6118
diff changeset
183 pull_request = PullRequest.guess_instance(pull_request)
2443
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
184 comment.pull_request = pull_request
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
185 else:
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
186 raise Exception('Please specify revision or pull_request_id')
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
187
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
188 Session().add(comment)
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
189 Session().flush()
2443
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
190
3257
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
191 if send_email:
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
192 (subj, body, recipients, notification_type,
4381
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
193 email_kwargs) = self._get_notification_data(
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
194 repo, comment, user,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
195 comment_text=text,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
196 line_no=line_no,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
197 revision=revision,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
198 pull_request=pull_request,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
199 status_change=status_change,
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
200 closing_pr=closing_pr)
4404
231442b0b6aa pull requests: handle @mention in PR description ... but so far without fancy js completion
Mads Kiilerich <madski@unity3d.com>
parents: 4384
diff changeset
201 email_kwargs['is_mention'] = False
3257
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
202 # create notification objects, and emails
2077
179604334d98 code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
203 NotificationModel().create(
2541
1c2ba03c42b4 Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents: 2522
diff changeset
204 created_by=user, subject=subj, body=body,
3257
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
205 recipients=recipients, type_=notification_type,
4381
55f2f2b4c462 notifications: improve Email subjects
Mads Kiilerich <madski@unity3d.com>
parents: 4380
diff changeset
206 email_kwargs=email_kwargs,
2077
179604334d98 code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
207 )
1703
f23828b00b21 notification fixes and improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1681
diff changeset
208
5877
ba5fee3879c8 utils: improve extract_mentioned_users usefulness
Søren Løvborg <sorenl@unity3d.com>
parents: 5763
diff changeset
209 mention_recipients = extract_mentioned_users(body).difference(recipients)
3257
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
210 if mention_recipients:
4404
231442b0b6aa pull requests: handle @mention in PR description ... but so far without fancy js completion
Mads Kiilerich <madski@unity3d.com>
parents: 4384
diff changeset
211 email_kwargs['is_mention'] = True
3257
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
212 subj = _('[Mention]') + ' ' + subj
6057
552800808386 tests: add test coverage of PR comment @mention
Mads Kiilerich <madski@unity3d.com>
parents: 6056
diff changeset
213 # FIXME: this subject is wrong and unused!
3257
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
214 NotificationModel().create(
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
215 created_by=user, subject=subj, body=body,
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
216 recipients=mention_recipients,
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
217 type_=notification_type,
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
218 email_kwargs=email_kwargs
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
219 )
32a283e5fd0d Don't send notification email for auto-status changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3250
diff changeset
220
2443
fd0a822481ec - added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2440
diff changeset
221 return comment
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
222
1713
54687aa00724 Tests updates, Session refactoring
Marcin Kuzminski <marcin@python-works.com>
parents: 1712
diff changeset
223 def delete(self, comment):
6119
91b38dc6d891 model: refactor and simplify _get_instance
Søren Løvborg <sorenl@unity3d.com>
parents: 6118
diff changeset
224 comment = ChangesetComment.guess_instance(comment)
3430
bbe21df7ad48 notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3257
diff changeset
225 Session().delete(comment)
1713
54687aa00724 Tests updates, Session refactoring
Marcin Kuzminski <marcin@python-works.com>
parents: 1712
diff changeset
226
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
227 return comment
1675
7c487d2678c7 code refactoring
Marcin Kuzminski <marcin@python-works.com>
parents: 1670
diff changeset
228
2440
1bc579bcd67a - pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents: 2439
diff changeset
229 def get_comments(self, repo_id, revision=None, pull_request=None):
2439
ad19dfcdb1cc Refactoring of changeset_file_comments for more generic usage. In both It enables sharing code between changeset, and pull requests discussions
Marcin Kuzminski <marcin@python-works.com>
parents: 2434
diff changeset
230 """
5085
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
231 Gets general comments for either revision or pull_request.
2439
ad19dfcdb1cc Refactoring of changeset_file_comments for more generic usage. In both It enables sharing code between changeset, and pull requests discussions
Marcin Kuzminski <marcin@python-works.com>
parents: 2434
diff changeset
232
5085
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
233 Returns a list, ordered by creation date.
2439
ad19dfcdb1cc Refactoring of changeset_file_comments for more generic usage. In both It enables sharing code between changeset, and pull requests discussions
Marcin Kuzminski <marcin@python-works.com>
parents: 2434
diff changeset
234 """
5086
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
235 return self._get_comments(repo_id, revision=revision, pull_request=pull_request,
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
236 inline=False)
1675
7c487d2678c7 code refactoring
Marcin Kuzminski <marcin@python-works.com>
parents: 1670
diff changeset
237
2440
1bc579bcd67a - pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents: 2439
diff changeset
238 def get_inline_comments(self, repo_id, revision=None, pull_request=None):
5085
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
239 """
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
240 Gets inline comments for either revision or pull_request.
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
241
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
242 Returns a list of tuples with file path and list of comments per line number.
34f2da0a2969 ChangesetCommentsModel: cleanup of doc strings
Jan Heylen <heyleke@gmail.com>
parents: 5068
diff changeset
243 """
5086
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
244 comments = self._get_comments(repo_id, revision=revision, pull_request=pull_request,
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
245 inline=True)
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
246
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
247 paths = defaultdict(lambda: defaultdict(list))
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
248 for co in comments:
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
249 paths[co.f_path][co.line_no].append(co)
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
250 return paths.items()
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
251
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
252 def _get_comments(self, repo_id, revision=None, pull_request=None, inline=False):
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
253 """
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
254 Gets comments for either revision or pull_request_id, either inline or general.
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
255 """
5460
5be4d7d6ac05 pull requests: don't filter on repo when finding comments for a PR
Mads Kiilerich <madski@unity3d.com>
parents: 5438
diff changeset
256 q = Session().query(ChangesetComment)
5086
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
257
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
258 if inline:
5598
edb24bc0f71a cleanup: consistent space before line continuation backslash
Mads Kiilerich <madski@unity3d.com>
parents: 5539
diff changeset
259 q = q.filter(ChangesetComment.line_no != None) \
5086
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
260 .filter(ChangesetComment.f_path != None)
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
261 else:
5598
edb24bc0f71a cleanup: consistent space before line continuation backslash
Mads Kiilerich <madski@unity3d.com>
parents: 5539
diff changeset
262 q = q.filter(ChangesetComment.line_no == None) \
5086
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
263 .filter(ChangesetComment.f_path == None)
2439
ad19dfcdb1cc Refactoring of changeset_file_comments for more generic usage. In both It enables sharing code between changeset, and pull requests discussions
Marcin Kuzminski <marcin@python-works.com>
parents: 2434
diff changeset
264
5539
87285c5007fb comments: check for None instead of boolean checks
Mads Kiilerich <madski@unity3d.com>
parents: 5499
diff changeset
265 if revision is not None:
5598
edb24bc0f71a cleanup: consistent space before line continuation backslash
Mads Kiilerich <madski@unity3d.com>
parents: 5539
diff changeset
266 q = q.filter(ChangesetComment.revision == revision) \
5460
5be4d7d6ac05 pull requests: don't filter on repo when finding comments for a PR
Mads Kiilerich <madski@unity3d.com>
parents: 5438
diff changeset
267 .filter(ChangesetComment.repo_id == repo_id)
5539
87285c5007fb comments: check for None instead of boolean checks
Mads Kiilerich <madski@unity3d.com>
parents: 5499
diff changeset
268 elif pull_request is not None:
6119
91b38dc6d891 model: refactor and simplify _get_instance
Søren Løvborg <sorenl@unity3d.com>
parents: 6118
diff changeset
269 pull_request = PullRequest.guess_instance(pull_request)
2440
1bc579bcd67a - pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents: 2439
diff changeset
270 q = q.filter(ChangesetComment.pull_request == pull_request)
2439
ad19dfcdb1cc Refactoring of changeset_file_comments for more generic usage. In both It enables sharing code between changeset, and pull requests discussions
Marcin Kuzminski <marcin@python-works.com>
parents: 2434
diff changeset
271 else:
5086
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
272 raise Exception('Please specify either revision or pull_request')
1677
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1675
diff changeset
273
5086
b5e399286ce5 ChangesetCommentsModel: refactor duplicate code
Jan Heylen <heyleke@gmail.com>
parents: 5085
diff changeset
274 return q.order_by(ChangesetComment.created_on).all()