Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
85d603e
Enhance access control for employee payment and contractor invitation…
manuthecoder Jun 5, 2025
9c4e808
fix header for donations
manuthecoder Jun 5, 2025
2df3403
Restrict tag management to organizers in transaction and tag views
manuthecoder Jun 5, 2025
7a7638f
Update organizer_signed_in? check to include member role in pinned tr…
manuthecoder Jun 5, 2025
fc0d90b
Refactor receipt policy to enhance destroy permission checks and upda…
manuthecoder Jun 5, 2025
603d5af
Allow users to remove themselves from an organization
manuthecoder Jun 5, 2025
ac6f42f
Merge branch 'main' into improve-reader-ui-part-2
manuthecoder Jun 10, 2025
dab4f19
Merge branch 'main' into improve-reader-ui-part-2
manuthecoder Jun 12, 2025
bd193df
Cancel Stripe cards when a user is demoted!
manuthecoder Jun 12, 2025
f662597
Lint code
manuthecoder Jun 12, 2025
4371831
hide suggested tags for readers
manuthecoder Jun 12, 2025
412ac7b
Merge branch 'main' into improve-reader-ui-part-2
manuthecoder Jun 16, 2025
957b7f4
Fix indeentation
manuthecoder Jun 16, 2025
1bacd91
Merge branch 'main' into improve-reader-ui-part-2
manuthecoder Jun 19, 2025
c711c96
Merge branch 'main' into improve-reader-ui-part-2
manuthecoder Jun 21, 2025
f37244a
Merge remote-tracking branch 'origin/main' into improve-reader-ui-part-2
manuthecoder Jul 3, 2025
4644e8f
Fix indentation
manuthecoder Jul 3, 2025
120c8a9
Fix linting issues
manuthecoder Jul 3, 2025
d0c0937
Discard admin changes
manuthecoder Jul 3, 2025
324caa8
Fix method call syntax for organizer_signed_in in canonical_pending_t…
manuthecoder Jul 3, 2025
bc4c235
Merge remote-tracking branch 'origin/main' into improve-reader-ui-part-2
manuthecoder Aug 29, 2025
6bff837
Fix closing tag for tags section in _tags.html.erb
manuthecoder Aug 29, 2025
fef44c6
Merge branch 'main' into improve-reader-ui-part-2
Luke-Oldenburg Oct 20, 2025
02c4753
Merge branch 'main' into improve-reader-ui-part-2
manuthecoder Oct 22, 2025
c3881ae
Use Pundit for authorization checks on tags
manuthecoder Oct 22, 2025
7e8fa4f
Update contractor invitation logic to use EmployeePolicy for authoriz…
manuthecoder Oct 23, 2025
ce9c77d
Update header authorization check to use event policy
manuthecoder Oct 23, 2025
97b8ff1
Merge branch 'main' into improve-reader-ui-part-2
manuthecoder Oct 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/models/organizer_position.rb
Copy link
Contributor

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.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class OrganizerPosition < ApplicationRecord
belongs_to :user
belongs_to :event

before_save :cancel_cards_if_demoted_to_reader

has_one :organizer_position_invite, required: true
has_many :organizer_position_deletion_requests
has_many :tours, as: :tourable, dependent: :destroy
Expand Down Expand Up @@ -76,4 +78,20 @@ def self.role_at_least?(user, event, role)

private

def cancel_cards_if_demoted_to_reader
return unless will_save_change_to_role?

old_role = role_before_last_save
new_role = self.role

return if old_role.nil?

if OrganizerPosition.roles[old_role] > OrganizerPosition.roles[new_role] &&
new_role == "reader"
stripe_cards.where(event: event).find_each do |card|
card.cancel! unless card.stripe_status == "canceled"
end
end
end

end
2 changes: 1 addition & 1 deletion app/policies/organizer_position_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class OrganizerPositionPolicy < ApplicationPolicy
def destroy?
admin_or_contract_signee?
admin_or_contract_signee? || record.user == user
Copy link
Contributor

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.

end

def set_index?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<% end %>
</div>

<% if !@frame && defined?(show_tags) && show_tags && organizer_signed_in?(as: :member) && !pt.instance_of?(OpenStruct) %>
<% if !@frame && defined?(show_tags) && show_tags && TagPolicy.new(current_user, pt).update? && !pt.instance_of?(OpenStruct) %>
<% if suggestion = pt.local_hcb_code.suggested_hcb_code_tag_suggestions.last %>
<div class="list-badge add-tag-badge ml0 menu__toggle menu__toggle--arrowless b--ai suggested_tag tooltipped tooltippped--s" style="border: 1.5px dashed #a633d6" id="tag_suggestion_<%= suggestion.id %>" aria-label="Click to apply HCB's suggestion">
<%= link_to "#{suggestion.tag.emoji} #{suggestion.tag.label}", tag_suggestion_accept_path(suggestion), style: "text-decoration: none", class: "ai", data: { turbo_method: :post } %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<% end %>
</div>

<% if !@frame && defined?(show_tags) && show_tags && organizer_signed_in?(as: :member) && !ct.instance_of?(OpenStruct) %>
<% if !@frame && defined?(show_tags) && show_tags && TagPolicy.new(current_user, ct).update? && !ct.instance_of?(OpenStruct) %>
<% if suggestion = ct.local_hcb_code.suggested_hcb_code_tag_suggestions.last %>
<div class="list-badge add-tag-badge ml0 menu__toggle menu__toggle--arrowless b--ai suggested_tag tooltipped tooltippped--s" style="border: 1.5px dashed #a633d6" id="tag_suggestion_<%= suggestion.id %>" aria-label="Click to apply HCB's suggestion">
<%= link_to "#{suggestion.tag.emoji} #{suggestion.tag.label}", tag_suggestion_accept_path(suggestion), style: "text-decoration: none", class: "ai", data: { turbo_method: :post } %>
Expand Down
8 changes: 5 additions & 3 deletions app/views/events/employees.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

<h1 class="heading flex">
<span class="flex-grow">Contractors</span>
<%= link_to "#", class: "btn bg-success", data: { behavior: "modal_trigger", modal: "invite" } do %>
<%= inline_icon "plus" %>
Invite a contractor
<% if EmployeePolicy.new(current_user, @event).new? %>
<%= link_to "#", class: "btn bg-success", data: { behavior: "modal_trigger", modal: "invite" } do %>
<%= inline_icon "plus" %>
Invite a contractor
<% end %>
<% end %>
</h1>

Expand Down
2 changes: 1 addition & 1 deletion app/views/events/landing/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>

<%= content_for(:header) do %>
<% if organizer_signed_in? %>
<% if policy(@event).update? %>
<div class="flex items-center m2 absolute z-10 top-0 left-0">
<%= form_with model: @event, class: "embedded-display-none", data: { "controller" => "form" } do |form| %>
<%= form.file_field :donation_header_image, required: true, class: "display-none", accept: "image/png,image/jpeg", data: { action: "change->form#submit" } %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/hcb_codes/_invoice.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@
disabled: !organizer_signed_in?,
method: :post,
data: { confirm: "Are you sure you want to void this invoice? Voided invoices can not be paid and this action cannot be undone." },
class: "btn bg-error mr1 right" if @invoice.open_v2? %>
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) %>
Comment on lines +198 to +203
Copy link
Contributor

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?

</section>
</article>

Expand Down