diff --git a/apis_core/api_routers.py b/apis_core/api_routers.py index 7e807cc04..5da84eff3 100644 --- a/apis_core/api_routers.py +++ b/apis_core/api_routers.py @@ -244,7 +244,7 @@ def generic_serializer_creation_factory(): if x in entity_field_name_list: exclude_lst_fin.append(x) if entity_str.lower() == "text": - exclude_lst_fin.extend(["kind", "source"]) + exclude_lst_fin.extend(["kind"]) for f in entity._meta.get_fields(): if f.__class__.__name__ == "ManyToManyField": prefetch_rel.append(f.name) diff --git a/apis_core/apis_entities/migrations/0002_remove_tempentityclass_source.py b/apis_core/apis_entities/migrations/0002_remove_tempentityclass_source.py new file mode 100644 index 000000000..7c94e6a43 --- /dev/null +++ b/apis_core/apis_entities/migrations/0002_remove_tempentityclass_source.py @@ -0,0 +1,17 @@ +# Generated by Django 4.1.8 on 2023-06-29 13:38 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("apis_entities", "0001_initial"), + ] + + operations = [ + migrations.RemoveField( + model_name="tempentityclass", + name="source", + ), + ] diff --git a/apis_core/apis_entities/models.py b/apis_core/apis_entities/models.py index 8be5f19a7..1f44d75b3 100644 --- a/apis_core/apis_entities/models.py +++ b/apis_core/apis_entities/models.py @@ -107,9 +107,6 @@ class TempEntityClass(AbstractEntity): text = models.ManyToManyField("apis_metainfo.Text", blank=True) collection = models.ManyToManyField("apis_metainfo.Collection") status = models.CharField(max_length=100) - source = models.ForeignKey( - "apis_metainfo.Source", blank=True, null=True, on_delete=models.SET_NULL - ) references = models.TextField(blank=True, null=True) notes = models.TextField(blank=True, null=True) published = models.BooleanField(default=False) diff --git a/apis_core/apis_entities/templates/apis_entities/detail_views/detail_generic.html b/apis_core/apis_entities/templates/apis_entities/detail_views/detail_generic.html index d7434981d..560060e91 100644 --- a/apis_core/apis_entities/templates/apis_entities/detail_views/detail_generic.html +++ b/apis_core/apis_entities/templates/apis_entities/detail_views/detail_generic.html @@ -246,10 +246,6 @@

{% block info-metadata %} - - - -
Source{{ object.source }}
Collection(s) diff --git a/apis_core/apis_metainfo/admin.py b/apis_core/apis_metainfo/admin.py index 729662e0e..1e0972ba0 100644 --- a/apis_core/apis_metainfo/admin.py +++ b/apis_core/apis_metainfo/admin.py @@ -1,8 +1,7 @@ from django.contrib import admin -from .models import Source, Collection, Text, Uri +from .models import Collection, Text, Uri -admin.site.register(Source) admin.site.register(Collection) admin.site.register(Text) admin.site.register(Uri) diff --git a/apis_core/apis_metainfo/migrations/0005_remove_text_source_delete_source.py b/apis_core/apis_metainfo/migrations/0005_remove_text_source_delete_source.py new file mode 100644 index 000000000..fdf058294 --- /dev/null +++ b/apis_core/apis_metainfo/migrations/0005_remove_text_source_delete_source.py @@ -0,0 +1,21 @@ +# Generated by Django 4.1.8 on 2023-06-29 13:38 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("apis_entities", "0002_remove_tempentityclass_source"), + ("apis_metainfo", "0004_auto_20230310_0804"), + ] + + operations = [ + migrations.RemoveField( + model_name="text", + name="source", + ), + migrations.DeleteModel( + name="Source", + ), + ] diff --git a/apis_core/apis_metainfo/models.py b/apis_core/apis_metainfo/models.py index 336f7ac5a..078bf2143 100644 --- a/apis_core/apis_metainfo/models.py +++ b/apis_core/apis_metainfo/models.py @@ -135,25 +135,6 @@ def duplicate(self): return duplicate -@reversion.register() -class Source(models.Model): - """Holds information about entities and their relations""" - - orig_filename = models.CharField(max_length=255, blank=True) - indexed = models.BooleanField(default=False) - pubinfo = models.CharField(max_length=400, blank=True) - author = models.CharField(max_length=255, blank=True) - orig_id = models.PositiveIntegerField(blank=True, null=True) - - def __str__(self): - if self.author != "" and self.orig_filename != "": - return "{}, stored by {}".format(self.orig_filename, self.author) - elif self.orig_filename != "": - return "{}".format(self.orig_filename) - else: - return "(ID: {})".format(self.id) - - @reversion.register() class Collection(models.Model): """Allows to group entities and relation.""" @@ -199,7 +180,6 @@ class Text(models.Model): kind = models.ForeignKey(TextType, blank=True, null=True, on_delete=models.SET_NULL) text = models.TextField(blank=True) - source = models.ForeignKey(Source, blank=True, null=True, on_delete=models.SET_NULL) def __str__(self): if self.text != "": diff --git a/apis_core/apis_metainfo/serializers.py b/apis_core/apis_metainfo/serializers.py index 112847285..6366d6911 100644 --- a/apis_core/apis_metainfo/serializers.py +++ b/apis_core/apis_metainfo/serializers.py @@ -1,7 +1,7 @@ from django.contrib.contenttypes.models import ContentType from rest_framework import serializers -from .models import Collection, Source, Text, Uri +from .models import Collection, Text, Uri from apis_core.apis_entities.models import TempEntityClass @@ -41,16 +41,6 @@ class Meta: model = Text -class SourceSerializer(serializers.HyperlinkedModelSerializer): - url = serializers.HyperlinkedIdentityField( - view_name="apis:apis_api:source-detail", lookup_field="pk" - ) - - class Meta: - fields = "__all__" - model = Source - - class UriSerializer(serializers.HyperlinkedModelSerializer): url = serializers.HyperlinkedIdentityField( view_name="apis:apis_api:uri-detail", lookup_field="pk" diff --git a/apis_core/apis_metainfo/test_models.py b/apis_core/apis_metainfo/test_models.py index eb8b1e6e8..5d36d875f 100644 --- a/apis_core/apis_metainfo/test_models.py +++ b/apis_core/apis_metainfo/test_models.py @@ -1,7 +1,7 @@ from django.test import TestCase from django.contrib.contenttypes.models import ContentType -from .models import RootObject, Source, Uri, UriCandidate +from .models import RootObject, Uri, UriCandidate class ModelTestCase(TestCase): @@ -17,19 +17,6 @@ def test_root_object(self): self.assertEquals(str(rfoo), "foo") self.assertEquals(str(rnone), "no name provided") - def test_source(self): - s = Source.objects.create() - s_fname = Source.objects.create(orig_filename="file_name_of_source") - s_fname_aut = Source.objects.create( - orig_filename="file_name_of_source", author="Alice" - ) - self.assertEquals(str(s), f"(ID: {s.id})") - self.assertEquals(str(s_fname), "file_name_of_source") - self.assertEquals( - str(s_fname_aut), - "file_name_of_source, stored by Alice", - ) - def test_uri(self): ufoo = Uri.objects.create() self.assertEquals(str(ufoo), "None") diff --git a/apis_core/utils/test_caching.py b/apis_core/utils/test_caching.py index 166403232..44d65d6a1 100644 --- a/apis_core/utils/test_caching.py +++ b/apis_core/utils/test_caching.py @@ -6,7 +6,6 @@ "apis_metainfo": [ "Collection", "RootObject", - "Source", "Text", "Uri", "UriCandidate",