From 4c7e0f2de21185fca25244204567a3351a3ebc0a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 16 Feb 2022 20:08:26 -0800 Subject: web editing: set entity status, eg when re-editing --- python/fatcat_web/entity_helpers.py | 11 +++++++++++ python/fatcat_web/forms.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'python') 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"] -- cgit v1.2.3