From d6d235a3d340f4f6547eb81ee1ec41977842a382 Mon Sep 17 00:00:00 2001 From: m0ppers Date: Thu, 22 Apr 2021 11:05:44 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20provide=20affiliate=20logo=20in=20a?= =?UTF-8?q?rea=20(#99)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/area.rb | 3 ++- app/models/company.rb | 1 + app/models/owner.rb | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/area.rb b/app/models/area.rb index ab2f370..bc14dd8 100644 --- a/app/models/area.rb +++ b/app/models/area.rb @@ -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? diff --git a/app/models/company.rb b/app/models/company.rb index fd18809..7b652c9 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -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 diff --git a/app/models/owner.rb b/app/models/owner.rb index c21e217..1f47fdb 100644 --- a/app/models/owner.rb +++ b/app/models/owner.rb @@ -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