Пример #1
0
def invite_user(service_id):

    form = InviteUserForm(invalid_email_address=current_user.email_address)

    if form.validate_on_submit():
        email_address = form.email_address.data
        # view_activity is a default role to be added to all users.
        # All users will have at minimum view_activity to allow users to see notifications,
        # templates, team members but no update privileges
        selected_permissions = [permissions for role, permissions in roles.items() if request.form.get(role) == 'y']
        selected_permissions = list(chain.from_iterable(selected_permissions))
        selected_permissions.append('view_activity')
        selected_permissions.sort()
        permissions = ','.join(selected_permissions)
        invited_user = invite_api_client.create_invite(
            current_user.id,
            service_id,
            email_address,
            permissions
        )

        flash('Invite sent to {}'.format(invited_user.email_address), 'default_with_tick')
        return redirect(url_for('.manage_users', service_id=service_id))

    return render_template(
        'views/invite-user.html',
        form=form
    )
Пример #2
0
def invite_user(service_id):

    form = InviteUserForm(
        invalid_email_address=current_user.email_address,
        all_template_folders=current_service.all_template_folders,
        folder_permissions=[
            f['id'] for f in current_service.all_template_folders
        ])

    service_has_email_auth = current_service.has_permission('email_auth')
    if not service_has_email_auth:
        form.login_authentication.data = 'sms_auth'

    if form.validate_on_submit():
        email_address = form.email_address.data
        invited_user = InvitedUser.create(
            current_user.id,
            service_id,
            email_address,
            form.permissions,
            form.login_authentication.data,
            form.folder_permissions.data,
        )

        flash('{} {}'.format(_l('Invite sent to'), invited_user.email_address),
              'default_with_tick')
        return redirect(url_for('.manage_users', service_id=service_id))

    return render_template(
        'views/invite-user.html',
        form=form,
        service_has_email_auth=service_has_email_auth,
        mobile_number=True,
    )
Пример #3
0
def invite_user(service_id):

    form = InviteUserForm(invalid_email_address=current_user.email_address)

    if form.validate_on_submit():
        email_address = form.email_address.data
        # view_activity is a default role to be added to all users.
        # All users will have at minimum view_activity to allow users to see notifications,
        # templates, team members but no update privileges
        selected_permissions = [
            permissions for role, permissions in roles.items()
            if request.form.get(role) == 'y'
        ]
        selected_permissions = list(chain.from_iterable(selected_permissions))
        selected_permissions.append('view_activity')
        selected_permissions.sort()
        permissions = ','.join(selected_permissions)
        invited_user = invite_api_client.create_invite(current_user.id,
                                                       service_id,
                                                       email_address,
                                                       permissions)

        flash('Invite sent to {}'.format(invited_user.email_address),
              'default_with_tick')
        return redirect(url_for('.manage_users', service_id=service_id))

    return render_template('views/invite-user.html', form=form)
Пример #4
0
def remove_user_from_service(service_id):
    form = InviteUserForm()
    service = admin_api_client.get_service_by_user_id_and_service_id(
        int(session['user_id']), service_id)
    users = admin_api_client.get_users_by_service_id(service_id)
    try:
        admin_api_client.remove_user_from_service(
            request.form['email_address'], service_id)
        return redirect(
            url_for('.view_service_users',
                    form=InviteUserForm(),
                    service_id=service_id))
    except APIError as ex:
        flash(ex.message, "error")
        return render_template('users.html',
                               service=service['service'],
                               users=users['users'],
                               **get_template_data(form=form)), 400
Пример #5
0
def view_service_users(service_id):
    service = admin_api_client.get_service_by_user_id_and_service_id(
        int(session['user_id']), service_id)
    users = admin_api_client.get_users_by_service_id(service_id)
    return render_template("users.html",
                           service=service['service'],
                           users=users['users'],
                           form=InviteUserForm(),
                           **get_template_data())
def invite_user(service_id):

    form = InviteUserForm(invalid_email_address=current_user.email_address)

    service_has_email_auth = current_service.has_permission('email_auth')
    if not service_has_email_auth:
        form.login_authentication.data = 'sms_auth'

    if form.validate_on_submit():
        email_address = form.email_address.data
        invited_user = invite_api_client.create_invite(
            current_user.id, service_id, email_address, form.permissions,
            form.login_authentication.data)

        flash('Invite sent to {}'.format(invited_user.email_address),
              'default_with_tick')
        return redirect(url_for('.manage_users', service_id=service_id))

    return render_template('views/invite-user.html',
                           form=form,
                           service_has_email_auth=service_has_email_auth)
Пример #7
0
def add_user_to_service(service_id):
    service = admin_api_client.get_service_by_user_id_and_service_id(int(session['user_id']), service_id)
    users = admin_api_client.get_users_by_service_id(service_id)
    form = InviteUserForm()
    if form.validate_on_submit():
        try:
            admin_api_client.add_user_to_service(form.email_address.data, service_id)
            return redirect(url_for('.view_service_users', form=InviteUserForm(), service_id=service_id))
        except APIError as ex:
            flash(ex.message, "error")
            return render_template(
                'users.html',
                service=service['service'],
                users=users['users'],
                **get_template_data(form=form)
            ), 400
    else:
        return render_template(
            'users.html',
            service=service['service'],
            users=users['users'],
            **get_template_data(form=form)
        ), 400
Пример #8
0
def invite_user(service_id):

    form = InviteUserForm(
        invalid_email_address=current_user.email_address,
        all_template_folders=current_service.all_template_folders,
        folder_permissions=[
            f["id"] for f in current_service.all_template_folders
        ],
    )

    service_has_email_auth = current_service.has_permission("email_auth")
    if not service_has_email_auth:
        form.login_authentication.data = "sms_auth"

    if form.validate_on_submit():
        email_address = form.email_address.data
        invited_user = InvitedUser.create(
            current_user.id,
            service_id,
            email_address,
            form.permissions,
            form.login_authentication.data,
            form.folder_permissions.data,
        )

        flash(
            "{} {}".format(_l("Invite sent to"), invited_user.email_address),
            "default_with_tick",
        )
        return redirect(url_for(".manage_users", service_id=service_id))

    return render_template(
        "views/invite-user.html",
        form=form,
        service_has_email_auth=service_has_email_auth,
        mobile_number=True,
    )
Пример #9
0
def add_user_to_service(service_id):
    service = admin_api_client.get_service_by_user_id_and_service_id(
        int(session['user_id']), service_id)
    users = admin_api_client.get_users_by_service_id(service_id)
    form = InviteUserForm()
    if form.validate_on_submit():
        try:
            admin_api_client.add_user_to_service(form.email_address.data,
                                                 service_id)
            return redirect(
                url_for('.view_service_users',
                        form=InviteUserForm(),
                        service_id=service_id))
        except APIError as ex:
            flash(ex.message, "error")
            return render_template('users.html',
                                   service=service['service'],
                                   users=users['users'],
                                   **get_template_data(form=form)), 400
    else:
        return render_template('users.html',
                               service=service['service'],
                               users=users['users'],
                               **get_template_data(form=form)), 400