##// END OF EJS Templates
api: added possibility to specify comment_type for comment API.
marcink -
r1337:e83852af default
parent child Browse files
Show More
@@ -31,7 +31,7 b' from rhodecode.lib.base import vcs_opera'
31 from rhodecode.lib.utils2 import str2bool
31 from rhodecode.lib.utils2 import str2bool
32 from rhodecode.model.changeset_status import ChangesetStatusModel
32 from rhodecode.model.changeset_status import ChangesetStatusModel
33 from rhodecode.model.comment import CommentsModel
33 from rhodecode.model.comment import CommentsModel
34 from rhodecode.model.db import Session, ChangesetStatus
34 from rhodecode.model.db import Session, ChangesetStatus, ChangesetComment
35 from rhodecode.model.pull_request import PullRequestModel, MergeCheck
35 from rhodecode.model.pull_request import PullRequestModel, MergeCheck
36 from rhodecode.model.settings import SettingsModel
36 from rhodecode.model.settings import SettingsModel
37
37
@@ -360,9 +360,10 b' def close_pull_request(request, apiuser,'
360
360
361
361
362 @jsonrpc_method()
362 @jsonrpc_method()
363 def comment_pull_request(request, apiuser, repoid, pullrequestid,
363 def comment_pull_request(
364 message=Optional(None), status=Optional(None),
364 request, apiuser, repoid, pullrequestid, message=Optional(None),
365 commit_id=Optional(None),
365 commit_id=Optional(None), status=Optional(None),
366 comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE),
366 userid=Optional(OAttr('apiuser'))):
367 userid=Optional(OAttr('apiuser'))):
367 """
368 """
368 Comment on the pull request specified with the `pullrequestid`,
369 Comment on the pull request specified with the `pullrequestid`,
@@ -375,19 +376,18 b' def comment_pull_request(request, apiuse'
375 :type repoid: str or int
376 :type repoid: str or int
376 :param pullrequestid: The pull request ID.
377 :param pullrequestid: The pull request ID.
377 :type pullrequestid: int
378 :type pullrequestid: int
378 :param message: The text content of the comment.
379 :type message: str
380 :param status: (**Optional**) Set the approval status of the pull
381 request. Valid options are:
382 * not_reviewed
383 * approved
384 * rejected
385 * under_review
386 :type status: str
387 :param commit_id: Specify the commit_id for which to set a comment. If
379 :param commit_id: Specify the commit_id for which to set a comment. If
388 given commit_id is different than latest in the PR status
380 given commit_id is different than latest in the PR status
389 change won't be performed.
381 change won't be performed.
390 :type commit_id: str
382 :type commit_id: str
383 :param message: The text content of the comment.
384 :type message: str
385 :param status: (**Optional**) Set the approval status of the pull
386 request. One of: 'not_reviewed', 'approved', 'rejected',
387 'under_review'
388 :type status: str
389 :param comment_type: Comment type, one of: 'note', 'todo'
390 :type comment_type: Optional(str), default: 'note'
391 :param userid: Comment on the pull request as this user
391 :param userid: Comment on the pull request as this user
392 :type userid: Optional(str or int)
392 :type userid: Optional(str or int)
393
393
@@ -421,6 +421,7 b' def comment_pull_request(request, apiuse'
421 message = Optional.extract(message)
421 message = Optional.extract(message)
422 status = Optional.extract(status)
422 status = Optional.extract(status)
423 commit_id = Optional.extract(commit_id)
423 commit_id = Optional.extract(commit_id)
424 comment_type = Optional.extract(comment_type)
424
425
425 if not message and not status:
426 if not message and not status:
426 raise JSONRPCError(
427 raise JSONRPCError(
@@ -466,7 +467,8 b' def comment_pull_request(request, apiuse'
466 status_change=(status_label if status_change else None),
467 status_change=(status_label if status_change else None),
467 status_change_type=(status if status_change else None),
468 status_change_type=(status if status_change else None),
468 closing_pr=False,
469 closing_pr=False,
469 renderer=renderer
470 renderer=renderer,
471 comment_type=comment_type
470 )
472 )
471
473
472 if allowed_to_change_status and status:
474 if allowed_to_change_status and status:
@@ -36,7 +36,8 b' from rhodecode.lib.ext_json import json'
36 from rhodecode.model.changeset_status import ChangesetStatusModel
36 from rhodecode.model.changeset_status import ChangesetStatusModel
37 from rhodecode.model.comment import CommentsModel
37 from rhodecode.model.comment import CommentsModel
38 from rhodecode.model.db import (
38 from rhodecode.model.db import (
39 Session, ChangesetStatus, RepositoryField, Repository, RepoGroup)
39 Session, ChangesetStatus, RepositoryField, Repository, RepoGroup,
40 ChangesetComment)
40 from rhodecode.model.repo import RepoModel
41 from rhodecode.model.repo import RepoModel
41 from rhodecode.model.scm import ScmModel, RepoList
42 from rhodecode.model.scm import ScmModel, RepoList
42 from rhodecode.model.settings import SettingsModel, VcsSettingsModel
43 from rhodecode.model.settings import SettingsModel, VcsSettingsModel
@@ -1382,8 +1383,9 b' def lock(request, apiuser, repoid, locke'
1382
1383
1383 @jsonrpc_method()
1384 @jsonrpc_method()
1384 def comment_commit(
1385 def comment_commit(
1385 request, apiuser, repoid, commit_id, message,
1386 request, apiuser, repoid, commit_id, message, status=Optional(None),
1386 userid=Optional(OAttr('apiuser')), status=Optional(None)):
1387 comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE),
1388 userid=Optional(OAttr('apiuser'))):
1387 """
1389 """
1388 Set a commit comment, and optionally change the status of the commit.
1390 Set a commit comment, and optionally change the status of the commit.
1389
1391
@@ -1395,15 +1397,17 b' def comment_commit('
1395 :type commit_id: str
1397 :type commit_id: str
1396 :param message: The comment text.
1398 :param message: The comment text.
1397 :type message: str
1399 :type message: str
1400 :param status: (**Optional**) status of commit, one of: 'not_reviewed',
1401 'approved', 'rejected', 'under_review'
1402 :type status: str
1403 :param comment_type: Comment type, one of: 'note', 'todo'
1404 :type comment_type: Optional(str), default: 'note'
1398 :param userid: Set the user name of the comment creator.
1405 :param userid: Set the user name of the comment creator.
1399 :type userid: Optional(str or int)
1406 :type userid: Optional(str or int)
1400 :param status: status, one of 'not_reviewed', 'approved', 'rejected',
1401 'under_review'
1402 :type status: str
1403
1407
1404 Example error output:
1408 Example error output:
1405
1409
1406 .. code-block:: json
1410 .. code-block:: bash
1407
1411
1408 {
1412 {
1409 "id" : <id_given_in_input>,
1413 "id" : <id_given_in_input>,
@@ -1426,6 +1430,7 b' def comment_commit('
1426
1430
1427 user = get_user_or_error(userid)
1431 user = get_user_or_error(userid)
1428 status = Optional.extract(status)
1432 status = Optional.extract(status)
1433 comment_type = Optional.extract(comment_type)
1429
1434
1430 allowed_statuses = [x[0] for x in ChangesetStatus.STATUSES]
1435 allowed_statuses = [x[0] for x in ChangesetStatus.STATUSES]
1431 if status and status not in allowed_statuses:
1436 if status and status not in allowed_statuses:
@@ -1440,7 +1445,9 b' def comment_commit('
1440 message, repo, user, commit_id=commit_id,
1445 message, repo, user, commit_id=commit_id,
1441 status_change=status_change_label,
1446 status_change=status_change_label,
1442 status_change_type=status,
1447 status_change_type=status,
1443 renderer=renderer)
1448 renderer=renderer,
1449 comment_type=comment_type
1450 )
1444 if status:
1451 if status:
1445 # also do a status change
1452 # also do a status change
1446 try:
1453 try:
General Comments 0
You need to be logged in to leave comments. Login now