Class: Spree::AuctionsController

Inherits:
StoreController
  • Object
show all
Defined in:
app/controllers/spree/auctions_controller.rb

Instance Method Summary collapse

Instance Method Details

#ending_soonObject



15
16
17
18
# File 'app/controllers/spree/auctions_controller.rb', line 15

def ending_soon
  @auctions = Spree::Auction.incomplete.ending_soon
  render :index
end

#indexObject



6
7
8
# File 'app/controllers/spree/auctions_controller.rb', line 6

def index
  @auctions = Spree::Auction.in_progress.incomplete.current_end_datetime_ascending
end

#recently_completedObject



20
21
22
23
# File 'app/controllers/spree/auctions_controller.rb', line 20

def recently_completed
  @auctions = Spree::Auction.recently_completed
  render :index
end

#showObject



25
26
27
28
29
# File 'app/controllers/spree/auctions_controller.rb', line 25

def show
  @auction = Spree::Auction.find(params[:id])
  @product = @auction.product
  @product_properties = @product.product_properties.includes(:property)
end

#starting_soonObject



10
11
12
13
# File 'app/controllers/spree/auctions_controller.rb', line 10

def starting_soon
  @auctions = Spree::Auction.incomplete.starting_soon.starting_datetime_ascending
  render :index
end

#vote_countObject



31
32
33
34
35
# File 'app/controllers/spree/auctions_controller.rb', line 31

def vote_count
  auction = Spree::Auction.find_by(id: params[:auction_id])
  votes = auction.cached_votes_up
  render json: { votes: votes }
end

#vote_downObject



45
46
47
48
49
50
51
# File 'app/controllers/spree/auctions_controller.rb', line 45

def vote_down
  auction = Spree::Auction.find_by(id: params[:auction_id])
  user = Spree::User.find_by(id: params[:user_id])
  auction.downvote_from user
  votes = auction.cached_votes_up
  render json: { votes: votes, voted_for: 0 }
end

#vote_upObject



37
38
39
40
41
42
43
# File 'app/controllers/spree/auctions_controller.rb', line 37

def vote_up
  auction = Spree::Auction.find_by(id: params[:auction_id])
  user = Spree::User.find_by(id: params[:user_id])
  auction.liked_by user
  votes = auction.cached_votes_up
  render json: { votes: votes, voted_for: 1 }
end