mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 04:21:36 +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
|
||||
end
|
||||
|
||||
if @contester.save!
|
||||
if @contester.save
|
||||
flash[:notice] = t(:contests_join)
|
||||
redirect_to contest_path(@contester.contest_id)
|
||||
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
|
||||
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_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_contest
|
||||
validate :validate_contest, :on => :create
|
||||
#validate_on_create:validate_playernumber
|
||||
|
||||
before_create :init_variables
|
||||
|
@ -87,8 +87,10 @@ class Contester < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def validate_contest
|
||||
if contest.end.past? or contest.status == Contest::STATUS_CLOSED
|
||||
errors.add :contest, I18n.t(:contests_closed)
|
||||
if contest.end.past?
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue