-
Notifications
You must be signed in to change notification settings - Fork 67
Improve reader UI (part 2) #10582
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
base: main
Are you sure you want to change the base?
Improve reader UI (part 2) #10582
Conversation
…te view logic for delete button visibility
df09aaa to
c711c96
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at #10776 for some similar / duplicate fixes that use more policy instead.
app/views/canonical_pending_transactions/_canonical_pending_transaction.html.erb
Outdated
Show resolved
Hide resolved
app/views/canonical_transactions/_canonical_transaction.html.erb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there just a few small changes. I reckon the PR title should be updated to be more general too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should freeze cards instead of cancel and be in a separate PR please.
| class: "btn bg-error mr1 right" if @invoice.open_v2? && organizer_signed_in?(as: :member) %> | ||
| <%= link_to (@invoice.archived? ? "Un-archive" : "Archive"), | ||
| (@invoice.archived? ? invoice_unarchive_path(@invoice) : invoice_archive_path(@invoice)), | ||
| disabled: !organizer_signed_in?, | ||
| method: :post, | ||
| class: "btn bg-muted" unless @invoice.void_v2? %> | ||
| class: "btn bg-muted" unless @invoice.void_v2? || !organizer_signed_in?(as: :member) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make policies for these please?
| class OrganizerPositionPolicy < ApplicationPolicy | ||
| def destroy? | ||
| admin_or_contract_signee? | ||
| admin_or_contract_signee? || record.user == user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be in a separate PR since it's not strictly UI related.
This pull request introduces changes to enhance authorization checks and ensure proper role-based access control across policies and views. The updates primarily focus on restricting actions to users with the appropriate roles, such as organizers with at least the
:memberrole, and improving the handling of deletions.Authorization Enhancements:
OrganizerPositionPolicyto allow record owners to destroy positions in addition to admins or contract signees. (app/policies/organizer_position_policy.rb, app/policies/organizer_position_policy.rbL5-R5)ReceiptPolicyto use role-based checks (OrganizerPosition.role_at_least?) for destruction permissions instead of relying on event user inclusion. (app/policies/receipt_policy.rb, app/policies/receipt_policy.rbL6-R6)Role-Based View Access:
organizer_signed_in?(as: :member)) for rendering "Add tag" buttons, links, and modals across multiple views, includingcanonical_pending_transactions,canonical_transactions,employees, andeventsviews. [1] [2] [3] [4] [5] [6] [7]hcb_codes/_invoice.html.erbis restricted to organizers with at least the:memberrole.Improved Deletion Handling:
receipts/_receipt.html.erbto checkpolicy(receipt).destroy?before rendering delete buttons, ensuring only authorized users can delete receipts. [1] [2]