diff --git a/cads_catalogue/layout_manager.py b/cads_catalogue/layout_manager.py index 59a9a0d..271f595 100644 --- a/cads_catalogue/layout_manager.py +++ b/cads_catalogue/layout_manager.py @@ -207,7 +207,7 @@ def manage_licence_section( blocks = new_section.get("blocks", []) replacements = 0 for i, block in enumerate(copy.deepcopy(blocks)): - if block.get("type") == "licence_widget": + if block.get("type") == "licence_block": licence_uid = block["licence-id"] try: licence = [ @@ -296,7 +296,7 @@ def build_licence_block2( } licence_blocks.append(licence_block) new_block = { - "type": "licence_block", + "type": "licence_widget", "id": "licences_section", "title": "Licence", "details": {"licences": licence_blocks}, @@ -322,7 +322,7 @@ def manage_licence_section2( blocks = new_section.get("blocks", []) for i, block in enumerate(copy.deepcopy(blocks)): if ( - block.get("type") == "licence_block" + block.get("type") == "licence_widget" and block.get("id") == "licences_section" and "details" in block ): diff --git a/tests/data/layout1.json b/tests/data/layout1.json index 488dab7..18794f0 100644 --- a/tests/data/layout1.json +++ b/tests/data/layout1.json @@ -127,7 +127,7 @@ "caption": "Variables" }, { - "type": "licence_block", + "type": "licence_widget", "id": "licences_section", "title": "a title", "details": { @@ -155,7 +155,7 @@ { "title": "A title to not override", "id": "licence", - "type": "licence_block", + "type": "licence_widget", "details": { "licences": [ { @@ -224,7 +224,7 @@ "type": "section", "blocks": [ { - "type": "licence_widget", + "type": "licence_block", "licence-id": "licence-to-use-copernicus-products", "id": "licence-to-use-copernicus-products" } diff --git a/tests/data/layout2.json b/tests/data/layout2.json index f0ab619..fe82c50 100644 --- a/tests/data/layout2.json +++ b/tests/data/layout2.json @@ -127,7 +127,7 @@ "caption": "Variables" }, { - "type": "licence_block", + "type": "licence_widget", "id": "licences_section", "title": "a title", "details": { @@ -163,7 +163,7 @@ { "title": "A title to not override", "id": "licence", - "type": "licence_block", + "type": "licence_widget", "details": { "licences": [ { @@ -232,7 +232,7 @@ "type": "section", "blocks": [ { - "type": "licence_widget", + "type": "licence_block", "licence-id": "licence-to-use-copernicus-products", "id": "licence-to-use-copernicus-products" } diff --git a/tests/test_30_layout_manager.py b/tests/test_30_layout_manager.py index 2329255..6b23c3a 100644 --- a/tests/test_30_layout_manager.py +++ b/tests/test_30_layout_manager.py @@ -52,14 +52,14 @@ def test_transform_licences_blocks(tmpdir, session_obj: sa.orm.sessionmaker): all_licences = session.scalars(sa.select(database.Licence)).all() # create a test layout.json layout_path = os.path.join(str(tmpdir), "layout.json") - block1 = {"licence-id": all_licences[0].licence_uid, "type": "licence_widget"} + block1 = {"licence-id": all_licences[0].licence_uid, "type": "licence_block"} block2 = { "type": "link", "id": "test-link-id", "title": "a link", "href": "http://a-link.html", } - block3 = {"licence-id": all_licences[1].licence_uid, "type": "licence_widget"} + block3 = {"licence-id": all_licences[1].licence_uid, "type": "licence_block"} sections = [ {"id": "overview", "blocks": [block1, block2, block3]}, {"id": "overview2", "blocks": [block2, block3]}, @@ -105,14 +105,14 @@ def test_transform_licences_blocks(tmpdir, session_obj: sa.orm.sessionmaker): } # build a nested version - block1 = {"licence-id": all_licences[0].licence_uid, "type": "licence_widget"} + block1 = {"licence-id": all_licences[0].licence_uid, "type": "licence_block"} block2 = { "type": "link", "id": "test-link-id", "title": "a link", "href": "http://a-link.html", } - block3 = {"licence-id": all_licences[1].licence_uid, "type": "licence_widget"} + block3 = {"licence-id": all_licences[1].licence_uid, "type": "licence_block"} section1 = {"id": "overview", "blocks": [block1, block2, block3]} section2 = {"id": "overview2", "blocks": [block2, block3]} section3 = {"id": "section1", "type": "section", "blocks": [block1, block3]}