Don’t allow indexing on service model

Making people use a property is a sure way to make sure they’re spelling
the name of the property correctly, and allows us to easily swap out
properties that call through to the underlying JSON, and properties
which are implemented as methods.
This commit is contained in:
Chris Hill-Scott
2018-10-26 12:13:04 +01:00
parent 780b9bb715
commit e1197c54a5
10 changed files with 17 additions and 12 deletions

View File

@@ -324,7 +324,7 @@ def get_status_filters(service, message_type, statistics):
option,
url_for(
'.view_notifications',
service_id=service['id'],
service_id=service.id,
message_type=message_type,
status=option
),

View File

@@ -346,7 +346,7 @@ def service_switch_can_upload_document(service_id):
# If turning the permission off, or turning it on and the service already has a contact_link,
# don't show the form to add the link
if current_service.has_permission('upload_document') or current_service.get('contact_link'):
if current_service.has_permission('upload_document') or current_service.contact_link:
switch_service_permissions(service_id, 'upload_document')
return redirect(url_for('.service_settings', service_id=service_id))
@@ -415,7 +415,7 @@ def service_set_contact_link(service_id):
form = ServiceContactDetailsForm()
if request.method == 'GET':
contact_details = current_service.get('contact_link')
contact_details = current_service.contact_link
contact_type = check_contact_details_type(contact_details)
field_to_update = getattr(form, contact_type)

View File

@@ -237,7 +237,7 @@ def choose_template_to_copy(service_id):
'templates': [
template for template in
service_api_client.get_service_templates(service['id'])['data']
if template['template_type'] in current_service['permissions']
if current_service.has_permission(template['template_type'])
],
} for service in user_api_client.get_services_for_user(current_user)],
)