diff --git a/cfgov/v1/templates/v1/ask_report.html b/cfgov/v1/templates/v1/ask_report.html index f3523feccaa..f689b66c27b 100644 --- a/cfgov/v1/templates/v1/ask_report.html +++ b/cfgov/v1/templates/v1/ask_report.html @@ -32,6 +32,9 @@ Live + + First published + Last edited @@ -47,6 +50,9 @@ Related questions + + Schema + Language @@ -82,6 +88,9 @@ {{ page.live }} + + {{ page.first_published_at }} + {{ page.last_edited }} @@ -106,6 +115,9 @@
{% endfor %} + + {{ page.schema }} + {{ page.language }} diff --git a/cfgov/v1/views/reports.py b/cfgov/v1/views/reports.py index 7b4f69e1d1c..b8ac7c98a66 100644 --- a/cfgov/v1/views/reports.py +++ b/cfgov/v1/views/reports.py @@ -307,11 +307,13 @@ class AskReportView(ReportView): "search_description", "url", "live", + "first_published_at", "last_edited", "portal_topic.all", "primary_portal_topic", "portal_category.all", "related_questions.all", + "schema", "language", ] export_headings = { @@ -324,11 +326,13 @@ class AskReportView(ReportView): "search_description": "Meta description", "url": "URL", "live": "Live", + "first_published_at": "First published", "last_edited": "Last edited", "portal_topic.all": "Portal topics", "primary_portal_topic": "Primary portal topic", "portal_category.all": "Portal categories", "related_questions.all": "Related questions", + "schema": "Schema used", "language": "Language", } @@ -357,6 +361,27 @@ def process_answer_content(answer_content): answer = "" return strip_html(answer) + def determine_schema(answer_content): + has_faq_schema = list( + filter( + lambda item: item["type"] == "faq_schema", + answer_content.raw_data, + ) + ) + has_how_to_schema = list( + filter( + lambda item: item["type"] == "how_to_schema", + answer_content.raw_data, + ) + ) + + if has_faq_schema: + return "FAQ" + elif has_how_to_schema: + return "How To" + else: + return "None" + custom_field_preprocess = { "answer_base": {"csv": partial(process_related_item, key="id")}, "short_answer": {"csv": strip_html}, @@ -370,6 +395,7 @@ def process_answer_content(answer_content): "related_questions.all": { "csv": partial(join_values_with_pipe, key="id") }, + "schema": {"csv": determine_schema}, } template_name = "v1/ask_report.html"