From 1e057a3875c998baa2b9ab3b142cfa6b80721574 Mon Sep 17 00:00:00 2001 From: Ben Silverman Date: Tue, 5 Dec 2023 14:46:00 -0500 Subject: [PATCH] Fix RelatedLink uuid errors on save/change --- apps/iiif/manifests/admin.py | 2 ++ .../migrations/0059_alter_relatedlink_id.py | 20 +++++++++++++++++++ apps/iiif/manifests/models.py | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 apps/iiif/manifests/migrations/0059_alter_relatedlink_id.py diff --git a/apps/iiif/manifests/admin.py b/apps/iiif/manifests/admin.py index ff697617..6a39b171 100644 --- a/apps/iiif/manifests/admin.py +++ b/apps/iiif/manifests/admin.py @@ -1,6 +1,7 @@ """Django admin module for maninfests""" from django.contrib import admin from django.http import HttpResponseRedirect +from django.http.request import HttpRequest from django.urls.conf import path from import_export import resources, fields from import_export.admin import ImportExportModelAdmin @@ -35,6 +36,7 @@ class Meta: # pylint: disable=too-few-public-methods, missing-class-docstring class RelatedLinksInline(admin.TabularInline): model = RelatedLink + exclude = ("id",) fields = ( "link", "data_type", diff --git a/apps/iiif/manifests/migrations/0059_alter_relatedlink_id.py b/apps/iiif/manifests/migrations/0059_alter_relatedlink_id.py new file mode 100644 index 00000000..20629c97 --- /dev/null +++ b/apps/iiif/manifests/migrations/0059_alter_relatedlink_id.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.12 on 2023-12-05 19:41 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + dependencies = [ + ("manifests", "0058_alter_relatedlink_format_and_data_type"), + ] + + operations = [ + migrations.AlterField( + model_name="relatedlink", + name="id", + field=models.UUIDField( + default=uuid.uuid4, editable=False, primary_key=True, serialize=False + ), + ), + ] diff --git a/apps/iiif/manifests/models.py b/apps/iiif/manifests/models.py index 614efbf5..31c71600 100644 --- a/apps/iiif/manifests/models.py +++ b/apps/iiif/manifests/models.py @@ -368,7 +368,7 @@ class Note(models.Model): class RelatedLink(models.Model): """ Links to related resources """ - id = models.UUIDField(primary_key=True, default=uuid4) + id = models.UUIDField(primary_key=True, default=uuid4, editable=False) link = models.CharField(max_length=255) data_type = models.CharField( max_length=255,