Getting at least one tournament working!

This commit is contained in:
Dan Buch
2012-03-12 00:18:42 -04:00
parent 73cff897a3
commit d08362326d
10 changed files with 66 additions and 79 deletions

View File

@@ -39,9 +39,12 @@ class MashTournamentsController < ApplicationController
@mash_tournament = MashTournament.new(
:requester => Requester.new(:ip => request.remote_ip)
)
respond_to do |format|
if @mash_tournament.save && @mash_tournament.create_rounds_for_contenders(8)
if @mash_tournament.save && (
@mash_tournament.builder.create_rounds_for_contenders(8) == 3
) && (
@mash_tournament.builder.fill_in_next_round.length == 4
)
flash[:notice] = "Let's start mashing!"
format.html { redirect_to :controller => 'mashes', :action => 'new' }
else

View File

@@ -24,27 +24,18 @@ class MashesController < ApplicationController
end
end
def create
def update
return if not already_registered?(request.remote_ip)
mash_params = params[:mash].clone
logger.info("Got params: #{params.inspect}")
requester = Requester.find_by_ip(request.remote_ip)
tournament = requester.mash_tournaments.first
mash_params[:tournament_id] = tournament.id
logger.info("Creating mash with: #{mash_params.inspect}")
@mash = Mash.new(mash_params)
@winner = Map.find(@mash.winner_id.to_i)
@winner.points += 1
@mash = Mash.find(params[:id])
@mash.winner = Map.find((params[:mash][:winner_id] || -1).to_i)
logger.info("About to save #{@mash.inspect}")
respond_to do |format|
if @winner.save && @mash.save
flash[:notice] = 'Mash was successfully created.'
if @mash.save
flash[:notice] = 'Mashed!'
format.html { redirect_to(:action => 'new') }
else
format.html { render :action => 'new' }