Esempio n. 1
0
    class _RepoForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = False
        repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
                        v.SlugifyName())
        repo_group = All(v.CanWriteGroup(old_data),
                         v.OneOf(repo_group_ids, hideList=True),
                         v.Int(min=-1, not_empty=True))
        repo_type = v.OneOf(supported_backends,
                            required=False,
                            if_missing=old_data.get('repo_type'))
        repo_description = v.UnicodeString(strip=True, min=1, not_empty=False)
        repo_private = v.StringBoolean(if_missing=False)
        repo_landing_rev = v.OneOf(landing_revs, hideList=True)
        repo_copy_permissions = v.StringBoolean(if_missing=False)
        clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))

        repo_enable_statistics = v.StringBoolean(if_missing=False)
        repo_enable_downloads = v.StringBoolean(if_missing=False)
        repo_enable_locking = v.StringBoolean(if_missing=False)

        if edit:
            owner = All(v.UnicodeString(not_empty=True), v.ValidRepoUser())
            # Not a real field - just for reference for validation:
            # clone_uri_hidden = v.UnicodeString(if_missing='')

        chained_validators = [
            v.ValidCloneUri(),
            v.ValidRepoName(edit, old_data)
        ]
Esempio n. 2
0
 class _RepoForkForm(formencode.Schema):
     allow_extra_fields = True
     filter_extra_fields = False
     repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
                     v.SlugifyName())
     repo_group = All(v.CanWriteGroup(),
                      v.OneOf(repo_group_ids, hideList=True),
                      v.Int(min=-1, not_empty=True))
     repo_type = All(v.ValidForkType(old_data), v.OneOf(supported_backends))
     description = v.UnicodeString(strip=True, min=1, not_empty=True)
     private = v.StringBoolean(if_missing=False)
     copy_permissions = v.StringBoolean(if_missing=False)
     update_after_clone = v.StringBoolean(if_missing=False)
     fork_parent_id = v.UnicodeString()
     chained_validators = [v.ValidForkName(edit, old_data)]
     landing_rev = v.OneOf(landing_revs, hideList=True)
Esempio n. 3
0
    class _RepoGroupForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = False

        group_name = All(
            v.UnicodeString(strip=True, min=1, not_empty=True),
            v.SlugifyName(),
            v.ValidRegex(
                msg=_('Name must not contain only digits'))(r'(?!^\d+$)^.+$'))
        group_description = v.UnicodeString(strip=True, min=1, not_empty=False)
        group_copy_permissions = v.StringBoolean(if_missing=False)

        if edit:
            #FIXME: do a special check that we cannot move a group to one of
            #its children
            pass

        parent_group_id = All(
            v.CanCreateGroup(can_create_in_root),
            v.OneOf(repo_group_ids,
                    hideList=False,
                    testValueList=True,
                    if_missing=None,
                    not_empty=True), v.Int(min=-1, not_empty=True))
        enable_locking = v.StringBoolean(if_missing=False)
        chained_validators = [v.ValidRepoGroup(edit, old_data)]
Esempio n. 4
0
 class _DefaultsForm(formencode.Schema):
     allow_extra_fields = True
     filter_extra_fields = True
     default_repo_type = v.OneOf(supported_backends)
     default_repo_private = v.StringBoolean(if_missing=False)
     default_repo_enable_statistics = v.StringBoolean(if_missing=False)
     default_repo_enable_downloads = v.StringBoolean(if_missing=False)
Esempio n. 5
0
 class _LdapSettingsForm(formencode.Schema):
     allow_extra_fields = True
     filter_extra_fields = True
     #pre_validators = [LdapLibValidator]
     ldap_active = v.StringBoolean(if_missing=False)
     ldap_host = v.UnicodeString(strip=True, )
     ldap_port = v.Number(strip=True, )
     ldap_tls_kind = v.OneOf(tls_kind_choices)
     ldap_tls_reqcert = v.OneOf(tls_reqcert_choices)
     ldap_dn_user = v.UnicodeString(strip=True, )
     ldap_dn_pass = v.UnicodeString(strip=True, )
     ldap_base_dn = v.UnicodeString(strip=True, )
     ldap_filter = v.UnicodeString(strip=True, )
     ldap_search_scope = v.OneOf(search_scope_choices)
     ldap_attr_login = v.AttrLoginValidator()(not_empty=True)
     ldap_attr_firstname = v.UnicodeString(strip=True, )
     ldap_attr_lastname = v.UnicodeString(strip=True, )
     ldap_attr_email = v.UnicodeString(strip=True, )
Esempio n. 6
0
    class _RepoFieldForm(formencode.Schema):
        filter_extra_fields = True
        allow_extra_fields = True

        new_field_key = All(v.FieldKey(),
                            v.UnicodeString(strip=True, min=3, not_empty=True))
        new_field_value = v.UnicodeString(not_empty=False, if_missing='')
        new_field_type = v.OneOf(['str', 'unicode', 'list', 'tuple'],
                                 if_missing='str')
        new_field_label = v.UnicodeString(not_empty=False)
        new_field_desc = v.UnicodeString(not_empty=False)
Esempio n. 7
0
    class _GistForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = True

        filename = All(v.BasePath()(),
                       v.UnicodeString(strip=True, required=False))
        description = v.UnicodeString(required=False, if_missing=u'')
        lifetime = v.OneOf(lifetime_options)
        mimetype = v.UnicodeString(required=False, if_missing=None)
        content = v.UnicodeString(required=True, not_empty=True)
        public = v.UnicodeString(required=False, if_missing=u'')
        private = v.UnicodeString(required=False, if_missing=u'')
Esempio n. 8
0
    class _DefaultPermissionsForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = True
        overwrite_default_repo = v.StringBoolean(if_missing=False)
        overwrite_default_group = v.StringBoolean(if_missing=False)
        overwrite_default_user_group = v.StringBoolean(if_missing=False)
        anonymous = v.StringBoolean(if_missing=False)
        default_repo_perm = v.OneOf(repo_perms_choices)
        default_group_perm = v.OneOf(group_perms_choices)
        default_user_group_perm = v.OneOf(user_group_perms_choices)

        default_repo_create = v.OneOf(create_choices)
        create_on_write = v.OneOf(create_on_write_choices)
        default_user_group_create = v.OneOf(user_group_create_choices)
        #default_repo_group_create = v.OneOf(repo_group_create_choices) #not impl. yet
        default_fork = v.OneOf(fork_choices)

        default_register = v.OneOf(register_choices)
        default_extern_activate = v.OneOf(extern_activate_choices)
Esempio n. 9
0
    class _UserGroupForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = True

        users_group_name = All(
            v.UnicodeString(strip=True, min=1, not_empty=True),
            v.ValidUserGroup(edit, old_data))
        user_group_description = v.UnicodeString(strip=True,
                                                 min=1,
                                                 not_empty=False)

        users_group_active = v.StringBoolean(if_missing=False)

        if edit:
            users_group_members = v.OneOf(available_members,
                                          hideList=False,
                                          testValueList=True,
                                          if_missing=None,
                                          not_empty=False)
Esempio n. 10
0
 class _RepoGroupPermsForm(formencode.Schema):
     allow_extra_fields = True
     filter_extra_fields = False
     recursive = v.OneOf(valid_recursive_choices)
     chained_validators = [v.ValidPerms(type_='repo_group')]