Пример #1
0
def permission_new():
    form = PermissionForm()
    form.context.choices = available_client_owners()
    if request.method == 'GET':
        form.context.data = g.user.userid
    if form.validate_on_submit():
        perm = Permission()
        form.populate_obj(perm)
        perm.user = form.user
        perm.org = form.org
        perm.allusers = False
        db.session.add(perm)
        db.session.commit()
        flash("Your new permission has been defined", 'success')
        return render_redirect(url_for('.permission_list'), code=303)
    return render_form(form=form, title="Define a new permission", formid="perm_new",
        submit="Define new permission", ajax=True)
Пример #2
0
def permission_new():
    form = PermissionForm()
    form.edit_user = current_auth.user
    form.context.choices = available_client_owners()
    if request.method == 'GET':
        form.context.data = current_auth.user.buid
    if form.validate_on_submit():
        perm = Permission()
        form.populate_obj(perm)
        perm.user = form.user
        perm.org = form.org
        perm.allusers = False
        db.session.add(perm)
        db.session.commit()
        flash(_("Your new permission has been defined"), 'success')
        return render_redirect(url_for('.permission_list'), code=303)
    return render_form(form=form, title=_("Define a new permission"), formid='perm_new',
        submit=_("Define new permission"), ajax=True)