Almost ready to merge
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Conference < ActiveRecord::Base
|
||||
translates :info
|
||||
translates :info, :title
|
||||
|
||||
mount_uploader :cover, CoverUploader
|
||||
mount_uploader :poster, PosterUploader
|
||||
@@ -19,10 +19,13 @@ class Conference < ActiveRecord::Base
|
||||
def to_param
|
||||
slug
|
||||
end
|
||||
#
|
||||
#def self.find_by_param(slug)
|
||||
# find_by_slug_and_conference_type(slug, ConferenceType.find_by_slug('regional').id)
|
||||
#end
|
||||
|
||||
def host?(user)
|
||||
organizations.each do |o|
|
||||
return true if o.host?(user)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def url(action = :show)
|
||||
path(action)
|
||||
|
||||
@@ -29,6 +29,14 @@ class Organization < ActiveRecord::Base
|
||||
slug
|
||||
end
|
||||
|
||||
def host?(user)
|
||||
return false unless user.present?
|
||||
users.each do |u|
|
||||
return true if u.id == user.id
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def generate_slug(name, location = nil)
|
||||
s = name.gsub(/[^a-z1-9]+/i, '-').chomp('-').gsub(/\-([A-Z])/, '\1')
|
||||
if Organization.find_by(:slug => s).present? && !location.nil?
|
||||
|
||||
@@ -12,6 +12,29 @@ class Workshop < ActiveRecord::Base
|
||||
slug
|
||||
end
|
||||
|
||||
def role(user)
|
||||
workshop_facilitators.each do |u|
|
||||
return u.role.to_sym if u.user_id == user.id
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def facilitator?(user)
|
||||
!!role(user)
|
||||
end
|
||||
|
||||
def creator?(user)
|
||||
role(user) == :creator
|
||||
end
|
||||
|
||||
def can_edit?(user)
|
||||
creator?(user)
|
||||
end
|
||||
|
||||
def can_delete?(user)
|
||||
creator?(user)
|
||||
end
|
||||
|
||||
private
|
||||
def make_slug
|
||||
if !self.slug
|
||||
|
||||
Reference in New Issue
Block a user