Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3-1-stable] Move decorator file inside controllers/spree folder #14

Open
wants to merge 1 commit into
base: 3-1-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions app/controllers/spree/users_controller_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Spree::UsersController.class_eval do

prepend_before_action :affiliate_user, only: :update
before_action :load_referred_records, only: :referral_details

def referral_details
end

private

def load_object
if @affiliate
@user ||= @affiliate_user
else
@user ||= spree_current_user
authorize! params[:action].to_sym, @user
end
end

def affiliate_user
if params[:activation_token]
@affiliate ||= Spree::Affiliate.find_by(activation_token: params[:activation_token])
(redirect_to root_path, error: Spree.t(:affiliate_not_found) and return) unless @affiliate
@affiliate_user ||= Spree::User.find_by(email: @affiliate.email)
@affiliate_user.can_activate_associated_partner = true
end
end

def load_referred_records
@referred_records = spree_current_user.referral.referred_records.order({ created_at: :desc }).
page(params[:page]).per(params[:per_page] || Spree::Config[:referred_records_per_page])
end

end
32 changes: 0 additions & 32 deletions app/controllers/users_controller_decorator.rb

This file was deleted.