Skip to content

Commit

Permalink
check footer and list item max characters when importing
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlamallama committed Feb 14, 2024
1 parent 5386c6d commit 85bb89c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
9 changes: 3 additions & 6 deletions home/import_content_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,17 @@ def create_shadow_content_page_from_row(
parent=row.parent,
related_pages=row.related_pages,
)
errors = {}

if len(row.footer) > 60:
errors["footer"] = ValidationError(
raise ImportException(
f"footer too long: {row.footer}", row.page_id
)

if len(row.list_items) > 24:
errors["list_items"] = ValidationError(
raise ImportException(
f"list_items too long: {row.list_items}", row.page_id
)

if errors:
raise ImportException(errors)

self.shadow_pages[(row.slug, locale)] = page

self.add_message_to_shadow_content_page_from_row(row, locale)
Expand Down
1 change: 0 additions & 1 deletion home/tests/test_content_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,6 @@ def test_field_maximum_characters(self, csv_impexp: ImportExport) -> None:

assert isinstance(e.value, ImportException)
assert e.value.row_num == 4
assert isinstance(e.value.message["footer"], ValidationError)


@pytest.fixture(params=["csv", "xlsx"])
Expand Down

0 comments on commit 85bb89c

Please sign in to comment.