def service_switch_live(service_id):
    form = ServiceOnOffSettingForm(name="Make service live",
                                   enabled=not current_service.trial_mode)

    if form.validate_on_submit():
        current_service.update_status(live=form.enabled.data)
        return redirect(url_for('.service_settings', service_id=service_id))

    return render_template(
        'views/service-settings/set-service-setting.html',
        title="Make service live",
        form=form,
    )
def service_set_international_letters(service_id):
    form = ServiceOnOffSettingForm(
        'Send letters to international addresses',
        enabled=current_service.has_permission('international_letters'),
    )
    if form.validate_on_submit():
        current_service.force_permission(
            'international_letters',
            on=form.enabled.data,
        )
        return redirect(url_for(".service_settings", service_id=service_id))
    return render_template(
        'views/service-settings/set-international-letters.html',
        form=form,
    )
Example #3
0
def service_switch_live(service_id):
    form = ServiceOnOffSettingForm(
        name="Make service live",
        enabled=ServiceOnOffSettingForm.enabled_from_boolean(not current_service['restricted'])
    )

    if form.validate_on_submit():
        service_api_client.update_status(service_id, live=form.enabled.data)
        return redirect(url_for('.service_settings', service_id=service_id))

    return render_template(
        'views/service-settings/set-service-setting.html',
        title="Make service live",
        form=form,
    )
def service_set_permission(service_id, permission):
    if permission not in PLATFORM_ADMIN_SERVICE_PERMISSIONS:
        abort(404)

    title = PLATFORM_ADMIN_SERVICE_PERMISSIONS[permission]['title']
    form = ServiceOnOffSettingForm(
        name=title, enabled=current_service.has_permission(permission))

    if form.validate_on_submit():
        current_service.force_permission(permission, on=form.enabled.data)

        return redirect(url_for(".service_settings", service_id=service_id))

    return render_template(
        'views/service-settings/set-service-setting.html',
        title=title,
        form=form,
    )
def service_switch_count_as_live(service_id):

    form = ServiceOnOffSettingForm(
        name="Count in list of live services",
        enabled=current_service.count_as_live,
        truthy='Yes',
        falsey='No',
    )

    if form.validate_on_submit():
        current_service.update_count_as_live(form.enabled.data)
        return redirect(url_for('.service_settings', service_id=service_id))

    return render_template(
        'views/service-settings/set-service-setting.html',
        title="Count in list of live services",
        form=form,
    )
Example #6
0
def service_switch_count_as_live(service_id):
    form = ServiceOnOffSettingForm(
        name="Count in list of live services",
        enabled=current_service['count_as_live'],
        truthy='Yes',
        falsey='No',
    )

    if form.validate_on_submit():
        service_api_client.update_service_with_properties(
            service_id, {"count_as_live": form.enabled.data})
        return redirect(url_for('.service_settings', service_id=service_id))

    return render_template(
        'views/service-settings/set-service-setting.html',
        title="Count in list of live services",
        form=form,
    )
def user_profile_disable_platform_admin_view():
    if not current_user.platform_admin and not session.get(
            'disable_platform_admin_view'):
        abort(403)

    form = ServiceOnOffSettingForm(
        name="Signing in again clears this setting",
        enabled=not session.get('disable_platform_admin_view'),
        truthy='Yes',
        falsey='No',
    )

    if form.validate_on_submit():
        session['disable_platform_admin_view'] = not form.enabled.data
        return redirect(url_for('.user_profile'))

    return render_template(
        'views/user-profile/disable-platform-admin-view.html', form=form)
Example #8
0
def user_profile_disable_platform_admin_view():
    if not current_user.platform_admin and not session.get(
            "disable_platform_admin_view"):
        abort(403)

    form = ServiceOnOffSettingForm(
        name=_("Signing in again clears this setting"),
        enabled=not session.get("disable_platform_admin_view"),
        truthy=_("Yes"),
        falsey=_("No"),
    )

    if form.validate_on_submit():
        session["disable_platform_admin_view"] = not form.enabled.data
        return redirect(url_for(".user_profile"))

    return render_template(
        "views/user-profile/disable-platform-admin-view.html", form=form)
def service_set_broadcast_permission(service_id):

    title = PLATFORM_ADMIN_SERVICE_PERMISSIONS['broadcast']['title']
    form = ServiceOnOffSettingForm(
        name=title, enabled=current_service.has_permission('broadcast'))

    if form.validate_on_submit():

        if form.enabled.data:
            current_service.force_broadcast_permission_on()
        else:
            current_service.force_permission('broadcast', on=False)

        return redirect(url_for(".service_settings", service_id=service_id))

    return render_template(
        'views/service-settings/set-service-setting.html',
        title=title,
        form=form,
    )