user upgrades: factor out gold/platinum prices.
This commit is contained in:
@@ -30,13 +30,13 @@ class UserUpgradesController < ApplicationController
|
|||||||
|
|
||||||
if params[:desc] == "Upgrade to Gold"
|
if params[:desc] == "Upgrade to Gold"
|
||||||
level = User::Levels::GOLD
|
level = User::Levels::GOLD
|
||||||
cost = 2000
|
cost = UserUpgrade.gold_price
|
||||||
elsif params[:desc] == "Upgrade to Platinum"
|
elsif params[:desc] == "Upgrade to Platinum"
|
||||||
level = User::Levels::PLATINUM
|
level = User::Levels::PLATINUM
|
||||||
cost = 4000
|
cost = UserUpgrade.platinum_price
|
||||||
elsif params[:desc] == "Upgrade Gold to Platinum" && @user.level == User::Levels::GOLD
|
elsif params[:desc] == "Upgrade Gold to Platinum" && @user.level == User::Levels::GOLD
|
||||||
level = User::Levels::PLATINUM
|
level = User::Levels::PLATINUM
|
||||||
cost = 2000
|
cost = UserUpgrade.upgrade_price
|
||||||
else
|
else
|
||||||
raise "Invalid desc"
|
raise "Invalid desc"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,4 +18,8 @@ module UserUpgradesHelper
|
|||||||
|
|
||||||
raw(html)
|
raw(html)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cents_to_usd(cents)
|
||||||
|
number_to_currency(cents / 100, precision: 0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
13
app/logical/user_upgrade.rb
Normal file
13
app/logical/user_upgrade.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
class UserUpgrade
|
||||||
|
def self.gold_price
|
||||||
|
2000
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.platinum_price
|
||||||
|
4000
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.upgrade_price
|
||||||
|
2000
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
<p>You can pay with a credit or debit card. Safebooru uses <a href="https://www.stripe.com">Stripe</a> as a payment intermediary so none of your personal information will be stored on the site.</p>
|
<p>You can pay with a credit or debit card. Safebooru uses <a href="https://www.stripe.com">Stripe</a> as a payment intermediary so none of your personal information will be stored on the site.</p>
|
||||||
|
|
||||||
<% if user.level < User::Levels::GOLD %>
|
<% if user.level < User::Levels::GOLD %>
|
||||||
<%= stripe_button("Upgrade to Gold", 2000, user) %>
|
<%= stripe_button("Upgrade to Gold", UserUpgrade.gold_price, user) %>
|
||||||
<%= stripe_button("Upgrade to Platinum", 4000, user) %>
|
<%= stripe_button("Upgrade to Platinum", UserUpgrade.platinum_price, user) %>
|
||||||
<% elsif user.level < User::Levels::PLATINUM %>
|
<% elsif user.level < User::Levels::PLATINUM %>
|
||||||
<%= stripe_button("Upgrade Gold to Platinum", 2000, user) %>
|
<%= stripe_button("Upgrade Gold to Platinum", UserUpgrade.upgrade_price, user) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Cost</td>
|
<td>Cost</td>
|
||||||
<td>Free</td>
|
<td>Free</td>
|
||||||
<td>$20<div class="fineprint">One time fee</div></td>
|
<td>
|
||||||
<td>$40<div class="fineprint">One time fee</div></td>
|
<%= cents_to_usd(UserUpgrade.gold_price) %>
|
||||||
|
<div class="fineprint">One time fee</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= cents_to_usd(UserUpgrade.platinum_price) %>
|
||||||
|
<div class="fineprint">One time fee</div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Tag Limit</td>
|
<td>Tag Limit</td>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div class="notice notice-info notice-large" id="upgrade-account-notice">
|
<div class="notice notice-info notice-large" id="upgrade-account-notice">
|
||||||
<h2><%= link_to "Upgrade your account for only $20!", new_user_upgrade_path, id: "goto-upgrade-account" %></h2>
|
<h2><%= link_to "Upgrade your account for only #{cents_to_usd(UserUpgrade.gold_price)}!", new_user_upgrade_path, id: "goto-upgrade-account" %></h2>
|
||||||
<div><%= link_to "No thanks", "#", id: "hide-upgrade-account-notice" %></div>
|
<div><%= link_to "No thanks", "#", id: "hide-upgrade-account-notice" %></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user