add ability for admin to delete any topics and synapses
This commit is contained in:
parent
9ce81df9f9
commit
499f6349e6
4 changed files with 10 additions and 9 deletions
|
@ -2776,7 +2776,7 @@ Metamaps.Control = {
|
|||
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
|
||||
var topic = node.getData('topic');
|
||||
|
||||
var permToDelete = Metamaps.Active.Mapper.id === topic.get('user_id');
|
||||
var permToDelete = Metamaps.Active.Mapper.id === topic.get('user_id') || Metamaps.Active.Mapper.get('admin');
|
||||
if (permToDelete) {
|
||||
var topicid = topic.id;
|
||||
var mapping = node.getData('mapping');
|
||||
|
@ -2945,7 +2945,7 @@ Metamaps.Control = {
|
|||
var synapse = edge.getData("synapses")[index];
|
||||
var mapping = edge.getData("mappings")[index];
|
||||
|
||||
var permToDelete = Metamaps.Active.Mapper.id === synapse.get('user_id');
|
||||
var permToDelete = Metamaps.Active.Mapper.id === synapse.get('user_id') || Metamaps.Active.Mapper.get('admin');
|
||||
if (permToDelete) {
|
||||
if (edge.getData("synapses").length - 1 === 0) {
|
||||
Metamaps.Control.hideEdge(edge);
|
||||
|
|
|
@ -41,10 +41,10 @@ class Synapse < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def authorize_to_delete(user)
|
||||
if (self.user != user)
|
||||
return false
|
||||
if (self.user == user || user.admin)
|
||||
return self
|
||||
end
|
||||
return self
|
||||
return false
|
||||
end
|
||||
|
||||
# returns Boolean if user allowed to view Topic, Synapse, or Map
|
||||
|
|
|
@ -112,10 +112,10 @@ class Topic < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def authorize_to_delete(user)
|
||||
if (self.user != user)
|
||||
return false
|
||||
if (self.user == user || user.admin)
|
||||
return self
|
||||
end
|
||||
return self
|
||||
return false
|
||||
end
|
||||
|
||||
# returns Boolean if user allowed to view Topic, Synapse, or Map
|
||||
|
|
|
@ -45,7 +45,8 @@ class User < ActiveRecord::Base
|
|||
def as_json(options={})
|
||||
{ :id => self.id,
|
||||
:name => self.name,
|
||||
:image => self.image.url(:sixtyfour)
|
||||
:image => self.image.url(:sixtyfour),
|
||||
:admin => self.admin
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue