mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 13:08:40 +08:00
## Description Add ability for House Ads to target ember routes in addition to categories and groups ## Extra Details - Ads new dropdown in House Ad manager page for pages/routes - New site setting to enable/disable this behavior - Original behavior should be observed if setting is disabled
33 lines
747 B
Ruby
Vendored
33 lines
747 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module AdPlugin
|
|
class HouseAdSerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:name,
|
|
:html,
|
|
:visible_to_logged_in_users,
|
|
:visible_to_anons,
|
|
:created_at,
|
|
:updated_at,
|
|
:routes
|
|
|
|
has_many :groups, serializer: ::BasicGroupSerializer, embed: :objects
|
|
has_many :categories, serializer: ::BasicCategorySerializer, embed: :objects
|
|
|
|
def routes
|
|
object.route_names
|
|
end
|
|
|
|
def include_routes?
|
|
SiteSetting.ad_plugin_routes_enabled
|
|
end
|
|
|
|
def include_groups?
|
|
@options[:include_groups]
|
|
end
|
|
|
|
def include_categories?
|
|
@options[:include_categories]
|
|
end
|
|
end
|
|
end
|