mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 05:10:59 +00:00
Fixing contests with closed signups are still joinable
This commit is contained in:
parent
7baac43cbb
commit
60779b8c05
2 changed files with 7 additions and 5 deletions
|
@ -26,11 +26,11 @@ class ContestersController < ApplicationController
|
||||||
@contester.score = @contester.contest.contesters.active.count + 1
|
@contester.score = @contester.contest.contesters.active.count + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if @contester.save!
|
if @contester.save
|
||||||
flash[:notice] = t(:contests_join)
|
flash[:notice] = t(:contests_join)
|
||||||
redirect_to contest_path(@contester.contest_id)
|
redirect_to contest_path(@contester.contest_id)
|
||||||
else
|
else
|
||||||
flash[:error] = @contester.errors.full_messages.to_s #t(:errors) + @contester.errors.full_messages.to_s
|
flash[:error] = @contester.errors.full_messages[0]
|
||||||
redirect_to_back
|
redirect_to_back
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Contester < ActiveRecord::Base
|
||||||
validates_inclusion_of [:score, :win, :loss, :draw, :extra], :in => 0..9999, :allow_nil => true
|
validates_inclusion_of [:score, :win, :loss, :draw, :extra], :in => 0..9999, :allow_nil => true
|
||||||
validates_uniqueness_of :team_id, :scope => :contest_id, :message => "You can't join same contest twice."
|
validates_uniqueness_of :team_id, :scope => :contest_id, :message => "You can't join same contest twice."
|
||||||
#validate_on_create:validate_member_participation
|
#validate_on_create:validate_member_participation
|
||||||
#validate_on_create:validate_contest
|
validate :validate_contest, :on => :create
|
||||||
#validate_on_create:validate_playernumber
|
#validate_on_create:validate_playernumber
|
||||||
|
|
||||||
before_create :init_variables
|
before_create :init_variables
|
||||||
|
@ -87,8 +87,10 @@ class Contester < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_contest
|
def validate_contest
|
||||||
if contest.end.past? or contest.status == Contest::STATUS_CLOSED
|
if contest.end.past?
|
||||||
errors.add :contest, I18n.t(:contests_closed)
|
self.errors.add :base, "Cannot join contest! It is already over!"
|
||||||
|
elsif contest.status != Contest::STATUS_OPEN
|
||||||
|
self.errors.add :base, "Cannot join contest! Signups are closed!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue