Skip to content

Commit

Permalink
Only add a doc link if there is one
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit Vermeulen committed Feb 26, 2024
1 parent 64296be commit 29433ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion home/export_content_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def add_message_fields(self, msg_blocks: MsgBlocks) -> None:
self.whatsapp_body = whatsapp.value["message"].strip()
if "image" in whatsapp.value and whatsapp.value["image"] is not None:
self.image_link = whatsapp.value["image"].file.url
if "document" in whatsapp.value:
if "document" in whatsapp.value and whatsapp.value["document"] is not None:
self.doc_link = whatsapp.value["document"].file.url
if "media" in whatsapp.value and whatsapp.value["media"] is not None:
self.media_link = whatsapp.value["media"].file.url
Expand Down
15 changes: 15 additions & 0 deletions home/tests/test_content_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,21 @@ def test_export_wa_with_document(self, impexp: ImportExport) -> None:
# Export should succeed
assert content is not None

def test_export_wa_with_none_document(self, impexp: ImportExport) -> None:
home_page = HomePage.objects.first()
main_menu = PageBuilder.build_cpi(home_page, "main-menu", "Main Menu")
_ha_menu = PageBuilder.build_cp(
parent=main_menu,
slug="ha-menu",
title="HealthAlert menu",
bodies=[
WABody("HA menu", [WABlk("Welcome WA", document=None)]),
],
)
content = impexp.export_content(locale="en")
# Export should succeed
assert content is not None


@pytest.fixture(params=["csv", "xlsx"])
def impexp(request: Any, admin_client: Any) -> ImportExport:
Expand Down

0 comments on commit 29433ba

Please sign in to comment.