diff --git a/app/policies/support_letter_policy.rb b/app/policies/support_letter_policy.rb index 5d14ec5a0..f3ccc3004 100644 --- a/app/policies/support_letter_policy.rb +++ b/app/policies/support_letter_policy.rb @@ -4,4 +4,8 @@ class SupportLetterPolicy < ApplicationPolicy def show? true end + + def can_remove? + admin? + end end diff --git a/app/views/qae_form/_supporter_fields.html.slim b/app/views/qae_form/_supporter_fields.html.slim index abca4341b..39c94654a 100644 --- a/app/views/qae_form/_supporter_fields.html.slim +++ b/app/views/qae_form/_supporter_fields.html.slim @@ -48,5 +48,5 @@ li.js-add-example class="#{'read-only js-support-letter-received' if persisted}" - url = users_form_answer_support_letter_path(form_answer_id: @form_answer.id, id: supporter["support_letter_id"]) - else - url = "#" - - = link_to "Remove", url, class: "govuk-button govuk-button--warning remove-supporter remove-link js-remove-link", data: { url: url }, 'aria-label' => "Delete support letter from #{supporter["first_name"]} #{supporter["last_name"]}" + = if current_user || policy(:support_letter).can_remove? + = link_to "Remove", url, class: "govuk-button govuk-button--warning remove-supporter remove-link js-remove-link", data: { url: url }, 'aria-label' => "Delete support letter from #{supporter["first_name"]} #{supporter["last_name"]}"