Skip to content

Commit

Permalink
✨ provide affiliate logo in area (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ppers authored Apr 22, 2021
1 parent 8c992b4 commit d6d235a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ class Area < ApplicationRecord
include ApiSerializable
include RailsAdminConfig::ForArea

EXPOSED_ATTRIBUTES = %i[id name menu_link company_id company_name company_need_to_show_corona_test owner_is_blocked menu_alias frontend_url public_key privacy_policy_link]
EXPOSED_ATTRIBUTES = %i[id name menu_link company_id company_name company_need_to_show_corona_test affiliate_logo owner_is_blocked menu_alias frontend_url public_key privacy_policy_link]

belongs_to :company
has_many :tickets, dependent: :destroy

delegate :id, :name, :need_to_show_corona_test, to: :company, prefix: :company
delegate :menu_alias, :frontend_url, :public_key, :privacy_policy_link, to: :company
delegate :affiliate_logo, to: :company

def owner_is_blocked
company.owner.blocked?
Expand Down
1 change: 1 addition & 0 deletions app/models/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Company < ApplicationRecord
scope :not_free, -> { where.not(is_free: true) }

delegate :menu_alias, :frontend_url, :public_key, to: :owner
delegate :affiliate_logo, to: :owner

attr_accessor :remove_menu_pdf

Expand Down
6 changes: 6 additions & 0 deletions app/models/owner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ def blocked?
block_at&.past?
end

def affiliate_logo
return unless affiliate

Affiliate.find_by(code: affiliate)&.logo_url
end

def frontend_url
# This could be replaced by a delegate once the migration has been done on production

Expand Down

0 comments on commit d6d235a

Please sign in to comment.