From bae79283b74e365d9d2f1ed0cd709f4379986b1f Mon Sep 17 00:00:00 2001 From: henrikek Date: Wed, 6 Nov 2024 17:27:25 +0100 Subject: [PATCH] Change global search fields in IP views --- .../static/frontend/lang/en/general.ts | 2 +- .../static/frontend/lang/sv/general.ts | 2 +- ESSArch_Core/ip/filters.py | 1 + ESSArch_Core/ip/views.py | 3 +-- ...alter_tapeslot_unique_together_and_more.py | 26 +++++++++++++++++++ ESSArch_Core/storage/models.py | 3 +-- 6 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 ESSArch_Core/storage/migrations/0047_alter_tapeslot_unique_together_and_more.py diff --git a/ESSArch_Core/frontend/static/frontend/lang/en/general.ts b/ESSArch_Core/frontend/static/frontend/lang/en/general.ts index f7e2e86b6..12b0af592 100644 --- a/ESSArch_Core/frontend/static/frontend/lang/en/general.ts +++ b/ESSArch_Core/frontend/static/frontend/lang/en/general.ts @@ -157,7 +157,7 @@ const general = ($translateProvider) => { GLOBALSEARCH: 'search ...', GLOBALSEARCHDESC_ARCHIVE_CREATORS: 'List all authority records associated to the search term', GLOBALSEARCHDESC_ARCHIVES: 'List all resources associated to the search term', - GLOBALSEARCHDESC_IP: "List all IP's associated to the search term", + GLOBALSEARCHDESC_IP: "List all IP's thar starts with search term in fields Label or ID", GLOBALSEARCHDESC_MEDIUM_CONTENT: 'List all medium content associated to the search term', GLOBALSEARCHDESC_MEDIUM: 'List all storage mediums associated to the search term', GLOBALSEARCHDESC_MIGRATION: 'List all migrations associated to the search term', diff --git a/ESSArch_Core/frontend/static/frontend/lang/sv/general.ts b/ESSArch_Core/frontend/static/frontend/lang/sv/general.ts index 6daa805c6..ab6f621af 100644 --- a/ESSArch_Core/frontend/static/frontend/lang/sv/general.ts +++ b/ESSArch_Core/frontend/static/frontend/lang/sv/general.ts @@ -159,7 +159,7 @@ export default ($translateProvider: ng.translate.ITranslateProvider) => { GLOBALSEARCH: 'sök ...', GLOBALSEARCHDESC_ARCHIVE_CREATORS: 'Lista alla arkivbildare som associeras med söktermen', GLOBALSEARCHDESC_ARCHIVES: 'Lista alla arkiv som associeras med söktermen', - GLOBALSEARCHDESC_IP: 'Lista alla IPn som associeras med söktermen', + GLOBALSEARCHDESC_IP: 'Lista alla IPn som börjar med sökord i fälten Etikett eller ID', GLOBALSEARCHDESC_MEDIUM_CONTENT: 'Lista allt innehåll i lagringsmedium som associeras med söktermen', GLOBALSEARCHDESC_MEDIUM: 'Lista alla lagringsmedium som associeras med söktermen', GLOBALSEARCHDESC_MIGRATION: 'Lista alla migreringar som associeras med söktermen', diff --git a/ESSArch_Core/ip/filters.py b/ESSArch_Core/ip/filters.py index 3301ed408..1b1f34c28 100644 --- a/ESSArch_Core/ip/filters.py +++ b/ESSArch_Core/ip/filters.py @@ -60,6 +60,7 @@ class InformationPackageFilter(filters.FilterSet): field_name='submission_agreement__policy', distinct=False ) + label = filters.CharFilter(field_name='label', lookup_expr='istartswith') def exclude_package_type_name(self, queryset, name, value): for package_type_id, package_type_name in InformationPackage.PACKAGE_TYPE_CHOICES: diff --git a/ESSArch_Core/ip/views.py b/ESSArch_Core/ip/views.py index d5d8fced6..affff49d4 100644 --- a/ESSArch_Core/ip/views.py +++ b/ESSArch_Core/ip/views.py @@ -423,8 +423,7 @@ class InformationPackageViewSet(viewsets.ModelViewSet): 'id', 'object_identifier_value', 'start_date', 'end_date', ) search_fields = ( - '=id', 'object_identifier_value', 'label', - 'aic__object_identifier_value', 'aic__label', + '^object_identifier_value', '^label', ) filterset_class = InformationPackageFilter diff --git a/ESSArch_Core/storage/migrations/0047_alter_tapeslot_unique_together_and_more.py b/ESSArch_Core/storage/migrations/0047_alter_tapeslot_unique_together_and_more.py new file mode 100644 index 000000000..6e1d55ec2 --- /dev/null +++ b/ESSArch_Core/storage/migrations/0047_alter_tapeslot_unique_together_and_more.py @@ -0,0 +1,26 @@ +# Generated by Django 5.0.9 on 2024-11-01 09:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('storage', '0046_alter_accessqueue_id_alter_ioqueue_id_alter_robot_id_and_more'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='tapeslot', + unique_together={('slot_id', 'robot')}, + ), + migrations.AlterField( + model_name='tapeslot', + name='medium_id', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='The id for the medium, e.g. barcode'), + ), + migrations.AlterUniqueTogether( + name='tapeslot', + unique_together={('medium_id', 'robot'), ('slot_id', 'robot')}, + ), + ] diff --git a/ESSArch_Core/storage/models.py b/ESSArch_Core/storage/models.py index 1498ba44a..505af5771 100644 --- a/ESSArch_Core/storage/models.py +++ b/ESSArch_Core/storage/models.py @@ -1109,7 +1109,6 @@ class TapeSlot(models.Model): medium_id = models.CharField( "The id for the medium, e.g. barcode", max_length=255, - unique=True, blank=True, null=True, ) @@ -1147,7 +1146,7 @@ def create_from_remote_copy(cls, host, session, object_id, create_storage_medium class Meta: ordering = ('slot_id',) - unique_together = ('slot_id', 'robot') + unique_together = [['slot_id', 'robot'], ['medium_id', 'robot']] def __str__(self): return str(self.slot_id)