mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-05-31 00:41:20 +00:00
Purged git history and removed sensitive information.
This commit is contained in:
commit
6bcc8dc76b
862 changed files with 25312 additions and 0 deletions
39
app/models/map.rb
Normal file
39
app/models/map.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
class Map < ActiveRecord::Base
|
||||
include Extra
|
||||
|
||||
attr_protected :id, :updated_at, :created_at, :deleted
|
||||
|
||||
has_and_belongs_to_many :contests
|
||||
|
||||
scope :basic, :conditions => {:deleted => false}, :order => "name"
|
||||
scope :with_name, lambda { |name| {:conditions => {:name => name}} }
|
||||
scope :classic, :conditions => "name LIKE 'ns_%'"
|
||||
scope :of_category,
|
||||
lambda { |category| {
|
||||
:conditions => {:category_id => category.id} }}
|
||||
|
||||
validates_length_of :name, :maximum => 20
|
||||
validates_length_of :download, :maximum => 100
|
||||
|
||||
mount_uploader :picture, MapUploader
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
def destroy
|
||||
update_attribute :deleted, true
|
||||
end
|
||||
|
||||
def can_create? cuser
|
||||
cuser and cuser.admin?
|
||||
end
|
||||
|
||||
def can_update? cuser
|
||||
cuser and cuser.admin?
|
||||
end
|
||||
|
||||
def can_destroy? cuser
|
||||
cuser and cuser.admin?
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue