Add custom_display_label to billboards and update API (#20355)
* Add a/b test for which comments to show in feed * Adjust figure * Started at * Add custom_display_label to billboards and update API * Add custom_display_label to billboards and update API
This commit is contained in:
parent
779701d5f6
commit
eccd5fd9e3
9 changed files with 1685 additions and 100 deletions
|
|
@ -60,7 +60,7 @@ module Admin
|
|||
params.permit(:organization_id, :body_markdown, :placement_area, :target_geolocations,
|
||||
:published, :approved, :name, :display_to, :tag_list, :type_of,
|
||||
:exclude_article_ids, :audience_segment_id, :priority,
|
||||
:render_mode, :template)
|
||||
:render_mode, :template, :custom_display_label)
|
||||
end
|
||||
|
||||
def authorize_admin
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ module Api
|
|||
:name, :organization_id, :placement_area, :published,
|
||||
:tag_list, :type_of, :exclude_article_ids, :weight,
|
||||
:audience_segment_type, :audience_segment_id, :priority,
|
||||
:custom_display_label, :template, :render_mode,
|
||||
# Permitting twice allows both comma-separated string and array values
|
||||
:target_geolocations, target_geolocations: []
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@
|
|||
<%= text_field_tag :organization_id, @billboard.organization_id, class: "crayons-textfield", placeholder: "1234", autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="crayons-field">
|
||||
<%= label_tag :custom_display_label, "Custom author display name:", class: "crayons-field__label" %>
|
||||
<%= text_field_tag :custom_display_label, @billboard.custom_display_label, size: "100x5", class: "crayons-textfield", autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="crayons-field">
|
||||
<%= label_tag :body_markdown, "Body Content:", class: "crayons-field__label" %>
|
||||
<%= text_area_tag :body_markdown, @billboard.body_markdown, size: "100x5", class: "crayons-textfield" %>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,20 @@
|
|||
<div class="crayons-sponsorship__header relative">
|
||||
<% if billboard.organization_id? && (billboard.type_of == "community" || billboard.type_of == "external") %>
|
||||
<% if (billboard.organization_id? || billboard.custom_display_label.present?) && (billboard.type_of == "community" || billboard.type_of == "external") %>
|
||||
<div class="flex">
|
||||
<a href="<%= billboard.organization.path %>" target="_blank" rel="noopener" class="flex">
|
||||
<img width="24" height="24" class="radius-default crayons-sponsorship__image" src="<%= billboard.organization.profile_image_url_for(length: 64) %>" alt="profile" loading="lazy" />
|
||||
<div class="crayons-sponsorship__title ml-2 fs-s fw-medium"><%= billboard.organization.name %></div>
|
||||
</a>
|
||||
<% if billboard.custom_display_label.present? %>
|
||||
<div class="crayons-sponsorship__title"><%= billboard.custom_display_label %></div>
|
||||
<% else %>
|
||||
<a href="<%= billboard.organization.path %>" target="_blank" rel="noopener" class="flex">
|
||||
<img width="24" height="24" class="radius-default crayons-sponsorship__image" src="<%= billboard.organization.profile_image_url_for(length: 64) %>" alt="profile" loading="lazy" />
|
||||
<div class="crayons-sponsorship__title ml-2 fs-s fw-medium"><%= billboard.organization.name %></div>
|
||||
</a>
|
||||
<% end %>
|
||||
<% if billboard.type_of == "external" %>
|
||||
<span class="crayons-sponsorship__indicator c-indicator c-indicator--subtle c-indicator--round fs-2xs fw-medium ml-2 py-1 px-2"><%= I18n.t("billboard.promoted") %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="crayons-sponsorship__title"><%= Settings::Community.community_name %></div>
|
||||
<div class="crayons-sponsorship__title"><%= billboard.custom_display_label.presence || Settings::Community.community_name %></div>
|
||||
<% end %>
|
||||
|
||||
<button id="sponsorship-dropdown-trigger-<%= billboard.id %>" aria-controls="sponsorship-dropdown-<%= billboard.id %>" aria-expanded="false" aria-haspopup="true"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
class AddCustomAuthorNameToBillboards < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :display_ads, :custom_display_label, :string
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_11_08_153011) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_11_14_154619) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "citext"
|
||||
enable_extension "ltree"
|
||||
|
|
@ -475,6 +475,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_08_153011) do
|
|||
t.integer "clicks_count", default: 0
|
||||
t.datetime "created_at", precision: nil, null: false
|
||||
t.integer "creator_id"
|
||||
t.string "custom_display_label"
|
||||
t.integer "display_to", default: 0, null: false
|
||||
t.integer "exclude_article_ids", default: [], array: true
|
||||
t.integer "impressions_count", default: 0
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ RSpec.describe "Api::V1::Billboards" do
|
|||
"success_rate", "tag_list", "type_of", "updated_at",
|
||||
"creator_id", "exclude_article_ids",
|
||||
"audience_segment_type", "audience_segment_id",
|
||||
"priority", "weight", "target_geolocations",
|
||||
"render_mode", "template")
|
||||
"custom_display_label", "template", "render_mode",
|
||||
"priority", "weight", "target_geolocations")
|
||||
expect(response.parsed_body["target_geolocations"]).to contain_exactly("US-WA", "CA-BC")
|
||||
end
|
||||
|
||||
|
|
@ -72,8 +72,8 @@ RSpec.describe "Api::V1::Billboards" do
|
|||
"success_rate", "tag_list", "type_of", "updated_at",
|
||||
"creator_id", "exclude_article_ids",
|
||||
"audience_segment_type", "audience_segment_id",
|
||||
"priority", "weight", "target_geolocations",
|
||||
"render_mode", "template")
|
||||
"custom_display_label", "template", "render_mode",
|
||||
"priority", "weight", "target_geolocations")
|
||||
expect(response.parsed_body["target_geolocations"]).to contain_exactly("US-WA", "CA-BC")
|
||||
end
|
||||
|
||||
|
|
@ -138,8 +138,8 @@ RSpec.describe "Api::V1::Billboards" do
|
|||
"success_rate", "tag_list", "type_of", "updated_at",
|
||||
"creator_id", "exclude_article_ids",
|
||||
"audience_segment_type", "audience_segment_id",
|
||||
"priority", "weight", "target_geolocations",
|
||||
"render_mode", "template")
|
||||
"custom_display_label", "template", "render_mode",
|
||||
"priority", "weight", "target_geolocations")
|
||||
end
|
||||
|
||||
it "also accepts target geolocations as an array" do
|
||||
|
|
|
|||
|
|
@ -153,6 +153,12 @@ RSpec.describe "Billboards" do
|
|||
get article_billboard_path(username: article.username, slug: article.slug, placement_area: "post_comments")
|
||||
expect(response.body).to include "crayons-sponsorship__header relative"
|
||||
end
|
||||
|
||||
it "includes custom_display_label if set" do
|
||||
billboard.update_column(:custom_display_label, "My great custom label")
|
||||
get article_billboard_path(username: article.username, slug: article.slug, placement_area: "post_comments")
|
||||
expect(response.body).to include "My great custom label"
|
||||
end
|
||||
end
|
||||
|
||||
context "when billboard template is plain" do
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue