Skip to content
Snippets Groups Projects
Commit 3c7c68d8 authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Add image status

parent 437a9239
No related branches found
No related tags found
1 merge request!21Offline manifest importation
......@@ -7,6 +7,7 @@ from elasticsearch.helpers import bulk as es_bulk
from arkindex.documents.models import Transcription
from arkindex.project.models import IndexableModel
from arkindex.project.tools import BoundingBox
from enumfields import EnumField, Enum
import requests
import urllib.parse
......@@ -50,6 +51,7 @@ class ImageServer(models.Model):
if img is None:
img = self.images.create(path=path, width=width, height=height)
return img
# Check the source
if not path.endswith('/'):
path += '/'
......@@ -75,7 +77,9 @@ class ImageServer(models.Model):
# Missing width or height data in image
img.width = data['width']
img.height = data['height']
img.save()
img.status = ImageStatus.Checked
img.save()
return img
......@@ -89,6 +93,15 @@ class ImageServer(models.Model):
return urllib.parse.urljoin(base_url, urllib.parse.quote(path.lstrip('/')))
class ImageStatus(Enum):
"""
Image validation status
"""
Checked = "checked"
Unchecked = "unchecked"
Error = "error"
class Image(IndexableModel):
"""
A document image
......@@ -98,6 +111,7 @@ class Image(IndexableModel):
width = models.PositiveIntegerField(default=0)
height = models.PositiveIntegerField(default=0)
elements = models.ManyToManyField('documents.Element', related_name='images', through='Zone')
status = EnumField(ImageStatus, default=ImageStatus.Unchecked, max_length=50)
class Meta:
unique_together = (
......
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