0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/plugins/discourse-adplugin/app/serializers/ad_plugin/house_ad_serializer.rb
Bannon Tanner 91bcd2a35d
Feature page routes for house ads (#36932)
## 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
2026-01-12 11:25:46 -06:00

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