[PATCH 14 of 14] controllers: inline changeset.create_comment
Thomas De Schampheleire
patrickdepinguin at gmail.com
Tue Nov 20 20:32:25 UTC 2018
# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
# Date 1542486668 -3600
# Sat Nov 17 21:31:08 2018 +0100
# Node ID be1dc8ce25e56e325489a70516b7d84884ecc1fe
# Parent 0cb01b80b3ae90daaa3e72870239e27d97758ef9
controllers: inline changeset.create_comment
As changeset.create_comment is now only used from
changeset.create_cs_pr_comment (used from pullrequests controller as well),
there is no need to have it as a separate method.
diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py
--- a/kallithea/controllers/changeset.py
+++ b/kallithea/controllers/changeset.py
@@ -167,26 +167,6 @@ def _context_url(GET, fileid=None):
return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'})
-# Could perhaps be nice to have in the model but is too high level ...
-def create_comment(text, status, f_path, line_no, revision=None, pull_request_id=None, closing_pr=None):
- """Comment functionality shared between changesets and pullrequests"""
- f_path = f_path or None
- line_no = line_no or None
-
- comment = ChangesetCommentsModel().create(
- text=text,
- repo=c.db_repo.repo_id,
- author=request.authuser.user_id,
- revision=revision,
- pull_request=pull_request_id,
- f_path=f_path,
- line_no=line_no,
- status_change=ChangesetStatus.get_status_lbl(status) if status else None,
- closing_pr=closing_pr,
- )
-
- return comment
-
def create_cs_pr_comment(repo_name, revision=None, pull_request=None, allowed_to_change_status=True):
assert request.environ.get('HTTP_X_PARTIAL_XHR')
if pull_request:
@@ -227,13 +207,15 @@ def create_cs_pr_comment(repo_name, revi
text = request.POST.get('text', '').strip()
- comment = create_comment(
- text,
- status,
+ comment = ChangesetCommentsModel().create(
+ text=text,
+ repo=c.db_repo.repo_id,
+ author=request.authuser.user_id,
revision=revision,
- pull_request_id=pull_request_id,
- f_path=f_path,
- line_no=line_no,
+ pull_request=pull_request_id,
+ f_path=f_path or None,
+ line_no=line_no or None,
+ status_change=ChangesetStatus.get_status_lbl(status) if status else None,
closing_pr=close_pr,
)
More information about the kallithea-general
mailing list