From f9dc23aab85516a08fa17ab26796b93cbc610e8f Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 15 Feb 2022 13:08:51 -0800 Subject: web: remove generic entity fields from 'metadata' tab --- python/fatcat_web/routes.py | 11 ++++++++--- python/fatcat_web/templates/entity_view_metadata.html | 10 +++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'python') diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 2f29b9e6..c1b5f929 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -266,6 +266,8 @@ def work_lookup() -> AnyResponse: ### More Generic Entity Views ############################################### +GENERIC_ENTITY_FIELDS = ["extra", "edit_extra", "revision", "redirect", "state", "ident"] + def generic_entity_view(entity_type: str, ident: str, view_template: str) -> AnyResponse: entity = generic_get_entity(entity_type, ident) @@ -276,7 +278,8 @@ def generic_entity_view(entity_type: str, ident: str, view_template: str) -> Any return render_template("deleted_entity.html", entity_type=entity_type, entity=entity) metadata = entity.to_dict() - metadata.pop("extra") + for k in GENERIC_ENTITY_FIELDS: + metadata.pop(k) entity._metadata = metadata if view_template == "container_view.html": @@ -299,7 +302,8 @@ def generic_entity_revision_view( entity = generic_get_entity_revision(entity_type, revision_id) metadata = entity.to_dict() - metadata.pop("extra") + for k in GENERIC_ENTITY_FIELDS: + metadata.pop(k) entity._metadata = metadata return render_template( @@ -323,7 +327,8 @@ def generic_editgroup_entity_view( ) metadata = entity.to_dict() - metadata.pop("extra") + for k in GENERIC_ENTITY_FIELDS: + metadata.pop(k) entity._metadata = metadata return render_template( diff --git a/python/fatcat_web/templates/entity_view_metadata.html b/python/fatcat_web/templates/entity_view_metadata.html index d1bd3c30..80aaf19c 100644 --- a/python/fatcat_web/templates/entity_view_metadata.html +++ b/python/fatcat_web/templates/entity_view_metadata.html @@ -5,7 +5,15 @@ {% block entity_main %}

Entity Metadata (schema)

-{{ entity_macros.extra_metadata(entity._metadata) }} +{% if entity._metadata %} + {{ entity_macros.extra_metadata(entity._metadata) }} +{% else %} + + + + +
No specific metadata for this entity
+{% endif %}
As JSON via API
-- cgit v1.2.3