From f4983e6f7ba113a0ba8beb8ae16e4afdb0347db6 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Thu, 5 Oct 2023 13:03:05 +0200 Subject: [PATCH] fix: the contenttype of the rootobject should not be user editable --- .../0008_alter_rootobject_self_contenttype.py | 26 +++++++++++++++++++ apis_core/apis_metainfo/models.py | 6 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 apis_core/apis_metainfo/migrations/0008_alter_rootobject_self_contenttype.py diff --git a/apis_core/apis_metainfo/migrations/0008_alter_rootobject_self_contenttype.py b/apis_core/apis_metainfo/migrations/0008_alter_rootobject_self_contenttype.py new file mode 100644 index 000000000..2b6b15ca7 --- /dev/null +++ b/apis_core/apis_metainfo/migrations/0008_alter_rootobject_self_contenttype.py @@ -0,0 +1,26 @@ +# Generated by Django 4.1.11 on 2023-10-11 10:14 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ("contenttypes", "0002_remove_content_type_name"), + ("apis_metainfo", "0007_delete_source"), + ] + + operations = [ + migrations.AlterField( + model_name="rootobject", + name="self_contenttype", + field=models.ForeignKey( + blank=True, + editable=False, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="contenttypes.contenttype", + ), + ), + ] diff --git a/apis_core/apis_metainfo/models.py b/apis_core/apis_metainfo/models.py index a80f63826..2d0721299 100644 --- a/apis_core/apis_metainfo/models.py +++ b/apis_core/apis_metainfo/models.py @@ -54,7 +54,11 @@ class RootObject(models.Model): # triples where the subject's or object's contenttype must be respected (e.g. get all triples # where the subject is a Person) self_contenttype = models.ForeignKey( - ContentType, on_delete=models.deletion.CASCADE, null=True, blank=True + ContentType, + on_delete=models.deletion.CASCADE, + null=True, + blank=True, + editable=False, ) objects = models.Manager() objects_inheritance = InheritanceManager()