summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/entity_helpers.py
diff options
context:
space:
mode:
authorbnewbold <bnewbold@archive.org>2020-08-03 18:00:41 +0000
committerbnewbold <bnewbold@archive.org>2020-08-03 18:00:41 +0000
commit4702bee24dde8bae64df76ad411a6d8329cc9bdf (patch)
tree221ec7bd8d77bddb2dec344c19253cca65156911 /python/fatcat_web/entity_helpers.py
parent5037642d7775c638d035c2faed8094537dfaf94d (diff)
parent31f59b4b0ba7ff95b685c8826a7d019fb142f65c (diff)
downloadfatcat-4702bee24dde8bae64df76ad411a6d8329cc9bdf.tar.gz
fatcat-4702bee24dde8bae64df76ad411a6d8329cc9bdf.zip
Merge branch 'bnewbold-editing' into 'master'
editing improvements See merge request webgroup/fatcat!73
Diffstat (limited to 'python/fatcat_web/entity_helpers.py')
-rw-r--r--python/fatcat_web/entity_helpers.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/python/fatcat_web/entity_helpers.py b/python/fatcat_web/entity_helpers.py
index c9a57290..7156b9be 100644
--- a/python/fatcat_web/entity_helpers.py
+++ b/python/fatcat_web/entity_helpers.py
@@ -1,5 +1,6 @@
from flask import abort
+from fatcat_openapi_client import *
from fatcat_openapi_client.rest import ApiException, ApiValueError
from fatcat_tools.transforms import *
from fatcat_web import api
@@ -148,6 +149,26 @@ def generic_get_entity_revision(entity_type, revision_id):
except ApiValueError:
abort(400)
+def generic_deleted_entity(entity_type, ident):
+ if entity_type == 'container':
+ entity = ContainerEntity()
+ elif entity_type == 'creator':
+ entity = CreatorEntity()
+ elif entity_type == 'file':
+ entity = FileEntity()
+ elif entity_type == 'fileset':
+ entity = FilesetEntity()
+ elif entity_type == 'webcapture':
+ entity = WebcaptureEntity()
+ elif entity_type == 'release':
+ entity = ReleaseEntity()
+ elif entity_type == 'work':
+ entity = WorkEntity()
+ else:
+ raise NotImplementedError
+ entity.ident = ident
+ return entity
+
def generic_get_editgroup_entity(editgroup, entity_type, ident):
if entity_type == 'container':
edits = editgroup.edits.containers
@@ -166,14 +187,18 @@ def generic_get_editgroup_entity(editgroup, entity_type, ident):
else:
raise NotImplementedError
revision_id = None
+ edit = None
for e in edits:
if e.ident == ident:
revision_id = e.revision
edit = e
break
- if not revision_id:
+ if not edit:
# couldn't find relevant edit in this editgroup
abort(404)
+ if not revision_id:
+ # deletion, presumably
+ return generic_deleted_entity(entity_type, ident), edit
try:
entity = generic_get_entity_revision(entity_type, revision_id)