Skip to content

Commit

Permalink
Add support letter policy for removal
Browse files Browse the repository at this point in the history
https://app.asana.com/0/1199154381249427/1203411987771110/f
Adds can_remove? policy for letters of support
  • Loading branch information
TheDancingClown committed Nov 30, 2023
1 parent 01581a6 commit e91aabd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/policies/support_letter_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ class SupportLetterPolicy < ApplicationPolicy
def show?
true
end

def can_remove?
admin?
end
end
4 changes: 2 additions & 2 deletions app/views/qae_form/_supporter_fields.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}"

0 comments on commit e91aabd

Please sign in to comment.