Skip to content

Commit

Permalink
fix avo resources for organizations
Browse files Browse the repository at this point in the history
  • Loading branch information
martinemde committed Nov 15, 2024
1 parent de0b447 commit 1f5845f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/avo/resources/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ class Avo::Resources::Organization < Avo::BaseResource
}
}

self.find_record_method = -> do
query.find_by_handle!(id)
end

class DeletedFilter < Avo::Filters::ScopeBooleanFilter; end

def filters
Expand All @@ -20,5 +24,12 @@ def fields
field :name, as: :text
field :deleted_at, as: :date_time
# add fields here
tabs style: :pills do
field :memberships, as: :has_many
field :unconfirmed_memberships, as: :has_many
field :users, as: :has_many
field :rubygems, as: :has_many
field :organization_onboarding, as: :belongs_to
end
end
end
2 changes: 2 additions & 0 deletions app/avo/resources/rubygem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def fields
field :ownerships_including_unconfirmed, as: :has_many
field :ownership_calls, as: :has_many
field :ownership_requests, as: :has_many
field :organization, as: :belongs_to

field :subscriptions, as: :has_many
field :subscribers, as: :has_many, through: :subscriptions
Expand All @@ -49,6 +50,7 @@ def fields
field :oidc_rubygem_trusted_publishers, as: :has_many

field :audits, as: :has_many
field :events, as: :has_many
end
end
end
4 changes: 3 additions & 1 deletion app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class Organization < ApplicationRecord
has_many :rubygems, dependent: :nullify
has_one :organization_onboarding, foreign_key: :onboarded_organization_id, inverse_of: :organization, dependent: :destroy

scope :deleted, -> { where.not(deleted_at: nil) }
default_scope { not_deleted }
scope :not_deleted, -> { where(deleted_at: nil) }
scope :deleted, -> { unscoped.where.not(deleted_at: nil) }

after_create do
record_event!(Events::OrganizationEvent::CREATED, actor_gid: memberships.first&.to_gid)
Expand Down

0 comments on commit 1f5845f

Please sign in to comment.