##// END OF EJS Templates
2fa: recovery codes copy
2fa: recovery codes copy

File last commit:

r5095:aa627a5f default
r5361:965120af default
Show More
routes.py
241 lines | 10.7 KiB | text/x-python | PythonLexer
copyrights: updated for 2023
r5088 # Copyright (C) 2012-2023 RhodeCode GmbH
dan
integrations: add integration support...
r411 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import logging
pyramid: moved add_route_requirements into pyramid base app....
r1928 from rhodecode.apps._base import ADMIN_PREFIX, add_route_requirements
integrations: rewrote usage of pylons components inside integrations....
r1990 from rhodecode.lib.utils2 import safe_int
dan
integrations: add repo group integrations, fixes #4175
r667 from rhodecode.model.db import Repository, Integration, RepoGroup
dan
integrations: add integration support...
r411 from rhodecode.integrations import integration_type_registry
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 from rhodecode.integrations.views import GlobalIntegrationsView
from rhodecode.integrations.views import RepoGroupIntegrationsView
from rhodecode.integrations.views import RepoIntegrationsView
dan
integrations: add integration support...
r411
log = logging.getLogger(__name__)
dan
pyramid: fixed some deprecated calls.
r3099 class ValidIntegrationPredicate(object):
def __init__(self, val, config):
self.val = val
def text(self):
integrations: fixed code for python3
r5064 return f'valid_integration_route = {self.val}'
dan
pyramid: fixed some deprecated calls.
r3099
phash = text
def __call__(self, info, request):
integration_type = info['match']['integration']
integration_id = info['match'].get('integration_id')
if integration_type not in integration_type_registry:
return False
if integration_id:
if not safe_int(integration_id):
return False
integration = Integration.get(integration_id)
if not integration:
return False
if integration.integration_type != integration_type:
return False
# match types to repo or repo group
repo_name = info['match'].get('repo_name')
repo_group_name = info['match'].get('repo_group_name')
repo, repo_group = None, None
if repo_name:
repo = Repository.get_by_repo_name(repo_name)
if not repo:
return False
if repo_group_name:
repo_group = RepoGroup.get_by_group_name(repo_group_name)
if not repo_group:
return False
if repo and repo.repo_id != integration.repo_id:
return False
if repo_group and repo_group.group_id != integration.repo_group_id:
return False
return True
dan
integrations: add integration support...
r411 def includeme(config):
dan
pyramid: fixed some deprecated calls.
r3099 config.add_route_predicate(
'valid_integration', ValidIntegrationPredicate)
dan
integrations: add repo group integrations, fixes #4175
r667
# global integrations
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 config.add_route('global_integrations_new',
ADMIN_PREFIX + '/integrations/new')
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(GlobalIntegrationsView,
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 attr='new_integration',
templating: use .mako as extensions for template files.
r1282 renderer='rhodecode:templates/admin/integrations/new.mako',
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 request_method='GET',
route_name='global_integrations_new')
dan
integrations: add integration support...
r411 config.add_route('global_integrations_home',
ADMIN_PREFIX + '/integrations')
config.add_route('global_integrations_list',
ADMIN_PREFIX + '/integrations/{integration}')
for route_name in ['global_integrations_home', 'global_integrations_list']:
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(GlobalIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='integration_list',
templating: use .mako as extensions for template files.
r1282 renderer='rhodecode:templates/admin/integrations/list.mako',
dan
integrations: add integration support...
r411 request_method='GET',
route_name=route_name)
config.add_route('global_integrations_create',
ADMIN_PREFIX + '/integrations/{integration}/new',
dan
pyramid: fixed some deprecated calls.
r3099 valid_integration=True)
dan
integrations: add integration support...
r411 config.add_route('global_integrations_edit',
ADMIN_PREFIX + '/integrations/{integration}/{integration_id}',
dan
pyramid: fixed some deprecated calls.
r3099 valid_integration=True)
dan
integrations: refactor/cleanup + features, fixes #4181...
r731
dan
integrations: add integration support...
r411 for route_name in ['global_integrations_create', 'global_integrations_edit']:
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(GlobalIntegrationsView,
dan
integrations: add integration support...
r411 attr='settings_get',
templating: use .mako as extensions for template files.
r1282 renderer='rhodecode:templates/admin/integrations/form.mako',
dan
integrations: add integration support...
r411 request_method='GET',
route_name=route_name)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(GlobalIntegrationsView,
dan
integrations: add integration support...
r411 attr='settings_post',
templating: use .mako as extensions for template files.
r1282 renderer='rhodecode:templates/admin/integrations/form.mako',
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 request_method='POST',
route_name=route_name)
# repo group integrations
config.add_route('repo_group_integrations_home',
repo-groups: moved to pyramid
r2175 add_route_requirements('/{repo_group_name}/_settings/integrations'),
integrations: rewrote usage of pylons components inside integrations....
r1990 repo_group_route=True)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoGroupIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='integration_list',
renderer='rhodecode:templates/admin/integrations/list.mako',
request_method='GET',
route_name='repo_group_integrations_home')
dan
integrations: refactor/cleanup + features, fixes #4181...
r731
config.add_route('repo_group_integrations_new',
repo-groups: moved to pyramid
r2175 add_route_requirements('/{repo_group_name}/_settings/integrations/new'),
integrations: rewrote usage of pylons components inside integrations....
r1990 repo_group_route=True)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoGroupIntegrationsView,
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 attr='new_integration',
templating: use .mako as extensions for template files.
r1282 renderer='rhodecode:templates/admin/integrations/new.mako',
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 request_method='GET',
route_name='repo_group_integrations_new')
integrations: rewrote usage of pylons components inside integrations....
r1990 config.add_route('repo_group_integrations_list',
repo-groups: moved to pyramid
r2175 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}'),
integrations: rewrote usage of pylons components inside integrations....
r1990 repo_group_route=True,
dan
pyramid: fixed some deprecated calls.
r3099 valid_integration=True)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoGroupIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='integration_list',
renderer='rhodecode:templates/admin/integrations/list.mako',
request_method='GET',
route_name='repo_group_integrations_list')
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 config.add_route('repo_group_integrations_create',
repo-groups: moved to pyramid
r2175 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}/new'),
integrations: rewrote usage of pylons components inside integrations....
r1990 repo_group_route=True,
dan
pyramid: fixed some deprecated calls.
r3099 valid_integration=True)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoGroupIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='settings_get',
renderer='rhodecode:templates/admin/integrations/form.mako',
request_method='GET',
route_name='repo_group_integrations_create')
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoGroupIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='settings_post',
renderer='rhodecode:templates/admin/integrations/form.mako',
request_method='POST',
route_name='repo_group_integrations_create')
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 config.add_route('repo_group_integrations_edit',
repo-groups: moved to pyramid
r2175 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}/{integration_id}'),
integrations: rewrote usage of pylons components inside integrations....
r1990 repo_group_route=True,
dan
pyramid: fixed some deprecated calls.
r3099 valid_integration=True)
dan
integrations: add integration support...
r411
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoGroupIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='settings_get',
renderer='rhodecode:templates/admin/integrations/form.mako',
request_method='GET',
route_name='repo_group_integrations_edit')
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoGroupIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='settings_post',
renderer='rhodecode:templates/admin/integrations/form.mako',
request_method='POST',
route_name='repo_group_integrations_edit')
dan
integrations: add repo group integrations, fixes #4175
r667
# repo integrations
dan
integrations: add integration support...
r411 config.add_route('repo_integrations_home',
integrations: rewrote usage of pylons components inside integrations....
r1990 add_route_requirements('/{repo_name}/settings/integrations'),
repo_route=True)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='integration_list',
request_method='GET',
renderer='rhodecode:templates/admin/integrations/list.mako',
route_name='repo_integrations_home')
dan
integrations: add integration support...
r411
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 config.add_route('repo_integrations_new',
integrations: rewrote usage of pylons components inside integrations....
r1990 add_route_requirements('/{repo_name}/settings/integrations/new'),
repo_route=True)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoIntegrationsView,
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 attr='new_integration',
templating: use .mako as extensions for template files.
r1282 renderer='rhodecode:templates/admin/integrations/new.mako',
dan
integrations: refactor/cleanup + features, fixes #4181...
r731 request_method='GET',
route_name='repo_integrations_new')
integrations: rewrote usage of pylons components inside integrations....
r1990 config.add_route('repo_integrations_list',
add_route_requirements('/{repo_name}/settings/integrations/{integration}'),
repo_route=True,
dan
pyramid: fixed some deprecated calls.
r3099 valid_integration=True)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='integration_list',
request_method='GET',
renderer='rhodecode:templates/admin/integrations/list.mako',
route_name='repo_integrations_list')
dan
integrations: add integration support...
r411 config.add_route('repo_integrations_create',
integrations: rewrote usage of pylons components inside integrations....
r1990 add_route_requirements('/{repo_name}/settings/integrations/{integration}/new'),
repo_route=True,
dan
pyramid: fixed some deprecated calls.
r3099 valid_integration=True)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='settings_get',
renderer='rhodecode:templates/admin/integrations/form.mako',
request_method='GET',
route_name='repo_integrations_create')
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='settings_post',
renderer='rhodecode:templates/admin/integrations/form.mako',
request_method='POST',
route_name='repo_integrations_create')
dan
integrations: add integration support...
r411 config.add_route('repo_integrations_edit',
integrations: rewrote usage of pylons components inside integrations....
r1990 add_route_requirements('/{repo_name}/settings/integrations/{integration}/{integration_id}'),
repo_route=True,
dan
pyramid: fixed some deprecated calls.
r3099 valid_integration=True)
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='settings_get',
renderer='rhodecode:templates/admin/integrations/form.mako',
request_method='GET',
route_name='repo_integrations_edit')
application: not use config.scan(), and replace all @add_view decorator into a explicit add_view call for faster app start.
r4610 config.add_view(RepoIntegrationsView,
integrations: rewrote usage of pylons components inside integrations....
r1990 attr='settings_post',
renderer='rhodecode:templates/admin/integrations/form.mako',
request_method='POST',
route_name='repo_integrations_edit')