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 @@
-

Upgrade Your Account

+

Upgrade Account

-

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.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BasicGoldPlatinum
CostFree$20

One time fee

$40

One time fee

Tag Limit2612
Favorite Limit10,00020,000Unlimited
Page Limit1,0002,0005,000
Tag SubscriptionsNoYesYes
See Censored TagsNoYesYes
API Hourly Limit3,00010,00020,000
Database Timeout3 sec6 sec9 sec
Variable Posts Per PageNoYesYes
Name ChangesNoYesYes
-
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BasicGoldPlatinum
CostFree$20

One time fee

$40

One time fee

Tag Limit2612
Favorite Limit10,00020,000Unlimited
Page Limit1,0002,0005,000
Tag SubscriptionsNoYesYes
See Censored TagsNoYesYes
API Hourly Limit3,00010,00020,000
Database Timeout3 sec6 sec9 sec
Variable Posts Per PageNoYesYes
Name ChangesNoYesYes
+
+ <% end %> <% if Danbooru.config.coinbase_api_key %> <%= render "coinbase_payment" %> diff --git a/app/views/users/_secondary_links.html.erb b/app/views/users/_secondary_links.html.erb index d08d9d25b..0e6559bfb 100644 --- a/app/views/users/_secondary_links.html.erb +++ b/app/views/users/_secondary_links.html.erb @@ -22,7 +22,11 @@ <% end %> <% if CurrentUser.is_member? || CurrentUser.is_gold? %> -
  • <%= link_to "Upgrade", new_user_upgrade_path %>
  • + <% if @user.id == CurrentUser.user.id %> +
  • <%= link_to "Upgrade", new_user_upgrade_path %>
  • + <% else %> +
  • <%= link_to "Gift Upgrade", new_user_upgrade_path(:user_id => @user.id) %>
  • + <% end %> <% end %> <% if CurrentUser.is_moderator? %>