aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-02-16 20:08:26 -0800
committerBryan Newbold <bnewbold@robocracy.org>2022-03-09 16:09:55 -0800
commit4c7e0f2de21185fca25244204567a3351a3ebc0a (patch)
treeb12743cb181aa9dcf863dad908297c314ac4dfc5 /python
parent7f6a03c31d2bae482896243e7468bc1290b1678b (diff)
downloadfatcat-4c7e0f2de21185fca25244204567a3351a3ebc0a.tar.gz
fatcat-4c7e0f2de21185fca25244204567a3351a3ebc0a.zip
web editing: set entity status, eg when re-editing
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_web/entity_helpers.py11
-rw-r--r--python/fatcat_web/forms.py2
2 files changed, 12 insertions, 1 deletions
diff --git a/python/fatcat_web/entity_helpers.py b/python/fatcat_web/entity_helpers.py
index 0228ca12..27b99b1d 100644
--- a/python/fatcat_web/entity_helpers.py
+++ b/python/fatcat_web/entity_helpers.py
@@ -243,6 +243,7 @@ def generic_deleted_entity(entity_type: str, ident: str) -> Any:
else:
raise NotImplementedError
entity.ident = ident
+ entity.state = "deleted"
return entity
@@ -290,6 +291,16 @@ def generic_get_editgroup_entity(
abort(400)
entity.ident = ident
+ if edit.redirect_ident:
+ entity.state = "redirect"
+ entity.redirect = edit.redirect_ident
+ elif edit.prev_revision:
+ # TODO: this doesn't catch the case of "deleted but then undeleted" or
+ # similar situations where edit.prev_revision is not set. Really we
+ # should re-fetch from the API or something.
+ entity.state = "active"
+ else:
+ entity.state = "wip"
return entity, edit
diff --git a/python/fatcat_web/forms.py b/python/fatcat_web/forms.py
index 9f11c423..754018d6 100644
--- a/python/fatcat_web/forms.py
+++ b/python/fatcat_web/forms.py
@@ -522,7 +522,7 @@ class EntityTomlForm(EntityEditForm):
Initializes form with TOML version of existing entity
"""
etf = EntityTomlForm()
- if entity.state == "active":
+ if entity.state in ["active", "wip"]:
pop_fields = ["ident", "state", "revision", "redirect"]
else:
pop_fields = ["ident", "state"]