def fix_settings(self): """ Fixes kallithea settings adds ga_code key for google analytics """ hgsettings3 = Setting('ga_code', '') self.sa.add(hgsettings3) self.sa.commit()
def create_default_options(self, skip_existing=False): """Creates default settings""" for k, v, t in [('default_repo_enable_locking', False, 'bool'), ('default_repo_enable_downloads', False, 'bool'), ('default_repo_enable_statistics', False, 'bool'), ('default_repo_private', False, 'bool'), ('default_repo_type', 'hg', 'unicode')]: if skip_existing and Setting.get_by_name(k) is not None: log.debug('Skipping option %s', k) continue setting = Setting(k, v, t) self.sa.add(setting)
def create_auth_plugin_options(self, skip_existing=False): """ Create default auth plugin settings, and make it active :param skip_existing: """ for k, v, t in [('auth_plugins', 'kallithea.lib.auth_modules.auth_internal', 'list'), ('auth_internal_enabled', 'True', 'bool')]: if skip_existing and Setting.get_by_name(k) is not None: log.debug('Skipping option %s', k) continue setting = Setting(k, v, t) self.sa.add(setting)
def create_settings(self, repo_root_path): ui_config = [ ('paths', '/', repo_root_path, True), #('phases', 'publish', 'false', False) ('hooks', Ui.HOOK_UPDATE, 'hg update >&2', False), ('hooks', Ui.HOOK_REPO_SIZE, 'python:kallithea.lib.hooks.repo_size', True), ('extensions', 'largefiles', '', True), ('largefiles', 'usercache', os.path.join(repo_root_path, '.cache', 'largefiles'), True), ('extensions', 'hgsubversion', '', False), ('extensions', 'hggit', '', False), ] for ui_section, ui_key, ui_value, ui_active in ui_config: ui_conf = Ui( ui_section=ui_section, ui_key=ui_key, ui_value=ui_value, ui_active=ui_active) self.sa.add(ui_conf) settings = [ ('realm', 'Kallithea', 'unicode'), ('title', '', 'unicode'), ('ga_code', '', 'unicode'), ('show_public_icon', True, 'bool'), ('show_private_icon', True, 'bool'), ('stylify_metalabels', False, 'bool'), ('dashboard_items', 100, 'int'), # TODO: call it page_size ('admin_grid_items', 25, 'int'), ('show_version', True, 'bool'), ('use_gravatar', True, 'bool'), ('gravatar_url', User.DEFAULT_GRAVATAR_URL, 'unicode'), ('clone_uri_tmpl', Repository.DEFAULT_CLONE_URI, 'unicode'), ('clone_ssh_tmpl', Repository.DEFAULT_CLONE_SSH, 'unicode'), ] for key, val, type_ in settings: sett = Setting(key, val, type_) self.sa.add(sett) self.create_auth_plugin_options() self.create_default_options() log.info('Populated Ui and Settings defaults')
def create_settings(self, path): self.create_ui_settings(path) ui_config = [ ('web', 'push_ssl', 'false'), ('web', 'allow_archive', 'gz zip bz2'), ('web', 'allow_push', '*'), ('web', 'baseurl', '/'), ('paths', '/', path), #('phases', 'publish', 'false') ] for section, key, value in ui_config: ui_conf = Ui() setattr(ui_conf, 'ui_section', section) setattr(ui_conf, 'ui_key', key) setattr(ui_conf, 'ui_value', value) self.sa.add(ui_conf) settings = [ ('realm', 'Kallithea', 'unicode'), ('title', '', 'unicode'), ('ga_code', '', 'unicode'), ('show_public_icon', True, 'bool'), ('show_private_icon', True, 'bool'), ('stylify_metatags', False, 'bool'), ('dashboard_items', 100, 'int'), ('admin_grid_items', 25, 'int'), ('show_version', True, 'bool'), ('use_gravatar', True, 'bool'), ('gravatar_url', User.DEFAULT_GRAVATAR_URL, 'unicode'), ('clone_uri_tmpl', Repository.DEFAULT_CLONE_URI, 'unicode'), ('update_url', Setting.DEFAULT_UPDATE_URL, 'unicode'), ] for key, val, type_ in settings: sett = Setting(key, val, type_) self.sa.add(sett) self.create_auth_plugin_options() self.create_default_options() log.info('created ui config')