示例#1
0
def add_role():
    form = AddRoleForm()
    if form.validate_on_submit():
        if not current_user.check_password(form.current_password.data):
            form.current_password.errors.append('Your password is incorrect')
        else:
            role = Role.find_byname(form.role_name.data)
            if role is not None:
                form.role_name.errors.append('this role already exists')
            else:
                Role.add(form.role_name.data)
    return render_template('accounts/addrole.html', form=form)
示例#2
0
def add():
    # create org
    org_name = request.form['org_name']
    org = controller.addOrg(org_name)

    # create roles and assign admin rights to creating user
    Role.add(org.get_resource() + '_admin')
    Role.add(org.get_resource() + '_user')
    current_user.add_to_role(role_name=org.get_resource() + '_admin')
    current_user.add_to_role(role_name=org.get_resource() + '_user')

    # return html
    return redirect(url_for('organization_api.all'))
示例#3
0
def init():
    handler = pugsql.module('assets/sql')
    handler.connect('sqlite:///memory')
    settings.sql = handler

    # Create table if they don't exist
    handler.org_create()
    handler.user_create()
    handler.prof_create()
    handler.fund_create()
    handler.stat_create()
    handler.value_create()
    handler.role_create()
    handler.role_user_create()

    # Add test rows if they don't exist
    org = handler.org_find(id=1)
    if (org == None):
        org = Organization.add('Test Company')
        admin = User.add('admin', 'test123')
        guest = User.add('guest', 'test123')
        admin_role = Role.add('admin')
        admin.add_to_role(role_id=admin_role.id)
        profile = Profile.add('Test Profile', org.id)
        fund = Fund.add('Test Fund', 'Test Manager', 2000, 0.00, 0.00,
                        profile.id)

    # return the queries handler
    return handler
示例#4
0
def add_role_api(role_name):
    Role.add(role_name)
    return ''