Add Danbooru Winter Sale.

This commit is contained in:
evazion
2021-12-28 14:41:37 -06:00
parent 572b1b74f7
commit b8356c97c1
11 changed files with 76 additions and 8 deletions

View File

@@ -151,8 +151,14 @@ module ApplicationHelper
end
time_tag(text, time, class: klass)
else
time_tag("in " + distance_of_time_in_words(Time.now, time), time)
elsif time.future?
if compact
text = distance_of_time_in_words(Time.now, time)
text = text.gsub(/almost|about|over/, "").gsub(/less than a/, "<1").strip
time_tag(text, time)
else
time_tag("in " + distance_of_time_in_words(Time.now, time), time)
end
end
end

View File

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

View File

@@ -437,7 +437,9 @@ class User < ApplicationRecord
end
def tag_query_limit(level)
if level >= User::Levels::BUILDER
if level >= User::Levels::MEMBER && Danbooru.config.is_promotion?
Float::INFINITY
elsif level >= User::Levels::BUILDER
Float::INFINITY
elsif level == User::Levels::PLATINUM
12

View File

@@ -37,7 +37,11 @@ class UserUpgrade < ApplicationRecord
end
def self.gold_price
2000
if Danbooru.config.is_promotion?
1500
else
2000
end
end
def self.platinum_price
@@ -161,6 +165,9 @@ class UserUpgrade < ApplicationRecord
price: price_id,
quantity: 1,
}],
discounts: [{
coupon: promotion_discount_id,
}],
metadata: {
user_upgrade_id: id,
purchaser_id: purchaser.id,
@@ -218,6 +225,12 @@ class UserUpgrade < ApplicationRecord
!pending?
end
def promotion_discount_id
if Danbooru.config.is_promotion?
Danbooru.config.stripe_promotion_discount_id
end
end
def upgrade_price_id(currency)
case [upgrade_type, currency]
when ["gold", "usd"]

View File

@@ -80,7 +80,20 @@
<div id="page">
<%= render "users/verification_notice" %>
<% if !CurrentUser.is_anonymous? && !CurrentUser.is_gold? && !CurrentUser.user.is_banned? && 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-small flex text-center items-center justify-center gap-2" id="promotion-notice">
<% file = %w[provgift.png kemogift.png padoru.gif ablobgift.gif].sample %>
<%= tag.img src: "/images/#{file}", width: 32, height: 32 %>
<span>
<%= link_to "Danbooru Winter Sale", forum_topic_path(Danbooru.config.winter_sale_forum_topic_id) %> ends <%= time_ago_in_words_tagged(Danbooru.config.winter_sale_end_date) %>!
<br>
<%= link_to "Get 25% off Gold & Platinum", new_user_upgrade_path %>
</span>
<span>(<%= link_to "hide", "#", id: "hide-promotion-notice" %>)</span>
</div>
<% elsif !CurrentUser.is_anonymous? && !CurrentUser.is_gold? && !CurrentUser.user.is_banned? && cookies[:hide_upgrade_account_notice].blank? && params[:action] != "upgrade_information" %>
<%= render "users/upgrade_notice" %>
<% end %>

View File

@@ -26,6 +26,14 @@
their profile page and look for a "Gift Upgrade" link.</p>
<% end %>
<% if Danbooru.config.is_promotion? %>
<p>
<%= tag.img src: "/images/padoru.gif", width: 24, height: 24 %>
<b>Danbooru Winter Sale! Gold and Platinum upgrades are 25% off. Sale ends <%= time_ago_in_words_tagged(Time.utc("2022-01-01")) %>.</b>
<%= tag.img src: "/images/padoru.gif", width: 24, height: 24 %>
</p>
<% end %>
<table id="feature-comparison" class="w-full text-center table-md mt-8 mb-8">
<thead>
<tr>
@@ -44,19 +52,25 @@
<td></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>
</tr>
<tr>
<td>Tag Limit</td>
<td><%= User.tag_query_limit(User::Levels::MEMBER) %></td>
<td><%= User.tag_query_limit(User::Levels::GOLD) %></td>
<td><%= User.tag_query_limit(User::Levels::PLATINUM) %></td>
<td>2</td>
<td>6</td>
<td>12</td>
</tr>
<tr>
<td>See Hidden Tags</td>

View File

@@ -516,6 +516,19 @@ module Danbooru
# https://docs.newrelic.com/docs/accounts/accounts-billing/account-setup/new-relic-license-key/
def new_relic_license_key
end
# True if the Winter Sale is active.
def is_promotion?
false
end
# The end date of the Winter Sale.
def winter_sale_end_date
end
# The forum topic linked to in the Winter Sale notice.
def winter_sale_forum_topic_id
end
end
EnvironmentConfiguration = Struct.new(:config) do

BIN
public/images/blobgift.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
public/images/kemogift.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
public/images/padoru.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
public/images/provgift.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB