mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Make a service model and use for permissions
Having the service floating about as JSON is a bit flakey. Could easily introduce a mistake where you mistype the name of a key and silently get `None`. Also means doing awkward things like `if 'permission' in current_service['permissions']`, whereas for users we can do the much cleaner `user.has_permission()`. So this commit: - introduces a model - adds a `.has_permission` method similar to the one we have for users
This commit is contained in:
@@ -37,7 +37,7 @@ dummy_bearer_token = 'bearer_token_set'
|
||||
@user_has_permissions('manage_api_keys')
|
||||
def api_integration(service_id):
|
||||
callbacks_link = (
|
||||
'.api_callbacks' if 'inbound_sms' in current_service['permissions']
|
||||
'.api_callbacks' if current_service.has_permission('inbound_sms')
|
||||
else '.delivery_status_callback'
|
||||
)
|
||||
return render_template(
|
||||
@@ -104,7 +104,7 @@ def create_api_key(service_id):
|
||||
'Not available because your service is in '
|
||||
'<a href="{}#trial-mode">trial mode</a>'.format(url_for(".using_notify"))
|
||||
)
|
||||
if 'letter' in current_service['permissions']:
|
||||
if current_service.has_permission('letter'):
|
||||
option_hints[KEY_TYPE_TEAM] = 'Can’t be used to send letters'
|
||||
if form.validate_on_submit():
|
||||
if form.key_type.data in disabled_options:
|
||||
@@ -198,7 +198,7 @@ def get_delivery_status_callback_details():
|
||||
def delivery_status_callback(service_id):
|
||||
delivery_status_callback = get_delivery_status_callback_details()
|
||||
back_link = (
|
||||
'.api_callbacks' if 'inbound_sms' in current_service['permissions']
|
||||
'.api_callbacks' if current_service.has_permission('inbound_sms')
|
||||
else '.api_integration'
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user