Beispiel #1
0
def user_fields(request):
    """Return user fields"""
    # username_available = Validator('taken', valid_username(db))
    # not_registered = Validator('already registered', email_unknown_test)

    personal_fields = f.Section(
        'Personal',
        [
            f.TextField('First Name', v.required, v.valid_name),
            f.TextField('Last Name', v.required, v.valid_name),
            # f.TextField('Email', v.required, v.valid_email, not_registered(request)),
            f.EmailField('Email', v.required, v.valid_email),
            f.PhoneField('Phone', v.valid_phone, hint='optional'),
        ])

    if request.route[-1] == 'new':
        account_fields = f.Section('Account', [
            f.TextField('Username', v.required, v.valid_username),
            f.CheckboxField('Send invitation'),
        ])
    else:
        account_fields = f.Section('Account', [
            f.TextField('Username', v.required, v.valid_username),
        ])

    security_fields = f.Section('Security', [
        UserGroupsField('Groups',
                        name='memberships',
                        default=[2],
                        options=model.get_user_group_options(request.site))
    ])

    return f.Fields(personal_fields, account_fields, security_fields)
Beispiel #2
0
def user_fields(request):
    # username_available = Validator('taken', valid_username(db))
    # not_registered = Validator('already registered', email_unknown_test)

    personal_fields = f.Section(
        'Personal',
        [
            f.TextField('First Name', v.required, v.valid_name),
            f.TextField('Last Name', v.required, v.valid_name),
            # f.TextField('Email', v.required, v.valid_email, not_registered(request)),
            f.EmailField('Email', v.required, v.valid_email),
            f.PhoneField('Phone', v.valid_phone, hint='optional'),
        ])

    account_fields = f.Section(
        'Account',
        [
            # f.TextField('Username', v.required, v.valid_username, username_available(request)),
            f.TextField('Username', v.required, v.valid_username),
        ])

    security_fields = f.Section('Security', [
        UserGroupsField('Groups',
                        default=['2'],
                        options=model.get_user_group_options(request.site))
    ])

    return f.Fields(personal_fields, account_fields, security_fields)
Beispiel #3
0
def group_fields(request):

    user_groups = model.get_user_group_options(request.site)

    fields = f.Fields([
        f.TextField('Name', v.required, v.valid_name),
        f.TextField('Description', maxlength=60),
        f.PulldownField(
            'Administrators',
            default='administrators',
            name='admin_group_id',
            options=user_groups
        ),
    ])

    db = request.site.db
    admin = model.AdminModel(db)

    if len(request.route) > 2 and request.route[2] not in ['new', 'clear', 'reindex']:
        group_id = int(request.route[2])
    else:
        group_id = None

    include_fields = f.Section('Includes',[
        SelectionField('Subgroups', options=admin.get_subgroup_options(group_id)),
        SelectionField('Users', options=admin.get_user_options()),
    ])

    access_fields = f.Section('Accesses',[
        SelectionField('Roles', options=admin.get_role_options(group_id)),
        SelectionField('Apps', options=admin.get_app_options(group_id)),
    ])

    return f.Fields(fields, include_fields, access_fields)