Skip to content
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

✨ provide affiliate logo in area #99

Merged
merged 1 commit into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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