Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a service setting to switch basic view on and off #2148

Merged
merged 4 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,20 @@ class ServiceSwitchLettersForm(StripWhitespaceForm):
)


class ServiceBasicViewForm(StripWhitespaceForm):

def __init__(self, enabled):
super().__init__(enabled='on' if enabled else 'off')

enabled = RadioField(
'Basic view',
choices=[
('on', 'On'),
('off', 'Off'),
],
)


class ServiceSetBranding(StripWhitespaceForm):

def __init__(self, email_branding=[], *args, **kwargs):
Expand Down
31 changes: 23 additions & 8 deletions app/main/views/service_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
OrganisationTypeForm,
RenameServiceForm,
RequestToGoLiveForm,
ServiceBasicViewForm,
ServiceContactLinkForm,
ServiceEditInboundNumberForm,
ServiceInboundNumberForm,
Expand Down Expand Up @@ -322,14 +323,6 @@ def service_switch_email_auth(service_id):
return redirect(url_for('.service_settings', service_id=service_id))


@main.route("/services/<service_id>/service-settings/caseworking")
@login_required
@user_is_platform_admin
def service_switch_caseworking(service_id):
switch_service_permissions(service_id, 'caseworking')
return redirect(url_for('.service_settings', service_id=service_id))


@main.route("/services/<service_id>/service-settings/can-send-precompiled-letter")
@login_required
@user_is_platform_admin
Expand Down Expand Up @@ -635,6 +628,28 @@ def service_set_auth_type(service_id):
)


@main.route("/services/<service_id>/service-settings/set-basic-view", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_service')
def service_set_basic_view(service_id):
form = ServiceBasicViewForm(
enabled='caseworking' in current_service['permissions']
)
if form.validate_on_submit():
force_service_permission(
service_id,
'caseworking',
on=(form.enabled.data == 'on'),
)
return redirect(
url_for('.service_settings', service_id=service_id)
)
return render_template(
'views/service-settings/set-basic-view.html',
form=form,
)


@main.route("/services/<service_id>/service-settings/letter-contacts", methods=['GET'])
@login_required
@user_has_permissions('manage_service', 'manage_api_keys')
Expand Down
8 changes: 4 additions & 4 deletions app/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class HeaderNavigation(Navigation):
'service_name_change',
'service_name_change_confirm',
'service_set_auth_type',
'service_set_basic_view',
'service_set_contact_link',
'service_set_email',
'service_set_email_branding',
Expand All @@ -229,7 +230,6 @@ class HeaderNavigation(Navigation):
'service_switch_can_send_precompiled_letter',
'service_switch_can_upload_document',
'service_switch_can_send_sms',
'service_switch_caseworking',
'service_switch_email_auth',
'service_switch_live',
'service_switch_research_mode',
Expand Down Expand Up @@ -331,6 +331,7 @@ class MainNavigation(Navigation):
'service_name_change',
'service_name_change_confirm',
'service_set_auth_type',
'service_set_basic_view',
'service_set_contact_link',
'service_set_email',
'service_set_email_branding',
Expand Down Expand Up @@ -448,7 +449,6 @@ class MainNavigation(Navigation):
'service_switch_can_send_precompiled_letter',
'service_switch_can_upload_document',
'service_switch_can_send_sms',
'service_switch_caseworking',
'service_switch_email_auth',
'service_switch_live',
'service_switch_research_mode',
Expand Down Expand Up @@ -638,6 +638,7 @@ class CaseworkNavigation(Navigation):
'service_name_change',
'service_name_change_confirm',
'service_set_auth_type',
'service_set_basic_view',
'service_set_contact_link',
'service_set_email',
'service_set_email_branding',
Expand All @@ -655,7 +656,6 @@ class CaseworkNavigation(Navigation):
'service_switch_can_send_precompiled_letter',
'service_switch_can_send_sms',
'service_switch_can_upload_document',
'service_switch_caseworking',
'service_switch_email_auth',
'service_switch_live',
'service_switch_research_mode',
Expand Down Expand Up @@ -859,6 +859,7 @@ class OrgNavigation(Navigation):
'service_name_change',
'service_name_change_confirm',
'service_set_auth_type',
'service_set_basic_view',
'service_set_contact_link',
'service_set_email',
'service_set_email_branding',
Expand All @@ -876,7 +877,6 @@ class OrgNavigation(Navigation):
'service_switch_can_send_precompiled_letter',
'service_switch_can_upload_document',
'service_switch_can_send_sms',
'service_switch_caseworking',
'service_switch_email_auth',
'service_switch_live',
'service_switch_research_mode',
Expand Down
9 changes: 9 additions & 0 deletions app/templates/components/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@
</tbody>
{%- endmacro %}

{% macro settings_row(if_has_permission='') -%}
{% set parent_caller = caller %}
{% if if_has_permission in current_service.permissions %}
{% call row() %}
{{ parent_caller() }}
{% endcall %}
{% endif %}
{%- endmacro %}

{% macro field(align='left', status='', border=True) -%}

{% set field_alignment = 'table-field-right-aligned' if align == 'right' else 'table-field-center-aligned' %}
Expand Down
Loading