mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 21:10:54 +00:00
4c7041e4b3
This will change the gather format to allow for players to volunteer to be captain / commander. The gather will not change from the running state until 2 commanders have volunteered. Once commanders have volunteered the gather will switch to the picking state. The voting state is no longer used. Also, added a new sound alert that will be played when the gather is full but doesn't have 2 captains. This alert will loop every 10 seconds unless you're the commander. And changed the music to play once the gather switches to the picking state and only if the player doesn't have the gather page on focus.
60 lines
1.5 KiB
Ruby
60 lines
1.5 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: shoutmsgs
|
|
#
|
|
# id :integer not null, primary key
|
|
# user_id :integer
|
|
# text :string(255)
|
|
# created_at :datetime
|
|
# updated_at :datetime
|
|
# shoutable_type :string(255)
|
|
# shoutable_id :integer
|
|
#
|
|
|
|
class Shoutmsg < ActiveRecord::Base
|
|
include Extra
|
|
|
|
attr_protected :id, :created_at, :updated_at, :user_id
|
|
|
|
validates_length_of :text, :in => 1..100
|
|
|
|
scope :recent,
|
|
:include => :user,
|
|
:order => "id DESC",
|
|
:limit => 8
|
|
scope :box,
|
|
:conditions => "shoutable_type IS NULL AND shoutable_id IS NULL",
|
|
:limit => 8
|
|
scope :typebox,
|
|
:conditions => "shoutable_type IS NULL AND shoutable_id IS NULL"
|
|
scope :lastXXX,
|
|
:include => :user,
|
|
:order => "id DESC",
|
|
:limit => 500
|
|
scope :of_object,
|
|
lambda { |object, id| {:conditions => {:shoutable_type => object, :shoutable_id => id}} }
|
|
scope :ordered, :order => "id"
|
|
|
|
belongs_to :user
|
|
belongs_to :shoutable, :polymorphic => true
|
|
|
|
def domain
|
|
self[:shoutable_type] ? "shout_#{shoutable_type}_#{shoutable_id}" : "shoutbox"
|
|
end
|
|
|
|
def can_create? cuser
|
|
cuser and !user.banned?(Ban::TYPE_MUTE) and cuser.verified?
|
|
end
|
|
|
|
def can_destroy? cuser
|
|
cuser and cuser.admin?
|
|
end
|
|
|
|
def self.flood? cuser, type = nil, id = nil
|
|
return false if self.of_object(type, id).count < 3
|
|
self.of_object(type, id).all(:order => "created_at DESC", :limit => 10).each do |msg|
|
|
return false if cuser != msg.user
|
|
end
|
|
return true
|
|
end
|
|
end
|