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 node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
|
||||||
var topic = node.getData('topic');
|
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) {
|
if (permToDelete) {
|
||||||
var topicid = topic.id;
|
var topicid = topic.id;
|
||||||
var mapping = node.getData('mapping');
|
var mapping = node.getData('mapping');
|
||||||
|
@ -2945,7 +2945,7 @@ Metamaps.Control = {
|
||||||
var synapse = edge.getData("synapses")[index];
|
var synapse = edge.getData("synapses")[index];
|
||||||
var mapping = edge.getData("mappings")[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 (permToDelete) {
|
||||||
if (edge.getData("synapses").length - 1 === 0) {
|
if (edge.getData("synapses").length - 1 === 0) {
|
||||||
Metamaps.Control.hideEdge(edge);
|
Metamaps.Control.hideEdge(edge);
|
||||||
|
|
|
@ -41,10 +41,10 @@ class Synapse < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def authorize_to_delete(user)
|
def authorize_to_delete(user)
|
||||||
if (self.user != user)
|
if (self.user == user || user.admin)
|
||||||
return false
|
return self
|
||||||
end
|
end
|
||||||
return self
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns Boolean if user allowed to view Topic, Synapse, or Map
|
# returns Boolean if user allowed to view Topic, Synapse, or Map
|
||||||
|
|
|
@ -112,10 +112,10 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def authorize_to_delete(user)
|
def authorize_to_delete(user)
|
||||||
if (self.user != user)
|
if (self.user == user || user.admin)
|
||||||
return false
|
return self
|
||||||
end
|
end
|
||||||
return self
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns Boolean if user allowed to view Topic, Synapse, or Map
|
# returns Boolean if user allowed to view Topic, Synapse, or Map
|
||||||
|
|
|
@ -45,7 +45,8 @@ class User < ActiveRecord::Base
|
||||||
def as_json(options={})
|
def as_json(options={})
|
||||||
{ :id => self.id,
|
{ :id => self.id,
|
||||||
:name => self.name,
|
:name => self.name,
|
||||||
:image => self.image.url(:sixtyfour)
|
:image => self.image.url(:sixtyfour),
|
||||||
|
:admin => self.admin
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue