Skip to content

Commit

Permalink
Merge pull request #202 from archesproject/jtw/create-blank-parent
Browse files Browse the repository at this point in the history
Create a blank parent for scheme right statement updates
  • Loading branch information
njkim authored Jan 31, 2025
2 parents 9668167 + f065e0a commit df8dbde
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions arches_lingo/serializers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.utils.translation import gettext as _
from rest_framework.exceptions import ValidationError

from arches_references.models import ListItem

from arches.app.models.models import ResourceInstance, TileModel
from arches.app.models.serializers import ArchesModelSerializer, ArchesTileSerializer
from arches.app.models.tile import Tile
from arches_references.models import ListItem


class SchemeStatementSerializer(ArchesTileSerializer):
Expand Down Expand Up @@ -57,6 +57,13 @@ def repair_right_statement(self, instance):
# Shouldn't need to refresh_from_db() here, but I'll (jtw)
# look into that later, since this is all just a workaround.
instance.refresh_from_db()
if not instance.rights:
instance.rights = Tile.get_blank_tile_from_nodegroup_id(
instance.right_statement.nodegroup.parentnodegroup_id,
resourceid=instance.resourceinstanceid,
)
instance.rights.save()

instance.right_statement.parenttile = instance.rights
instance.right_statement.save()
return instance
Expand Down

0 comments on commit df8dbde

Please sign in to comment.