diff --git a/kallithea/controllers/admin/settings.py b/kallithea/controllers/admin/settings.py --- a/kallithea/controllers/admin/settings.py +++ b/kallithea/controllers/admin/settings.py @@ -104,24 +104,24 @@ class SettingsController(BaseController) force_defaults=False) try: - sett = Ui.get_by_key('push_ssl') + sett = Ui.get_by_key('web', 'push_ssl') sett.ui_value = form_result['web_push_ssl'] if c.visual.allow_repo_location_change: - sett = Ui.get_by_key('/') + sett = Ui.get_by_key('paths', '/') sett.ui_value = form_result['paths_root_path'] #HOOKS - sett = Ui.get_by_key(Ui.HOOK_UPDATE) + sett = Ui.get_by_key('hooks', Ui.HOOK_UPDATE) sett.ui_active = form_result['hooks_changegroup_update'] - sett = Ui.get_by_key(Ui.HOOK_REPO_SIZE) + sett = Ui.get_by_key('hooks', Ui.HOOK_REPO_SIZE) sett.ui_active = form_result['hooks_changegroup_repo_size'] - sett = Ui.get_by_key(Ui.HOOK_PUSH) + sett = Ui.get_by_key('hooks', Ui.HOOK_PUSH) sett.ui_active = form_result['hooks_changegroup_push_logger'] - sett = Ui.get_by_key(Ui.HOOK_PULL) + sett = Ui.get_by_key('hooks', Ui.HOOK_PULL) sett.ui_active = form_result['hooks_outgoing_pull_logger'] ## EXTENSIONS diff --git a/kallithea/controllers/forks.py b/kallithea/controllers/forks.py --- a/kallithea/controllers/forks.py +++ b/kallithea/controllers/forks.py @@ -62,7 +62,7 @@ class ForksController(BaseRepoController c.landing_revs_choices, c.landing_revs = ScmModel().get_repo_landing_revs() - c.can_update = Ui.get_by_key(Ui.HOOK_UPDATE).ui_active + c.can_update = Ui.get_by_key('hooks', Ui.HOOK_UPDATE).ui_active def __load_data(self, repo_name=None): """ @@ -164,7 +164,7 @@ class ForksController(BaseRepoController form_result = _form.to_python(dict(request.POST)) # an approximation that is better than nothing - if not Ui.get_by_key(Ui.HOOK_UPDATE).ui_active: + if not Ui.get_by_key('hooks', Ui.HOOK_UPDATE).ui_active: form_result['update_after_clone'] = False # create fork is done sometimes async on celery, db transaction diff --git a/kallithea/lib/base.py b/kallithea/lib/base.py --- a/kallithea/lib/base.py +++ b/kallithea/lib/base.py @@ -255,7 +255,7 @@ class BaseVCSController(object): and required True otherwise """ #check if we have SSL required ! if not it's a bad request ! - if str2bool(Ui.get_by_key('push_ssl').ui_value): + if str2bool(Ui.get_by_key('web', 'push_ssl').ui_value): org_proto = environ.get('wsgi._org_proto', environ['wsgi.url_scheme']) if org_proto != 'https': log.debug('proto is %s and SSL is required BAD REQUEST !', diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -351,14 +351,14 @@ class Ui(Base, BaseModel): ui_active = Column(Boolean(), nullable=False, default=True) @classmethod - def get_by_key(cls, key): + def get_by_key(cls, section, key): """ Return specified Ui object, or None if not found. """ - return cls.query().filter(cls.ui_key == key).scalar() + return cls.query().filter_by(ui_section=section, ui_key=key).scalar() @classmethod def get_or_create(cls, section, key): """ Return specified Ui object, creating it if necessary. """ - setting = cls.get_by_key(key) + setting = cls.get_by_key(section, key) if setting is None: setting = cls(ui_section=section, ui_key=key) Session().add(setting) @@ -370,6 +370,7 @@ class Ui(Base, BaseModel): q = q.filter(cls.ui_key.in_([cls.HOOK_UPDATE, cls.HOOK_REPO_SIZE, cls.HOOK_PUSH, cls.HOOK_PRE_PUSH, cls.HOOK_PULL, cls.HOOK_PRE_PULL])) + q = q.filter(cls.ui_section == 'hooks') return q.all() @classmethod @@ -383,7 +384,7 @@ class Ui(Base, BaseModel): @classmethod def get_repos_location(cls): - return cls.get_by_key('/').ui_value + return cls.get_by_key('paths', '/').ui_value @classmethod def create_or_update_hook(cls, key, val): diff --git a/kallithea/model/repo_group.py b/kallithea/model/repo_group.py --- a/kallithea/model/repo_group.py +++ b/kallithea/model/repo_group.py @@ -59,7 +59,7 @@ class RepoGroupModel(BaseModel): Gets the repositories root path from database """ - q = Ui.get_by_key('/') + q = Ui.get_by_key('paths', '/') return q.ui_value def _create_default_perms(self, new_group): diff --git a/kallithea/tests/functional/test_admin_settings.py b/kallithea/tests/functional/test_admin_settings.py --- a/kallithea/tests/functional/test_admin_settings.py +++ b/kallithea/tests/functional/test_admin_settings.py @@ -55,7 +55,7 @@ class TestAdminSettingsController(TestCo response.mustcontain('test_hooks_2') response.mustcontain('cd /tmp2') - hook_id = Ui.get_by_key('test_hooks_2').ui_id + hook_id = Ui.get_by_key('hooks', 'test_hooks_2').ui_id ## delete self.app.post(url('admin_settings_hooks'), params=dict(hook_id=hook_id, _authentication_token=self.authentication_token()))