##// END OF EJS Templates
reviewers: moved the new v1 api of default reviewers into pyramid view....
marcink -
r1767:dee6c9db default
parent child Browse files
Show More
@@ -94,6 +94,10 b' def includeme(config):'
94 94 name='repo_reviewers',
95 95 pattern='/{repo_name:.*?[^/]}/settings/review/rules', repo_route=True)
96 96
97 config.add_route(
98 name='repo_default_reviewers_data',
99 pattern='/{repo_name:.*?[^/]}/settings/review/default-reviewers', repo_route=True)
100
97 101 # Maintenance
98 102 config.add_route(
99 103 name='repo_maintenance',
@@ -23,6 +23,7 b' import logging'
23 23 from pyramid.view import view_config
24 24
25 25 from rhodecode.apps._base import RepoAppView
26 from rhodecode.controllers import utils
26 27 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 28
28 29 log = logging.getLogger(__name__)
@@ -49,3 +50,20 b' class RepoReviewRulesView(RepoAppView):'
49 50
50 51 return self._get_template_context(c)
51 52
53 @LoginRequired()
54 @HasRepoPermissionAnyDecorator(
55 'repository.read', 'repository.write', 'repository.admin')
56 @view_config(
57 route_name='repo_default_reviewers_data', request_method='GET',
58 renderer='json_ext')
59 def repo_default_reviewers_data(self):
60 reasons = ['Default reviewer', 'Repository owner']
61 default = utils.reviewer_as_json(
62 user=self.db_repo.user, reasons=reasons, mandatory=False)
63
64 return {
65 'api_ver': 'v1', # define version for later possible schema upgrade
66 'reviewers': [default],
67 'rules': {},
68 'rules_data': {},
69 }
@@ -623,9 +623,6 b' def make_map(config):'
623 623 rmap.connect('repo_refs_changelog_data', '/{repo_name}/refs-data-changelog',
624 624 controller='summary', action='repo_refs_changelog_data',
625 625 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
626 rmap.connect('repo_default_reviewers_data', '/{repo_name}/default-reviewers',
627 controller='summary', action='repo_default_reviewers_data',
628 jsroute=True, requirements=URL_NAME_REQUIREMENTS)
629 626
630 627 rmap.connect('changeset_home', '/{repo_name}/changeset/{revision}',
631 628 controller='changeset', revision='tip',
@@ -27,7 +27,7 b' from string import lower'
27 27
28 28 from pylons import tmpl_context as c, request
29 29 from pylons.i18n.translation import _
30 from beaker.cache import cache_region, region_invalidate
30 from beaker.cache import cache_region
31 31
32 32 from rhodecode.config.conf import (LANGUAGES_EXTENSIONS_MAP)
33 33 from rhodecode.controllers import utils
@@ -36,13 +36,12 b' from rhodecode.lib import caches, helper'
36 36 from rhodecode.lib.utils import jsonify
37 37 from rhodecode.lib.utils2 import safe_str
38 38 from rhodecode.lib.auth import (
39 LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous, XHRRequired)
39 LoginRequired, HasRepoPermissionAnyDecorator, XHRRequired)
40 40 from rhodecode.lib.base import BaseRepoController, render
41 41 from rhodecode.lib.markup_renderer import MarkupRenderer, relative_links
42 42 from rhodecode.lib.ext_json import json
43 43 from rhodecode.lib.vcs.backends.base import EmptyCommit
44 from rhodecode.lib.vcs.exceptions import (
45 CommitError, EmptyRepositoryError, NodeDoesNotExistError)
44 from rhodecode.lib.vcs.exceptions import CommitError, EmptyRepositoryError
46 45 from rhodecode.model.db import Statistics, CacheKey, User
47 46 from rhodecode.model.repo import ReadmeFinder
48 47
@@ -259,16 +258,6 b' class SummaryController(BaseRepoControll'
259 258 }
260 259 return data
261 260
262 @LoginRequired()
263 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
264 'repository.admin')
265 @jsonify
266 def repo_default_reviewers_data(self, repo_name):
267 return {
268 'reviewers': [utils.reviewer_as_json(
269 user=c.rhodecode_db_repo.user, reasons=None)]
270 }
271
272 261 @jsonify
273 262 def repo_refs_changelog_data(self, repo_name):
274 263 repo = c.rhodecode_repo
@@ -89,17 +89,19 b' def get_commit_from_ref_name(repo, ref_n'
89 89 return repo_scm.get_commit(commit_id)
90 90
91 91
92 def reviewer_as_json(user, reasons):
92 def reviewer_as_json(user, reasons, mandatory):
93 93 """
94 94 Returns json struct of a reviewer for frontend
95 95
96 96 :param user: the reviewer
97 97 :param reasons: list of strings of why they are reviewers
98 :param mandatory: bool, to set user as mandatory
98 99 """
99 100
100 101 return {
101 102 'user_id': user.user_id,
102 103 'reasons': reasons,
104 'mandatory': mandatory,
103 105 'username': user.username,
104 106 'firstname': user.firstname,
105 107 'lastname': user.lastname,
@@ -21,7 +21,6 b' function registerRCRoutes() {'
21 21 pyroutes.register('repo_stats', '/%(repo_name)s/repo_stats/%(commit_id)s', ['repo_name', 'commit_id']);
22 22 pyroutes.register('repo_refs_data', '/%(repo_name)s/refs-data', ['repo_name']);
23 23 pyroutes.register('repo_refs_changelog_data', '/%(repo_name)s/refs-data-changelog', ['repo_name']);
24 pyroutes.register('repo_default_reviewers_data', '/%(repo_name)s/default-reviewers', ['repo_name']);
25 24 pyroutes.register('changeset_home', '/%(repo_name)s/changeset/%(revision)s', ['repo_name', 'revision']);
26 25 pyroutes.register('changeset_comment', '/%(repo_name)s/changeset/%(revision)s/comment', ['repo_name', 'revision']);
27 26 pyroutes.register('changeset_comment_preview', '/%(repo_name)s/changeset/comment/preview', ['repo_name']);
@@ -116,6 +115,7 b' function registerRCRoutes() {'
116 115 pyroutes.register('edit_repo_caches', '/%(repo_name)s/settings/caches', ['repo_name']);
117 116 pyroutes.register('edit_repo_perms', '/%(repo_name)s/settings/permissions', ['repo_name']);
118 117 pyroutes.register('repo_reviewers', '/%(repo_name)s/settings/review/rules', ['repo_name']);
118 pyroutes.register('repo_default_reviewers_data', '/%(repo_name)s/settings/review/default-reviewers', ['repo_name']);
119 119 pyroutes.register('repo_maintenance', '/%(repo_name)s/settings/maintenance', ['repo_name']);
120 120 pyroutes.register('repo_maintenance_execute', '/%(repo_name)s/settings/maintenance/execute', ['repo_name']);
121 121 pyroutes.register('strip', '/%(repo_name)s/settings/strip', ['repo_name']);
General Comments 0
You need to be logged in to leave comments. Login now