generalise sidebar campaign published article timeframe (#12278)
This commit is contained in:
parent
af3a1a5fcf
commit
58efe300ac
6 changed files with 24 additions and 2 deletions
|
|
@ -11,7 +11,7 @@ class SidebarsController < ApplicationController
|
|||
|
||||
def get_latest_campaign_articles
|
||||
campaign_articles_scope = Article.tagged_with(Campaign.current.featured_tags, any: true)
|
||||
.where("published_at > ? AND score > ?", 4.weeks.ago, 0)
|
||||
.where("published_at > ? AND score > ?", SiteConfig.campaign_articles_expiry_time.weeks.ago, 0)
|
||||
.order(hotness_score: :desc)
|
||||
|
||||
requires_approval = Campaign.current.articles_require_approval?
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class StoriesController < ApplicationController
|
|||
|
||||
def get_latest_campaign_articles
|
||||
campaign_articles_scope = Article.tagged_with(Campaign.current.featured_tags, any: true)
|
||||
.where("published_at > ? AND score > ?", 4.weeks.ago, 0)
|
||||
.where("published_at > ? AND score > ?", SiteConfig.campaign_articles_expiry_time.weeks.ago, 0)
|
||||
.order(hotness_score: :desc)
|
||||
|
||||
requires_approval = Campaign.current.articles_require_approval?
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ module Constants
|
|||
description: "https://url.com/lander",
|
||||
placeholder: "URL campaign sidebar image will link to"
|
||||
},
|
||||
campaign_articles_expiry_time: {
|
||||
description: "Sets the expiry time for articles (in weeks) to be displayed in campaign sidebar",
|
||||
placeholder: ""
|
||||
},
|
||||
community_copyright_start_year: {
|
||||
description: "Used to mark the year this forem was started.",
|
||||
placeholder: Time.zone.today.year.to_s
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class SiteConfig < RailsSettings::Base
|
|||
field :campaign_sidebar_image, type: :string, default: nil
|
||||
field :campaign_url, type: :string, default: nil
|
||||
field :campaign_articles_require_approval, type: :boolean, default: 0
|
||||
field :campaign_articles_expiry_time, type: :integer, default: 4
|
||||
|
||||
# Community Content
|
||||
field :community_name, type: :string, default: ApplicationConfig["COMMUNITY_NAME"] || "New Forem"
|
||||
|
|
|
|||
|
|
@ -438,6 +438,15 @@
|
|||
placeholder: Constants::SiteConfig::DETAILS[:campaign_call_to_action][:placeholder] %>
|
||||
</div>
|
||||
|
||||
<div class="crayons-field">
|
||||
<%= admin_config_label :campaign_articles_expiry_time, "Campaign article expiry time" %>
|
||||
<%= admin_config_description Constants::SiteConfig::DETAILS[:campaign_articles_expiry_time][:description] %>
|
||||
<%= f.number_field :campaign_articles_expiry_time,
|
||||
class: "crayons-textfield",
|
||||
value: SiteConfig.campaign_articles_expiry_time,
|
||||
placeholder: Constants::SiteConfig::DETAILS[:campaign_articles_expiry_time][:placeholder] %>
|
||||
</div>
|
||||
|
||||
<%= render "form_submission", f: f %>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -86,6 +86,14 @@ RSpec.describe "/admin/config", type: :request do
|
|||
expect(SiteConfig.authentication_providers).to eq([enabled])
|
||||
end
|
||||
|
||||
describe "Campaigns" do
|
||||
it "sets campaign_articles_expiry_time" do
|
||||
post "/admin/config", params: { site_config: { campaign_articles_expiry_time: 4 },
|
||||
confirmation: confirmation_message }
|
||||
expect(SiteConfig.campaign_articles_expiry_time).to eq(4)
|
||||
end
|
||||
end
|
||||
|
||||
it "strips empty elements" do
|
||||
provider = Authentication::Providers.available.last.to_s
|
||||
enabled = "#{provider}, '', nil"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue