Skip to content

Commit

Permalink
#116 #162 Allow editing nodes containing resources
Browse files Browse the repository at this point in the history
  • Loading branch information
veuncent committed Jan 27, 2019
1 parent 0760026 commit 5b18604
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions arches/app/models/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,11 @@ def append_node(self, nodeid=None):

nodeToAppendTo = self.nodes[uuid.UUID(str(nodeid))] if nodeid else self.root
card = None
tile_count = models.TileModel.objects.filter(nodegroup_id=nodeToAppendTo.nodegroup_id).count()
if tile_count > 0:
raise GraphValidationError(_("Your resource model: {0}, already has instances saved. You cannot modify a Resource Model with instances.".format(self.name)), 1006)

if not settings.OVERRIDE_RESOURCE_MODEL_LOCK:
tile_count = models.TileModel.objects.filter(nodegroup_id=nodeToAppendTo.nodegroup_id).count()
if tile_count > 0:
raise GraphValidationError(_("Your resource model: {0}, already has instances saved. You cannot modify a Resource Model with instances.".format(self.name)), 1006)

nodegroup = None
if nodeToAppendTo.nodeid == self.root.nodeid and self.isresource is True:
Expand Down
7 changes: 6 additions & 1 deletion arches/app/views/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ def get(self, request, graphid):
'sortorder').all() for card in cards] for widget in widgets]
widgets = models.Widget.objects.all()
nodegroups = cards.values_list('nodegroup_id', flat=True)
restricted_nodegroups = models.TileModel.objects.filter(nodegroup__in=nodegroups).values_list('nodegroup_id', flat=True).distinct()

if settings.OVERRIDE_RESOURCE_MODEL_LOCK:
restricted_nodegroups = []
else:
restricted_nodegroups = models.TileModel.objects.filter(nodegroup__in=nodegroups).values_list('nodegroup_id', flat=True).distinct()

card_components = models.CardComponent.objects.all()
map_layers = models.MapLayer.objects.all()
map_markers = models.MapMarker.objects.all()
Expand Down

0 comments on commit 5b18604

Please sign in to comment.