2017-05-01 14:57:32 +00:00
|
|
|
class MatchProposal < ActiveRecord::Base
|
|
|
|
|
|
|
|
STATUS_PENDING = 0
|
|
|
|
STATUS_REVOKED = 1
|
|
|
|
STATUS_REJECTED = 2
|
2017-05-11 20:26:18 +00:00
|
|
|
STATUS_CONFIRMED = 3
|
2017-05-01 14:57:32 +00:00
|
|
|
|
|
|
|
belongs_to :match
|
|
|
|
belongs_to :team
|
|
|
|
attr_accessible :proposed_time, :status
|
|
|
|
|
|
|
|
validates_presence_of :match, :team, :proposed_time
|
|
|
|
|
2017-05-11 20:26:18 +00:00
|
|
|
def status_strings
|
|
|
|
{STATUS_PENDING => 'Pending',
|
|
|
|
STATUS_REVOKED => 'Revoked',
|
|
|
|
STATUS_REJECTED => 'Rejected',
|
|
|
|
STATUS_CONFIRMED => 'Confirmed'}
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_create? cuser
|
2017-06-04 18:30:33 +00:00
|
|
|
cuser && match && match.can_make_proposal?(cuser)
|
2017-05-11 20:26:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def can_update? cuser
|
2017-06-04 18:30:33 +00:00
|
|
|
cuser && match && match.can_make_proposal?(cuser)
|
2017-05-01 14:57:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def can_destroy?
|
|
|
|
cuser && cuser.admin?
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|