當前位置: 首頁>>代碼示例>>Python>>正文


Python db.RhodeCodeSetting類代碼示例

本文整理匯總了Python中rhodecode.model.db.RhodeCodeSetting的典型用法代碼示例。如果您正苦於以下問題:Python RhodeCodeSetting類的具體用法?Python RhodeCodeSetting怎麽用?Python RhodeCodeSetting使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了RhodeCodeSetting類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_update

    def test_update(self):
        self.log_user()
        params = {
            'default_repo_enable_locking': True,
            'default_repo_enable_downloads': True,
            'default_repo_enable_statistics': True,
            'default_repo_private': True,
            'default_repo_type': 'hg',
        }
        response = self.app.put(url('default', id='default'), params=params)
        self.checkSessionFlash(response, 'Default settings updated successfully')
        defs = RhodeCodeSetting.get_default_repo_settings()
        self.assertEqual(params, defs)

        params = {
            'default_repo_enable_locking': False,
            'default_repo_enable_downloads': False,
            'default_repo_enable_statistics': False,
            'default_repo_private': False,
            'default_repo_type': 'git',
        }
        response = self.app.put(url('default', id='default'), params=params)
        self.checkSessionFlash(response, 'Default settings updated successfully')
        defs = RhodeCodeSetting.get_default_repo_settings()
        self.assertEqual(params, defs)
開發者ID:adamscieszko,項目名稱:rhodecode,代碼行數:25,代碼來源:test_admin_defaults.py

示例2: create_repository

    def create_repository(self):
        """GET /_admin/create_repository: Form to create a new item"""
        new_repo = request.GET.get('repo', '')
        parent_group = request.GET.get('parent_group')
        if not HasPermissionAny('hg.admin', 'hg.create.repository')():
            #you're not super admin nor have global create permissions,
            #but maybe you have at least write permission to a parent group ?
            _gr = RepoGroup.get(parent_group)
            gr_name = _gr.group_name if _gr else None
            if not HasReposGroupPermissionAny('group.admin', 'group.write')(group_name=gr_name):
                raise HTTPForbidden

        acl_groups = GroupList(RepoGroup.query().all(),
                               perm_set=['group.write', 'group.admin'])
        c.repo_groups = RepoGroup.groups_choices(groups=acl_groups)
        c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
        choices, c.landing_revs = ScmModel().get_repo_landing_revs()

        c.new_repo = repo_name_slug(new_repo)

        ## apply the defaults from defaults page
        defaults = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
        if parent_group:
            defaults.update({'repo_group': parent_group})

        return htmlfill.render(
            render('admin/repos/repo_add.html'),
            defaults=defaults,
            errors={},
            prefix_error=False,
            encoding="UTF-8"
        )
開發者ID:jeffjirsa,項目名稱:rhodecode,代碼行數:32,代碼來源:repos.py

示例3: test_ldap_save_settings

    def test_ldap_save_settings(self):
        self.log_user()
        if skip_ldap_test:
            raise SkipTest("skipping due to missing ldap lib")

        test_url = url(controller="admin/ldap_settings", action="ldap_settings")

        response = self.app.post(
            url=test_url,
            params={
                "ldap_host": u"dc.example.com",
                "ldap_port": "999",
                "ldap_tls_kind": "PLAIN",
                "ldap_tls_reqcert": "NEVER",
                "ldap_dn_user": "test_user",
                "ldap_dn_pass": "test_pass",
                "ldap_base_dn": "test_base_dn",
                "ldap_filter": "test_filter",
                "ldap_search_scope": "BASE",
                "ldap_attr_login": "test_attr_login",
                "ldap_attr_firstname": "ima",
                "ldap_attr_lastname": "tester",
                "ldap_attr_email": "[email protected]",
            },
        )

        new_settings = RhodeCodeSetting.get_ldap_settings()
        print new_settings
        self.assertEqual(new_settings["ldap_host"], u"dc.example.com", "fail db write compare")

        self.checkSessionFlash(response, "Ldap settings updated successfully")
開發者ID:seacoastboy,項目名稱:rhodecode,代碼行數:31,代碼來源:test_admin_ldap_settings.py

示例4: create

    def create(self, form_data, cur_user, just_db=False, fork=None):
        """
        Backward compatibility function, just a wrapper on top of create_repo

        :param form_data:
        :param cur_user:
        :param just_db:
        :param fork:
        """
        owner = cur_user
        repo_name = form_data['repo_name_full']
        repo_type = form_data['repo_type']
        description = form_data['repo_description']
        private = form_data['repo_private']
        clone_uri = form_data.get('clone_uri')
        repos_group = form_data['repo_group']
        landing_rev = form_data['repo_landing_rev']
        copy_fork_permissions = form_data.get('copy_permissions')
        fork_of = form_data.get('fork_parent_id')

        ## repo creation defaults, private and repo_type are filled in form
        defs = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
        enable_statistics = defs.get('repo_enable_statistics')
        enable_locking = defs.get('repo_enable_locking')
        enable_downloads = defs.get('repo_enable_downloads')

        return self.create_repo(
            repo_name, repo_type, description, owner, private, clone_uri,
            repos_group, landing_rev, just_db, fork_of, copy_fork_permissions,
            enable_statistics, enable_locking, enable_downloads
        )
開發者ID:greenboxindonesia,項目名稱:rhodecode,代碼行數:31,代碼來源:repo.py

示例5: test_ldap_save_settings

    def test_ldap_save_settings(self):
        self.log_user()
        if skip_ldap_test:
            raise SkipTest('skipping due to missing ldap lib')

        test_url = url(controller='admin/ldap_settings',
                       action='ldap_settings')

        response = self.app.post(url=test_url,
            params={'ldap_host' : u'dc.example.com',
                    'ldap_port' : '999',
                    'ldap_tls_kind' : 'PLAIN',
                    'ldap_tls_reqcert' : 'NEVER',
                    'ldap_dn_user':'test_user',
                    'ldap_dn_pass':'test_pass',
                    'ldap_base_dn':'test_base_dn',
                    'ldap_filter':'test_filter',
                    'ldap_search_scope':'BASE',
                    'ldap_attr_login':'test_attr_login',
                    'ldap_attr_firstname':'ima',
                    'ldap_attr_lastname':'tester',
                    'ldap_attr_email':'[email protected]' })

        new_settings = RhodeCodeSetting.get_ldap_settings()
        self.assertEqual(new_settings['ldap_host'], u'dc.example.com',
                         'fail db write compare')

        self.checkSessionFlash(response,
                               'Ldap settings updated successfully')
開發者ID:break123,項目名稱:rhodecode,代碼行數:29,代碼來源:test_admin_ldap_settings.py

示例6: __before__

    def __before__(self):
        c.rhodecode_version = __version__
        c.rhodecode_instanceid = config.get('instance_id')
        c.rhodecode_name = config.get('rhodecode_title')
        c.use_gravatar = str2bool(config.get('use_gravatar'))
        c.ga_code = config.get('rhodecode_ga_code')
        # Visual options
        c.visual = AttributeDict({})
        rc_config = RhodeCodeSetting.get_app_settings()

        c.visual.show_public_icon = str2bool(rc_config.get('rhodecode_show_public_icon'))
        c.visual.show_private_icon = str2bool(rc_config.get('rhodecode_show_private_icon'))
        c.visual.stylify_metatags = str2bool(rc_config.get('rhodecode_stylify_metatags'))
        c.visual.lightweight_dashboard = str2bool(rc_config.get('rhodecode_lightweight_dashboard'))
        c.visual.lightweight_dashboard_items = safe_int(config.get('dashboard_items', 100))

        c.repo_name = get_repo_slug(request)
        c.backends = BACKENDS.keys()
        c.unread_notifications = NotificationModel()\
                        .get_unread_cnt_for_user(c.rhodecode_user.user_id)
        self.cut_off_limit = int(config.get('cut_off_limit'))

        self.sa = meta.Session
        self.scm_model = ScmModel(self.sa)
        self.ip_addr = ''
開發者ID:break123,項目名稱:rhodecode,代碼行數:25,代碼來源:base.py

示例7: create_ldap_options

    def create_ldap_options(self, skip_existing=False):
        """Creates ldap settings"""

        for k, v in [
            ("ldap_active", "false"),
            ("ldap_host", ""),
            ("ldap_port", "389"),
            ("ldap_tls_kind", "PLAIN"),
            ("ldap_tls_reqcert", ""),
            ("ldap_dn_user", ""),
            ("ldap_dn_pass", ""),
            ("ldap_base_dn", ""),
            ("ldap_filter", ""),
            ("ldap_search_scope", ""),
            ("ldap_attr_login", ""),
            ("ldap_attr_firstname", ""),
            ("ldap_attr_lastname", ""),
            ("ldap_attr_email", ""),
        ]:

            if skip_existing and RhodeCodeSetting.get_by_name(k) != None:
                log.debug("Skipping option %s" % k)
                continue
            setting = RhodeCodeSetting(k, v)
            self.sa.add(setting)
開發者ID:yujiro,項目名稱:rhodecode,代碼行數:25,代碼來源:db_manage.py

示例8: __before__

    def __before__(self):
        """
        __before__ is called before controller methods and after __call__
        """
        c.rhodecode_version = __version__
        c.rhodecode_instanceid = config.get('instance_id')
        c.rhodecode_name = config.get('rhodecode_title')
        c.use_gravatar = str2bool(config.get('use_gravatar'))
        c.ga_code = config.get('rhodecode_ga_code')
        # Visual options
        c.visual = AttributeDict({})
        rc_config = RhodeCodeSetting.get_app_settings()
        ## DB stored
        c.visual.show_public_icon = str2bool(rc_config.get('rhodecode_show_public_icon'))
        c.visual.show_private_icon = str2bool(rc_config.get('rhodecode_show_private_icon'))
        c.visual.stylify_metatags = str2bool(rc_config.get('rhodecode_stylify_metatags'))
        c.visual.dashboard_items = safe_int(rc_config.get('rhodecode_dashboard_items', 100))
        c.visual.repository_fields = str2bool(rc_config.get('rhodecode_repository_fields'))
        c.visual.show_version = str2bool(rc_config.get('rhodecode_show_version'))

        ## INI stored
        self.cut_off_limit = int(config.get('cut_off_limit'))
        c.visual.allow_repo_location_change = str2bool(config.get('allow_repo_location_change', True))

        c.repo_name = get_repo_slug(request)  # can be empty
        c.backends = BACKENDS.keys()
        c.unread_notifications = NotificationModel()\
                        .get_unread_cnt_for_user(c.rhodecode_user.user_id)
        self.sa = meta.Session
        self.scm_model = ScmModel(self.sa)
