diff --git a/app/controllers/user_upgrades_controller.rb b/app/controllers/user_upgrades_controller.rb index 9204c8977..60c9eb087 100644 --- a/app/controllers/user_upgrades_controller.rb +++ b/app/controllers/user_upgrades_controller.rb @@ -1,17 +1,17 @@ class UserUpgradesController < ApplicationController before_filter :member_only, :only => [:new, :show] - helper_method :encrypt_custom, :coinbase + helper_method :encrypt_custom, :coinbase, :user force_ssl :if => :ssl_enabled? skip_before_action :verify_authenticity_token, only: [:create] def create if params[:order][:status] == "completed" user_id, level = decrypt_custom - user = User.find(user_id) + member = User.find(user_id) - if user.level < User::Levels::PLATINUM && level >= User::Levels::GOLD && level <= User::Levels::PLATINUM + if member.level < User::Levels::PLATINUM && level >= User::Levels::GOLD && level <= User::Levels::PLATINUM CurrentUser.scoped(User.admins.first, "127.0.0.1") do - user.promote_to!(level, :skip_feedback => true) + member.promote_to!(level, :skip_feedback => true) end end end @@ -25,17 +25,28 @@ class UserUpgradesController < ApplicationController end end + def gift + end + def show end def encrypt_custom(level) - crypt.encrypt_and_sign("#{CurrentUser.user.id},#{level}") + crypt.encrypt_and_sign("#{user.id},#{level}") end def coinbase @coinbase_api ||= Coinbase::Client.new(Danbooru.config.coinbase_api_key, Danbooru.config.coinbase_api_secret) end + def user + if params[:user_id] + User.find(params[:user_id]) + else + CurrentUser.user + end + end + private def decrypt_custom diff --git a/app/views/user_upgrades/_coinbase_payment.html.erb b/app/views/user_upgrades/_coinbase_payment.html.erb index 0a3c0e0ea..e6b378395 100644 --- a/app/views/user_upgrades/_coinbase_payment.html.erb +++ b/app/views/user_upgrades/_coinbase_payment.html.erb @@ -1,8 +1,14 @@
You can pay with Bitcoin. You will pay either $20 USD or $40 USD equivalent in Bitcoin. Danbooru uses Coinbase as a payment intermediary so none of your personal information will be stored on the site.
-<% if CurrentUser.user.level < User::Levels::GOLD %> +<% if params[:user_id] %> +You are gifting this account upgrade to <%= link_to user.pretty_name, user_path(params[:user_id]) %>.
+<% else %> +You can also upgrade someone else's account for the same price. The easiest way is to go to their profile page and look for a "Gift Upgrade" link.
+<% end %> + +<% if user.level < User::Levels::GOLD %> <%= raw coinbase.create_button("Upgrade to Gold", 20.to_money("USD"), "Upgrade your Basic Account to a Gold Account", encrypt_custom(User::Levels::GOLD), :button => {:style => "custom_small", :text => "Upgrade to Gold", :callback_url => user_upgrade_path(:only_path => false, :host => Danbooru.config.hostname, :protocol => "https")}).embed_html %> <%= raw coinbase.create_button("Upgrade to Platinum", 40.to_money("USD"), "Upgrade your Basic Account to a Platinum Account", encrypt_custom(User::Levels::PLATINUM), :button => {:style => "custom_small", :text => "Upgrade to Platinum", :callback_url => user_upgrade_path(:only_path => false, :host => Danbooru.config.hostname, :protocol => "https")}).embed_html %> -<% elsif CurrentUser.level < User::Levels::PLATINUM %> +<% elsif user.level < User::Levels::PLATINUM %> <%= raw coinbase.create_button("Upgrade to Platinum", 20.to_money("USD"), "Upgrade your Gold Account to a Platinum Account", encrypt_custom(User::Levels::PLATINUM), :button => {:style => "custom_small", :text => "Upgrade to Platinum", :callback_url => user_upgrade_path(:only_path => false, :host => Danbooru.config.hostname, :protocol => "https")}).embed_html %> <% end %> diff --git a/app/views/user_upgrades/new.html.erb b/app/views/user_upgrades/new.html.erb index b0187e501..97b95c17a 100644 --- a/app/views/user_upgrades/new.html.erb +++ b/app/views/user_upgrades/new.html.erb @@ -1,87 +1,89 @@Annoyed by ads? Want more searching power? Upgrade your account and become a power user of the best database of anime artwork on the internet.
+ <% unless params[:user_id] %> +Annoyed by ads? Want more searching power? Upgrade your account and become a power user of the best database of anime artwork on the internet.
-| - | Basic | -Gold | -Platinum | -
|---|---|---|---|
| Cost | -Free | -$20 One time fee |
- $40 One time fee |
-
| Tag Limit | -2 | -6 | -12 | -
| Favorite Limit | -10,000 | -20,000 | -Unlimited | -
| Page Limit | -1,000 | -2,000 | -5,000 | -
| Tag Subscriptions | -No | -Yes | -Yes | -
| See Censored Tags | -No | -Yes | -Yes | -
| API Hourly Limit | -3,000 | -10,000 | -20,000 | -
| Database Timeout | -3 sec | -6 sec | -9 sec | -
| Variable Posts Per Page | -No | -Yes | -Yes | -
| Name Changes | -No | -Yes | -Yes | -
| + | Basic | +Gold | +Platinum | +
|---|---|---|---|
| Cost | +Free | +$20 One time fee |
+ $40 One time fee |
+
| Tag Limit | +2 | +6 | +12 | +
| Favorite Limit | +10,000 | +20,000 | +Unlimited | +
| Page Limit | +1,000 | +2,000 | +5,000 | +
| Tag Subscriptions | +No | +Yes | +Yes | +
| See Censored Tags | +No | +Yes | +Yes | +
| API Hourly Limit | +3,000 | +10,000 | +20,000 | +
| Database Timeout | +3 sec | +6 sec | +9 sec | +
| Variable Posts Per Page | +No | +Yes | +Yes | +
| Name Changes | +No | +Yes | +Yes | +