Skip to content

Commit

Permalink
licence_block->lincence_widget and vice versa
Browse files Browse the repository at this point in the history
  • Loading branch information
alex75 committed Aug 23, 2024
1 parent 528162b commit 29c9853
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions cads_catalogue/layout_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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},
Expand All @@ -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
):
Expand Down
6 changes: 3 additions & 3 deletions tests/data/layout1.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"caption": "Variables"
},
{
"type": "licence_block",
"type": "licence_widget",
"id": "licences_section",
"title": "a title",
"details": {
Expand Down Expand Up @@ -155,7 +155,7 @@
{
"title": "A title to not override",
"id": "licence",
"type": "licence_block",
"type": "licence_widget",
"details": {
"licences": [
{
Expand Down Expand Up @@ -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"
}
Expand Down
6 changes: 3 additions & 3 deletions tests/data/layout2.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"caption": "Variables"
},
{
"type": "licence_block",
"type": "licence_widget",
"id": "licences_section",
"title": "a title",
"details": {
Expand Down Expand Up @@ -163,7 +163,7 @@
{
"title": "A title to not override",
"id": "licence",
"type": "licence_block",
"type": "licence_widget",
"details": {
"licences": [
{
Expand Down Expand Up @@ -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"
}
Expand Down
8 changes: 4 additions & 4 deletions tests/test_30_layout_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]},
Expand Down Expand Up @@ -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]}
Expand Down

0 comments on commit 29c9853

Please sign in to comment.