Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure part tiles are removed post deletion #1588

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arches_for_science/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ class ArchesForScienceConfig(AppConfig):

def ready(self):
generate_frontend_configuration()
from . import signals
19 changes: 1 addition & 18 deletions arches_for_science/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import uuid

from arches.app.models.models import IIIFManifest, TileModel, FunctionXGraph
from arches.app.models.models import TileModel, FunctionXGraph
from django.db import models
from django.db.models import JSONField
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
import pgtrigger

from .trigger_functions import CALCULATE_MULTICARD_PRIMARY_DESCRIPTOR_SINGLE, CALCULATE_MULTICARD_PRIMARY_DESCRIPTOR_ALL
Expand Down Expand Up @@ -82,17 +79,3 @@ class ManifestXCanvas(models.Model):
class Meta:
managed = True
db_table = "manifest_x_canvas"


@receiver(post_save, sender=IIIFManifest)
def create_digital_resources(sender, instance, created, **kwargs):
from arches_for_science.utils.digital_resource_for_manifest import digital_resources_for_manifest, digital_resources_for_canvases

digital_resources_for_manifest(instance, created)
digital_resources_for_canvases(instance)


@receiver(post_delete, sender=IIIFManifest)
def delete_manifest_x_canvas(sender, instance, **kwargs):
ManifestXCanvas.objects.filter(manifest=instance.manifest["@id"]).delete()
ManifestXDigitalResource.objects.filter(manifest=instance.manifest["@id"]).delete()
30 changes: 30 additions & 0 deletions arches_for_science/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from arches.app.models.models import IIIFManifest, ResourceXResource
from arches.app.models.resource import Resource
from .models import ManifestXCanvas, ManifestXDigitalResource
import uuid


@receiver(post_save, sender=IIIFManifest)
def create_digital_resources(sender, instance, created, **kwargs):
from arches_for_science.utils.digital_resource_for_manifest import digital_resources_for_manifest, digital_resources_for_canvases

digital_resources_for_manifest(instance, created)
digital_resources_for_canvases(instance)


@receiver(post_delete, sender=IIIFManifest)
def delete_manifest_x_canvas(sender, instance, **kwargs):
ManifestXCanvas.objects.filter(manifest=instance.manifest["@id"]).delete()
ManifestXDigitalResource.objects.filter(manifest=instance.manifest["@id"]).delete()


@receiver(post_delete, sender=ResourceXResource)
def ensure_part_tile_is_deleted(sender, instance, **kwargs):
physical_thing_parts_node_id = uuid.UUID("b240c366-8594-11ea-97eb-acde48001122")
if instance.nodeid_id == physical_thing_parts_node_id:
instance.tileid.delete()
resourceid = instance.tileid.resourceinstance_id
resource = Resource.objects.get(pk=resourceid)
resource.index()
3 changes: 2 additions & 1 deletion releases/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

### Bug Fixes and Enhancements

- Upgrades Arches for Science to work with the latest Arches 7.6.x release #[1570](https://github.com/archesproject/arches-for-science/pull/1570)
- Upgrades Arches for Science to work with the latest Arches 7.6.x release [#1570](https://github.com/archesproject/arches-for-science/pull/1570)
- Automatically delete part tiles when analysis and sample areas are deleted [#1588](https://github.com/archesproject/arches-for-science/pull/1588)

### Dependency changes:

Expand Down
Loading