開發者ID:greenboxindonesia,項目名稱:rhodecode,代碼行數:30,代碼來源:base.py

示例9: update

    def update(self, id):
        """PUT /defaults/id: Update an existing item"""
        # Forms posted to this method should contain a hidden field:
        #    <input type="hidden" name="_method" value="PUT" />
        # Or using helpers:
        #    h.form(url('default', id=ID),
        #           method='put')
        # url('default', id=ID)

        _form = DefaultsForm()()

        try:
            form_result = _form.to_python(dict(request.POST))
            for k, v in form_result.iteritems():
                setting = RhodeCodeSetting.get_by_name_or_create(k)
                setting.app_settings_value = v
                Session().add(setting)
            Session().commit()
            h.flash(_('Default settings updated successfully'),
                    category='success')

        except formencode.Invalid, errors:
            defaults = errors.value

            return htmlfill.render(
                render('admin/defaults/defaults.html'),
                defaults=defaults,
                errors=errors.error_dict or {},
                prefix_error=False,
                encoding="UTF-8")
開發者ID:adamscieszko,項目名稱:rhodecode,代碼行數:30,代碼來源:defaults.py

示例10: set_rhodecode_config

def set_rhodecode_config(config):
    """
    Updates pylons config with new settings from database

    :param config:
    """
    hgsettings = RhodeCodeSetting.get_app_settings()

    for k, v in hgsettings.items():
        config[k] = v
開發者ID:break123,項目名稱:rhodecode,代碼行數:10,代碼來源:utils.py

示例11: index

    def index(self):
        defaults = RhodeCodeSetting.get_ldap_settings()
        c.search_scope_cur = defaults.get('ldap_search_scope')
        c.tls_reqcert_cur = defaults.get('ldap_tls_reqcert')
        c.tls_kind_cur = defaults.get('ldap_tls_kind')

        return htmlfill.render(
                    render('admin/ldap/ldap.html'),
                    defaults=defaults,
                    encoding="UTF-8",
                    force_defaults=True,)
開發者ID:adamscieszko,項目名稱:rhodecode,代碼行數:11,代碼來源:ldap_settings.py

示例12: index

    def index(self, format='html'):
        """GET /defaults: All items in the collection"""
        # url('defaults')
        c.backends = BACKENDS.keys()
        defaults = RhodeCodeSetting.get_default_repo_settings()

        return htmlfill.render(
            render('admin/defaults/defaults.html'),
            defaults=defaults,
            encoding="UTF-8",
            force_defaults=False
        )
開發者ID:adamscieszko,項目名稱:rhodecode,代碼行數:12,代碼來源:defaults.py

示例13: index

    def index(self, format='html'):
        """GET /admin/settings: All items in the collection"""
        # url('admin_settings')

        defaults = RhodeCodeSetting.get_app_settings()
        defaults.update(self.get_hg_ui_settings())

        return htmlfill.render(
            render('admin/settings/settings.html'),
            defaults=defaults,
            encoding="UTF-8",
            force_defaults=False
        )
開發者ID:elfixit,項目名稱:rhodecode,代碼行數:13,代碼來源:settings.py

示例14: new

 def new(self, format='html'):
     """GET /repos/new: Form to create a new item"""
     new_repo = request.GET.get('repo', '')
     c.new_repo = repo_name_slug(new_repo)
     self.__load_defaults()
     ## apply the defaults from defaults page
     defaults = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
     return htmlfill.render(
         render('admin/repos/repo_add.html'),
         defaults=defaults,
         errors={},
         prefix_error=False,
         encoding="UTF-8"
     )
開發者ID:break123,項目名稱:rhodecode,代碼行數:14,代碼來源:repos.py

示例15: create_default_options

    def create_default_options(self, skip_existing=False):
        """Creates default settings"""

        for k, v in [
            ('default_repo_enable_locking',  False),
            ('default_repo_enable_downloads', False),
            ('default_repo_enable_statistics', False),
            ('default_repo_private', False),
            ('default_repo_type', 'hg')]:

            if skip_existing and RhodeCodeSetting.get_by_name(k) != None:
                log.debug('Skipping option %s' % k)
                continue
            setting = RhodeCodeSetting(k, v)
            self.sa.add(setting)
開發者ID:break123,項目名稱:rhodecode,代碼行數:15,代碼來源:db_manage.py


注:本文中的rhodecode.model.db.RhodeCodeSetting類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。