Skip to content
Snippets Groups Projects
Commit 92d58baa authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

:boom: Page and :boom: Act

parent 928a0b87
No related branches found
No related tags found
No related merge requests found
Showing
with 590 additions and 713 deletions
......@@ -10,7 +10,7 @@ from django.core.validators import URLValidator
from django.core.exceptions import ValidationError
from django.db import transaction
from arkindex_common.enums import MetaType
from arkindex.documents.models import Corpus, Element, ElementType, Page, MetaData
from arkindex.documents.models import Corpus, Element, ElementType, MetaData
from arkindex.images.models import ImageServer, Zone
from arkindex.dataimport.models import Revision, EventType
from arkindex.project.polygon import Polygon
......@@ -334,7 +334,8 @@ class ManifestParser(IIIFParser):
elements__corpus=self.corpus,
)
new_page = Page(
new_page = Element(
type=ElementType.Page,
zone=zone,
corpus_id=self.corpus.id,
name=page_name,
......@@ -396,7 +397,10 @@ class ManifestParser(IIIFParser):
)
if not self.is_new: # Deleted pages cannot happen on a new volume
deleted_pages = Page.objects.get_descending(self.volume.id).exclude(id__in=[p.id for p in self.pages])
deleted_pages = Element.objects \
.get_descending(self.volume.id) \
.filter(type=ElementType.Page) \
.exclude(id__in=[p.id for p in self.pages])
if deleted_pages.exists():
# Set volume as changed since one or more pages got deleted
self.volume_changed = True
......
from unittest.mock import MagicMock, patch, call
from arkindex_common.enums import DataImportMode
from arkindex.project.tests import FixtureTestCase
from arkindex.documents.models import Element, Page
from arkindex.documents.models import Element
from arkindex.dataimport.models import DataImport
from arkindex.dataimport.filetypes import IIIFFileType, ActsListFileType
from arkindex.dataimport.git import GitFlow, SimpleDiff, DiffType
......@@ -314,8 +314,8 @@ class TestGitFlow(FixtureTestCase):
"""
Test a normal GitFlow file types dispatch
"""
elt = Element.objects.get(name='Volume 1, page 1r')
page = Page.objects.get(name='Volume 1, page 1v')
elt1 = Element.objects.get(name='Volume 1, page 1r')
elt2 = Element.objects.get(name='Volume 1, page 1v')
diff1 = SimpleDiff(DiffType.Modification, 'path1a', 'path1b')
diff2 = SimpleDiff(DiffType.Modification, 'path2a', 'path2b')
......@@ -323,15 +323,15 @@ class TestGitFlow(FixtureTestCase):
iiif_mock = MagicMock(spec=IIIFFileType)
act_mock.diff = diff1
iiif_mock.diff = diff2
act_mock.changed_elements = [elt, ]
iiif_mock.changed_elements = [page, ]
act_mock.changed_elements = [elt1, ]
iiif_mock.changed_elements = [elt2, ]
filetype_mock.side_effect = [act_mock, iiif_mock]
flow = GitFlow(self.dataimport, self.working_dir)
flow.config = MagicMock()
changed_elements = flow.dispatch_imports([diff1, diff2])
self.assertListEqual(changed_elements, [page, elt])
self.assertCountEqual(changed_elements, [elt1, elt2])
self.assertEqual(filetype_mock.call_count, 2)
self.assertListEqual(filetype_mock.call_args_list, [
......
......@@ -2,7 +2,7 @@ from unittest.mock import patch, call
from django.test import override_settings
from arkindex_common.enums import MetaType, DataImportMode
from arkindex.project.tests import FixtureTestCase
from arkindex.documents.models import Element, ElementType, Page
from arkindex.documents.models import Element, ElementType
from arkindex.images.models import ImageServer
from arkindex.dataimport.models import EventType
from arkindex.dataimport.git import GitFlow
......@@ -49,7 +49,7 @@ class TestManifestParser(FixtureTestCase):
Check importing base.json
"""
vol = Element.objects.get(type=ElementType.Volume, name='ParserTest')
pages = Page.objects.get_descending(vol.id)
pages = Element.objects.get_descending(vol.id).filter(type=ElementType.Page)
# Volume metadata
self.assertEqual(vol.metadatas.count(), 4)
......@@ -99,7 +99,7 @@ class TestManifestParser(FixtureTestCase):
Check importing changed.json after base.json
"""
vol = Element.objects.get(type=ElementType.Volume, name='ParserTest')
pages = Page.objects.get_descending(vol.id)
pages = Element.objects.get_descending(vol.id).filter(type=ElementType.Page)
# Volume metadata
self.assertEqual(vol.metadatas.count(), 4)
......@@ -313,7 +313,7 @@ class TestManifestParser(FixtureTestCase):
def test_collection_parser(self, mp_mock):
vol1 = Element.objects.get(type=ElementType.Volume, name='Volume 1')
vol2 = Element.objects.get(type=ElementType.Volume, name='Volume 2')
page = Page.objects.get_descending(vol1.id).first()
page = Element.objects.get(type=ElementType.Page, name='Volume 1, page 1r')
mp_mock.return_value.run.side_effect = [[vol1, page], [vol2, ]]
parser = IIIFParser.load(
......
......@@ -6,7 +6,7 @@ from arkindex_common.enums import MetaType
from arkindex.project.polygon import Polygon
from arkindex.images.models import Image
from arkindex.documents.indexer import Indexer
from arkindex.documents.models import Element, ElementType, Act, Corpus
from arkindex.documents.models import Element, ElementType, Corpus
import csv
import logging
......@@ -148,4 +148,4 @@ class ActsImporter(object):
assert failed < count, 'No acts were imported'
logger.info('Updating search index')
Indexer().run_index(Act.objects.get_descending(self.volume.id))
Indexer().run_index(Element.objects.get_descending(self.volume.id).filter(type=ElementType.Act))
from django.db.models import Q, Count
from django_filters import rest_framework as filters
from arkindex.documents.models import MLClass, Element, ElementType, Page, ClassificationState
from arkindex.documents.models import MLClass, Element, ElementType, ClassificationState
class MLClassVolumeChoiceFilter(filters.ModelChoiceFilter):
......@@ -13,7 +13,7 @@ class CorpusMLClassFilter(filters.FilterSet):
volume = MLClassVolumeChoiceFilter(method='filter_volume', label='Volume')
def filter_volume(self, queryset, name, value):
return queryset.filter(classifications__element__in=Page.objects.get_descending(value.pk)).distinct()
return queryset.filter(classifications__element__in=Element.objects.get_descending(value.pk)).distinct()
class Meta:
model = MLClass
......
......@@ -3,7 +3,7 @@ from django.views.decorators.cache import cache_page
from rest_framework.generics import RetrieveAPIView
from rest_framework.exceptions import PermissionDenied
from arkindex_common.enums import TranscriptionType
from arkindex.documents.models import Element, ElementType, Page, Act, Corpus
from arkindex.documents.models import Element, ElementType, Corpus
from arkindex.documents.serializers.iiif import \
VolumeManifestSerializer, ActManifestSerializer, \
PageAnnotationListSerializer, PageActAnnotationListSerializer, \
......@@ -37,10 +37,12 @@ class ActManifest(RetrieveAPIView):
"""
serializer_class = ActManifestSerializer
queryset = Act.objects.all()
def get_queryset(self):
return Act.objects.filter(corpus__in=Corpus.objects.readable(self.request.user))
return Element.objects.filter(
corpus__in=Corpus.objects.readable(self.request.user),
type=ElementType.Act,
)
@method_decorator(cache_page(3600))
def get(self, *args, **kwargs):
......@@ -55,7 +57,10 @@ class PageAnnotationList(RetrieveAPIView):
serializer_class = PageAnnotationListSerializer
def get_queryset(self):
return Page.objects.filter(corpus__in=Corpus.objects.readable(self.request.user))
return Element.objects.filter(
corpus__in=Corpus.objects.readable(self.request.user),
type=ElementType.Page,
)
@method_decorator(cache_page(3600))
def get(self, *args, **kwargs):
......@@ -70,7 +75,10 @@ class PageActAnnotationList(RetrieveAPIView):
serializer_class = PageActAnnotationListSerializer
def get_queryset(self):
return Page.objects.filter(corpus__in=Corpus.objects.readable(self.request.user))
return Element.objects.filter(
corpus__in=Corpus.objects.readable(self.request.user),
type=ElementType.Page,
)
@method_decorator(cache_page(3600))
def get(self, *args, **kwargs):
......@@ -119,9 +127,10 @@ class TranscriptionSearchAnnotationList(SearchAPIMixin, RetrieveAPIView):
.filter(
'terms',
element=list(
Page.objects
.get_descending(self.get_element().id)
.values_list('id', flat=True)
Element.objects
.get_descending(self.get_element().id)
.filter(type=ElementType.Page)
.values_list('id', flat=True)
),
) \
.filter('range', score={'gte': min_score}) \
......
This diff is collapsed.
from django.db import models
from itertools import groupby, chain
import uuid
import warnings
class ElementManager(models.Manager):
......@@ -135,30 +134,6 @@ class ElementManager(models.Manager):
return neighbors
class PageManager(ElementManager):
def get_queryset(self):
warnings.warn(
'Page-specific features are being removed. Please use Elements',
DeprecationWarning,
stacklevel=2,
)
from arkindex.documents.models import ElementType
return super().get_queryset().filter(type=ElementType.Page)
class ActManager(ElementManager):
def get_queryset(self):
warnings.warn(
'Act-specific features are being removed. Please use Elements',
DeprecationWarning,
stacklevel=2,
)
from arkindex.documents.models import ElementType
return super().get_queryset().filter(type=ElementType.Act)
class CorpusManager(models.Manager):
'''
Add ACL functions to corpus listing
......
# Generated by Django 2.2 on 2019-09-27 08:22
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('documents', '0019_remove_register'),
]
operations = [
migrations.DeleteModel(
name='Act',
),
migrations.DeleteModel(
name='Page',
),
]
......@@ -9,12 +9,11 @@ from arkindex_common.ml_tool import MLToolType
from arkindex.project.models import IndexableModel
from arkindex.project.fields import ArrayField
from arkindex.project.elastic import ESTranscription, ESElement, ESEntity
from arkindex.documents.managers import ElementManager, CorpusManager, PageManager, ActManager
from arkindex.documents.managers import ElementManager, CorpusManager
from arkindex.documents.dates import InterpretedDateMixin
import uuid
import logging
import itertools
import warnings
logger = logging.getLogger(__name__)
......@@ -117,15 +116,6 @@ class Element(IndexableModel):
es_document = ESElement
objects = ElementManager()
def get_thumbnail(self):
"""Get an Image instance corresponding to a thumbnail for this element."""
if self.type == ElementType.Volume:
first_page = Page.objects.get_descending(self.id).first()
return first_page and first_page.zone.image
elif self.type == ElementType.Page:
return self.page.images.first()
return None
@transaction.atomic
def add_parent(self, parent, order=None):
'''
......@@ -262,66 +252,6 @@ class Element(IndexableModel):
return '{} : {}'.format(self.type, self.name)
class Page(Element):
"""
with folio numbering
"""
objects = PageManager()
class Meta:
proxy = True
def save(self, *args, **kwargs):
# TODO: move this in Element through introspection
warnings.warn(
'Page-specific features are being removed. Please use Elements',
DeprecationWarning,
stacklevel=2,
)
self.type = ElementType.Page
super().save(*args, **kwargs)
# see https://code.djangoproject.com/ticket/30333
# TODO: remove as soon as __eq__ is removed
__hash__ = models.Model.__hash__
def __lt__(self, other):
raise DeprecationWarning('Page-specific features are being removed. Please use Elements')
def __eq__(self, other):
raise DeprecationWarning('Page-specific features are being removed. Please use Elements')
def __le__(self, other):
raise DeprecationWarning('Page-specific features are being removed. Please use Elements')
@property
def page_transcriptions(self):
"""
A helper property to write a serializer than only uses Page transcriptions
"""
return self.transcriptions.filter(type=TranscriptionType.Page)
class Act(Element):
"""
A logical subdivision that can span on multiple images via zones
"""
objects = ActManager()
class Meta:
proxy = True
def save(self, *args, **kwargs):
# TODO: move this in Element through introspection
warnings.warn(
'Act-specific features are being removed. Please use Elements',
DeprecationWarning,
stacklevel=2,
)
self.type = ElementType.Act
super().save(*args, **kwargs)
class DataSource(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4)
type = EnumField(MLToolType)
......
from abc import ABC, abstractmethod
from django.conf import settings
from rest_framework import serializers
from arkindex.documents.models import Element, ElementType, Page, Transcription
from arkindex.documents.models import Element, ElementType, Transcription
from arkindex.project.tools import build_absolute_url
......@@ -88,7 +88,7 @@ class SurfaceAnnotationSerializer(AnnotationSerializer):
)
class AnnotationListSerializer(ABC, serializers.BaseSerializer):
class AnnotationListSerializer(serializers.BaseSerializer):
"""
Serialize a list of serialized annotations into a IIIF annotation list
"""
......@@ -109,8 +109,8 @@ class AnnotationListSerializer(ABC, serializers.BaseSerializer):
).data
}
@abstractmethod
def get_elements(self, obj):
def get_elements(self, element):
return element.transcriptions.all()
"Get a list of elements to serialize as annotations."
......@@ -121,10 +121,6 @@ class PageAnnotationListSerializer(AnnotationListSerializer):
annotation_serializer = TranscriptionAnnotationSerializer
def get_elements(self, page):
assert isinstance(page, Page)
return page.transcriptions.all()
class PageActAnnotationListSerializer(AnnotationListSerializer):
"""
......@@ -133,11 +129,10 @@ class PageActAnnotationListSerializer(AnnotationListSerializer):
annotation_serializer = SurfaceAnnotationSerializer
def get_elements(self, page):
assert isinstance(page, Page)
if page.zone is None:
def get_elements(self, element):
if element.zone is None:
return []
return Element.objects.filter(type=ElementType.Surface, zone__image=page.zone.image)
return Element.objects.filter(type=ElementType.Surface, zone__image=element.zone.image)
class SurfaceAnnotationListSerializer(AnnotationListSerializer):
......
......@@ -3,7 +3,7 @@ from django.db.models import Prefetch, Subquery, OuterRef, Value, F, CharField
from django.db.models.functions import Concat, Ceil
from rest_framework import serializers
from arkindex_common.enums import MetaType
from arkindex.documents.models import Element, ElementType, Page, Act, MetaData, Classification
from arkindex.documents.models import Element, ElementType, MetaData, Classification
from arkindex.images.models import Image, Zone
from arkindex.project.tools import sslify_url, build_absolute_url
import urllib.parse
......@@ -148,16 +148,21 @@ class ManifestSerializer(serializers.BaseSerializer):
assert isinstance(element, Element)
assert 'request' in self.context, "A request is required to generate absolute URLs"
canvas_elements = self.get_canvases(element)
canvases = self.canvas_serializer(
self.get_canvases(element),
canvas_elements,
context=self.context,
many=True
).data
if len(canvas_elements) > 0:
thumbnail = ImageThumbnailManifestSerializer(canvas_elements[0].zone.image).data
else:
thumbnail = None
return {
"@context": settings.IIIF_PRESENTATION_CONTEXT,
"@id": build_absolute_url(element, self.context['request'], self.id_url_name),
"@type": "sc:Manifest",
"thumbnail": ImageThumbnailManifestSerializer(element.get_thumbnail()).data,
"thumbnail": thumbnail,
"related": [],
"structures": self.get_structures(element, canvases),
"description": "",
......@@ -234,8 +239,9 @@ class VolumeManifestSerializer(ManifestSerializer):
to_attr='folio_metadatas',
)
return Page.objects \
return Element.objects \
.get_descending(volume.id) \
.filter(type=ElementType.Page) \
.annotate(best_classification=Subquery(best_classification_subquery)) \
.prefetch_related('zone__image__server', folio_prefetch)
......@@ -260,17 +266,17 @@ class ActManifestSerializer(ManifestSerializer):
canvas_serializer = ActPageCanvasManifestSerializer
id_url_name = 'api:act-manifest'
def get_canvases(self, act):
assert isinstance(act, Act)
def get_canvases(self, element):
assert element.type == ElementType.Act
image_ids = list(Element.objects
.get_descending(act.id, type=ElementType.Surface)
.get_descending(element.id, type=ElementType.Surface)
.values_list('zone__image_id', flat=True))
pages = Page.objects \
.filter(zone__image_id__in=image_ids) \
.select_related('zone__image__server')
pages = Element.objects \
.filter(zone__image_id__in=image_ids, type=ElementType.Page) \
.select_related('zone__image__server')
# This query gives unordered pages so we reorder them manually
ordered_pages = sorted(pages, key=lambda p: image_ids.index(p.zone.image_id))
# Add act info for canvas serializer
for p in ordered_pages:
p.act = act
p.act = element
return ordered_pages
......@@ -3,7 +3,7 @@ from arkindex_common.tei import TeiElement, TeiParser as BaseTeiParser
from arkindex_common.enums import MetaType
from arkindex.project.tools import find_closest
from arkindex.documents.indexer import Indexer
from arkindex.documents.models import Element, ElementType, Act, Entity, Page, MetaData, DataSource, MLToolType
from arkindex.documents.models import Element, ElementType, Entity, MetaData, DataSource, MLToolType
import logging
......@@ -53,8 +53,9 @@ class TeiParser(BaseTeiParser):
logger.warning('No witness on text, skipping.')
continue
act = Act.objects.filter(
act = Element.objects.filter(
id__in=volume_acts,
type=ElementType.Act,
metadatas__name='number',
metadatas__value=text.witness.id,
).first()
......@@ -145,13 +146,14 @@ class TeiParser(BaseTeiParser):
md_ids = (md.id for md in db_metadatas)
date_metadatas = MetaData.objects.filter(id__in=md_ids, type=MetaType.Date)
acts = Act.objects \
.filter(metadatas__in=date_metadatas) \
acts = Element.objects \
.filter(metadatas__in=date_metadatas, type=ElementType.Act) \
.prefetch_related('metadatas')
if acts.exists():
Indexer().run_index(acts)
pages = Page.objects \
.filter(metadatas__in=date_metadatas) \
pages = Element.objects \
.filter(metadatas__in=date_metadatas, type=ElementType.Page) \
.prefetch_related('transcriptions')
if pages.exists():
Indexer().run_index(pages)
......@@ -3,7 +3,7 @@ from django.db.models.signals import pre_delete
from arkindex_common.enums import TranscriptionType, MetaType, DataImportMode
from arkindex_common.ml_tool import MLToolType
from arkindex.project.tests import FixtureTestCase
from arkindex.documents.models import Corpus, Element, Page, ElementType, DataSource, MLClass
from arkindex.documents.models import Corpus, Element, ElementType, DataSource, MLClass
from arkindex.dataimport.models import EventType
......@@ -51,8 +51,9 @@ class TestDeleteCorpus(FixtureTestCase):
revision=cls.rev,
type=EventType.Addition,
)
cls.page = Page.objects.create(
cls.page = Element.objects.create(
corpus=cls.corpus2,
type=ElementType.Page,
name='A page',
)
cls.page.classifications.create(
......
......@@ -3,7 +3,7 @@ from pathlib import Path
from arkindex_common.enums import MetaType
from arkindex.project.tests import FixtureTestCase
from arkindex.project.polygon import Polygon
from arkindex.documents.models import Element, ElementType, Act
from arkindex.documents.models import Element, ElementType
from arkindex.documents.acts import ActsImporter
ACT_SAMPLES = Path(__file__).resolve().parent / 'act_samples'
......@@ -30,8 +30,17 @@ class TestActsImporter(FixtureTestCase):
importer.run()
self.assertEqual(importer.created_acts_count, 3)
self.assertEqual(importer.created_surfaces_count, 3)
self.assertEqual(Act.objects.get_descending(self.volume.id).count(), 3)
act_1, act_2bis, act_3 = Act.objects.get_descending(self.volume.id).order_by('name')
self.assertEqual(
Element.objects
.get_descending(self.volume.id)
.filter(type=ElementType.Act)
.count(),
3,
)
act_1, act_2bis, act_3 = Element.objects \
.get_descending(self.volume.id) \
.filter(type=ElementType.Act) \
.order_by('name')
self.assertEqual(act_1.name, 'Act 1')
metadata = act_1.metadatas.get()
......
from django.urls import reverse
from arkindex.project.tests import FixtureAPITestCase
from rest_framework import status
from arkindex.documents.models import Page
from arkindex.project.tests import FixtureAPITestCase
class TestPageAnnotationListSerializer(FixtureAPITestCase):
def test_normal_list(self):
page = Page.objects.get(corpus=self.corpus, zone__image__path='img1')
page = self.corpus.elements.get(name='Volume 1, page 1r')
response = self.client.get(reverse('api:page-transcription-manifest', kwargs={'pk': page.id}))
self.assertEqual(response.status_code, status.HTTP_200_OK)
annotation_list = response.json()
......@@ -44,7 +43,7 @@ class TestPageAnnotationListSerializer(FixtureAPITestCase):
def test_empty_list(self):
# An annotation list with nothing in it
response = self.client.get(reverse('api:page-transcription-manifest', kwargs={
'pk': Page.objects.get(corpus=self.corpus, zone__image__path='img6').id
'pk': self.corpus.elements.get(name='Volume 2, page 2r').id
}))
self.assertEqual(response.status_code, status.HTTP_200_OK)
annotation_list = response.json()
......@@ -55,7 +54,7 @@ class TestPageAnnotationListSerializer(FixtureAPITestCase):
class TestPageActAnnotationListSerializer(FixtureAPITestCase):
def test_normal_list(self):
page = Page.objects.get(corpus=self.corpus, zone__image__path='img1')
page = self.corpus.elements.get(name='Volume 1, page 1r')
response = self.client.get(reverse('api:page-act-manifest', kwargs={'pk': page.id}))
self.assertEqual(response.status_code, status.HTTP_200_OK)
annotation_list = response.json()
......@@ -92,7 +91,7 @@ class TestPageActAnnotationListSerializer(FixtureAPITestCase):
def test_empty_list(self):
# An annotation list with nothing in it
response = self.client.get(reverse('api:page-act-manifest', kwargs={
'pk': Page.objects.get(corpus=self.corpus, zone__image__path='img6').id
'pk': self.corpus.elements.get(name='Volume 2, page 2r').id
}))
self.assertEqual(response.status_code, status.HTTP_200_OK)
annotation_list = response.json()
......
from django.urls import reverse
from rest_framework import status
from arkindex.documents.models import Classification, DataSource, Element, ElementType, MLClass, Page
from arkindex.documents.models import Classification, DataSource, Element, ElementType, MLClass
from arkindex.project.tests import FixtureAPITestCase
......@@ -87,7 +87,7 @@ class TestClasses(FixtureAPITestCase):
})
# Attach page to the volume: must not return any MLClass without classification
page = Page.objects.create(corpus=self.corpus, name='Custom page')
page = self.corpus.elements.create(type=ElementType.Page, name='Custom page')
page.add_parent(volume)
response = self.client.get(reverse('api:corpus-classes', kwargs={'pk': self.corpus.pk}), {'volume': volume.id})
self.assertEqual(response.status_code, status.HTTP_200_OK)
......
from django.urls import reverse
from rest_framework import status
from arkindex_common.enums import MetaType, TranscriptionType, EntityType
from arkindex.documents.models import Element, ElementType, DataSource, \
Page, Act, Corpus, Entity, MLClass, Classification
from arkindex.documents.models import \
Element, ElementType, DataSource, Corpus, Entity, MLClass, Classification
from arkindex.images.models import ImageServer
from arkindex.project.tests import FixtureAPITestCase
from arkindex.project.aws import S3FileStatus
......@@ -143,7 +143,7 @@ class TestElementsAPI(FixtureAPITestCase):
response = self.client.post(**request)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
data = response.json()
page = Page.objects.get(id=data['id'])
page = self.corpus.elements.get(id=data['id'])
self.assertDictEqual(
data,
{
......@@ -174,8 +174,9 @@ class TestElementsAPI(FixtureAPITestCase):
)
response = self.client.post(**request)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
act = Act.objects.get(id=response.json()['id'])
act = Element.objects.get(id=response.json()['id'])
self.assertEqual(act.name, 'Castle story')
self.assertEqual(act.type, ElementType.Act)
self.assertEqual(act.metadatas.count(), 2)
folio_metadata, number_metadata = act.metadatas.order_by('name')
self.assertEqual(number_metadata.name, 'number')
......
from arkindex_common.enums import MetaType, EntityType
from arkindex_common.tei import Text, NAMESPACES
from arkindex.documents.models import Act
from arkindex.documents.tei import TeiParser
from arkindex.project.tests import FixtureTestCase
import os.path
......@@ -101,7 +100,7 @@ class TestTeiElement(FixtureTestCase):
xml_path = os.path.join(FIXTURES, 'arguments.xml')
parser = TeiParser(xml_path, corpus=self.corpus, revision=rev1)
act = Act.objects.get(name='Act 1')
act = self.corpus.elements.get(name='Act 1')
te_before = Text(os.path.join(FIXTURES, 'update_before.xml'), NAMESPACES)
te_after = Text(os.path.join(FIXTURES, 'update_after.xml'), NAMESPACES)
......
......@@ -4,7 +4,7 @@ from rest_framework import status
from arkindex.project.tests import FixtureAPITestCase
from arkindex.project.polygon import Polygon
from arkindex_common.enums import TranscriptionType
from arkindex.documents.models import Page, Transcription, DataSource
from arkindex.documents.models import Transcription, DataSource
import uuid
......@@ -16,7 +16,7 @@ class TestTranscriptionCreate(FixtureAPITestCase):
@classmethod
def setUpTestData(cls):
super().setUpTestData()
cls.page = Page.objects.get(corpus=cls.corpus, zone__image__path='img1')
cls.page = cls.corpus.elements.get(name='Volume 1, page 1r')
cls.vol = cls.corpus.elements.get(name='Volume 1')
cls.src = DataSource.objects.get(slug='test')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment