Add Danbooru Winter Sale.

* 25% off Gold and Platinum accounts.
* Free 6 tag searches for Member-level users.
* Runs from midnight Dec. 25th to 28th (UTC time).
This commit is contained in:
evazion
2019-12-24 13:02:05 -06:00
parent ef2eb9d0f5
commit 963f1f7991
6 changed files with 56 additions and 5 deletions

View File

@@ -8,6 +8,13 @@ $(function() {
e.preventDefault();
});
$("#hide-promotion-notice").on("click.danbooru", function(e) {
$("#promotion-notice").hide();
Cookie.put('hide_promotion_notice', '1', 7);
Cookie.put('hide_upgrade_account_notice', '1', 7);
e.preventDefault();
});
$("#hide-dmail-notice").on("click.danbooru", function(e) {
var $dmail_notice = $("#dmail-notice");
$dmail_notice.hide();

View File

@@ -1,13 +1,25 @@
class UserUpgrade
def self.gold_price
2000
if Danbooru.config.is_promotion?
1500
else
2000
end
end
def self.platinum_price
4000
if Danbooru.config.is_promotion?
3000
else
4000
end
end
def self.upgrade_price
2000
if Danbooru.config.is_promotion?
1500
else
2000
end
end
end

View File

@@ -505,6 +505,8 @@ class User < ApplicationRecord
Danbooru.config.base_tag_query_limit * 2
elsif is_gold?
Danbooru.config.base_tag_query_limit
elsif is_member? && Danbooru.config.is_promotion?
Danbooru.config.base_tag_query_limit
else
2
end

View File

@@ -97,7 +97,15 @@
</header>
<div id="page">
<% if !CurrentUser.is_anonymous? && !CurrentUser.is_gold? && cookies[:hide_upgrade_account_notice].blank? && params[:action] != "upgrade_information" %>
<% if Danbooru.config.is_promotion? && cookies[:hide_promotion_notice].blank? %>
<div class="notice notice-info notice-large" id="promotion-notice">
Danbooru Winter Sale! 25% off Gold and free 6-tag searches for Members!
(<%= link_to "close", "#", id: "hide-promotion-notice" %>)
</div>
<% end %>
<% if !Danbooru.config.is_promotion? && !CurrentUser.is_anonymous? && !CurrentUser.is_gold? && cookies[:hide_upgrade_account_notice].blank? && params[:action] != "upgrade_information" %>
<%= render "users/upgrade_notice" %>
<% end %>

View File

@@ -3,7 +3,17 @@
<h1>Upgrade Account</h1>
<% unless params[:user_id] %>
<p class="copy">Want more searching power? Upgrade your account and become a power user of the best database of anime artwork on the internet.</p>
<p class="copy">
Want more searching power? Upgrade your account and
become a power user of the best database of anime artwork on the
internet.
</p>
<% if Danbooru.config.is_promotion? %>
<p>
<h6>Danbooru Winter Sale! Gold and Platinum upgrades are 25% off from now until December 28th.</h6>
</p>
<% end %>
<div id="feature-comparison">
<table>
@@ -24,10 +34,16 @@
<td>Cost</td>
<td>Free</td>
<td>
<% if Danbooru.config.is_promotion? %>
<s>$20</s>
<% end %>
<%= cents_to_usd(UserUpgrade.gold_price) %>
<div class="fineprint">One time fee</div>
</td>
<td>
<% if Danbooru.config.is_promotion? %>
<s>$40</s>
<% end %>
<%= cents_to_usd(UserUpgrade.platinum_price) %>
<div class="fineprint">One time fee</div>
</td>

View File

@@ -638,6 +638,12 @@ module Danbooru
def redis_url
"redis://localhost:6379"
end
def is_promotion?
Time.use_zone("UTC") do
Time.zone.now.in?(Time.zone.parse("2019-12-25")..Time.zone.parse("2019-12-28"))
end
end
end
class EnvironmentConfiguration