cleanup topic model a bit
This commit is contained in:
parent
86b79c1e55
commit
9e4a7b821f
1 changed files with 9 additions and 15 deletions
|
@ -39,27 +39,27 @@ class Topic < ActiveRecord::Base
|
||||||
belongs_to :metacode
|
belongs_to :metacode
|
||||||
|
|
||||||
def user_name
|
def user_name
|
||||||
self.user.name
|
user.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_image
|
def user_image
|
||||||
self.user.image.url
|
user.image.url
|
||||||
end
|
end
|
||||||
|
|
||||||
def map_count
|
def map_count
|
||||||
self.maps.count
|
maps.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def synapse_count
|
def synapse_count
|
||||||
self.synapses.count
|
synapses.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def inmaps
|
def inmaps
|
||||||
self.maps.map(&:name)
|
maps.map(&:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def inmapsLinks
|
def inmapsLinks
|
||||||
self.maps.map(&:id)
|
maps.map(&:id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json(options={})
|
def as_json(options={})
|
||||||
|
@ -71,24 +71,18 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def mk_permission
|
def mk_permission
|
||||||
if self.permission == "commons"
|
Perm.short(permission)
|
||||||
"co"
|
|
||||||
elsif self.permission == "public"
|
|
||||||
"pu"
|
|
||||||
elsif self.permission == "private"
|
|
||||||
"pr"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# has no viewable synapses helper function
|
# has no viewable synapses helper function
|
||||||
def has_viewable_synapses(current)
|
def has_viewable_synapses(current)
|
||||||
result = false
|
result = false
|
||||||
self.synapses.each do |synapse|
|
synapses.each do |synapse|
|
||||||
if synapse.authorize_to_view(current)
|
if synapse.authorize_to_view(current)
|
||||||
result = true
|
result = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
##### PERMISSIONS ######
|
##### PERMISSIONS ######
|
||||||
|
|
Loading…
Reference in a new issue