2017-05-01 14:57:32 +00:00
|
|
|
class MatchProposalsController < ApplicationController
|
2017-06-04 18:30:33 +00:00
|
|
|
before_filter :get_match
|
2017-05-01 14:57:32 +00:00
|
|
|
def index
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
2017-06-04 18:30:33 +00:00
|
|
|
@proposal = MatchProposal.new
|
|
|
|
@proposal.match = @match
|
2017-05-11 20:26:18 +00:00
|
|
|
raise AccessError unless @proposal.can_create? cuser
|
2017-05-01 14:57:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2017-06-04 18:30:33 +00:00
|
|
|
@proposal = MatchProposal.new(params[:match_proposal])
|
|
|
|
@proposal.match = @match
|
|
|
|
raise AccessError unless @proposal.can_create? cuser
|
2017-05-11 20:26:18 +00:00
|
|
|
@proposal.team = cuser.team
|
|
|
|
@proposal.status = MatchProposal::STATUS_PENDING
|
|
|
|
|
2017-06-04 18:30:33 +00:00
|
|
|
if @proposal.save!
|
2017-05-11 20:26:18 +00:00
|
|
|
flash[:notice] = 'Created new proposal'
|
2017-06-04 18:30:33 +00:00
|
|
|
redirect_to(@match)
|
2017-05-11 20:26:18 +00:00
|
|
|
else
|
|
|
|
render :new
|
|
|
|
end
|
2017-05-01 14:57:32 +00:00
|
|
|
end
|
2017-05-11 20:26:18 +00:00
|
|
|
|
|
|
|
def update
|
|
|
|
end
|
|
|
|
|
2017-06-04 18:30:33 +00:00
|
|
|
private
|
|
|
|
def get_match
|
|
|
|
@match = Match.find params[:match_id]
|
|
|
|
end
|
2017-05-01 14:57:32 +00:00
|
|
|
end
|