Skip to content

Commit

Permalink
⬆️(backend) upgrade to django cms link 5
Browse files Browse the repository at this point in the history
Django CMS Link 5 has been released and introduces some breaking
change. We have to update our demo site script to work with this new version.
  • Loading branch information
jbpenrath committed Dec 2, 2024
1 parent 51d6014 commit 8c774ab
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).

- Add Slider plugin

### Fixed

- Ugrade to djangocms-link 5

## [2.32.0] - 2024-11-27

### Changed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies = [
"Django<5",
"djangocms-file",
"djangocms-googlemap",
"djangocms-link<5",
"djangocms-link>=5.0.0,<6",
"djangocms-picture",
"djangocms-text-ckeditor",
"djangocms-video",
Expand Down
3 changes: 1 addition & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"matchPackageNames": [
"Django",
"django-cms",
"elasticsearch",
"djangocms-link"
"elasticsearch"
]
}
]
Expand Down
38 changes: 24 additions & 14 deletions src/richie/apps/demo/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,47 +373,57 @@

FOOTER_CONTENT = {
"en": [
{"name": "About", "internal_link": "annex__about"},
{"name": "Sitemap", "internal_link": "annex__sitemap"},
{"name": "Style guide", "external_link": "/styleguide/"},
{"name": "About", "link": {"internal_link": "annex__about"}},
{"name": "Sitemap", "link": {"internal_link": "annex__sitemap"}},
{"name": "Style guide", "link": {"external_link": "/styleguide/"}},
{
"title": "Richie community",
"items": [
{"name": "Website", "external_link": "https://richie.education"},
{
"name": "Website",
"link": {"external_link": "https://richie.education"},
},
{
"name": "Github",
"external_link": "https://github.com/openfun/richie",
"link": {"external_link": "https://github.com/openfun/richie"},
},
{
"name": "Site factory",
"external_link": "https://github.com/openfun/richie-site-factory",
"link": {
"external_link": "https://github.com/openfun/richie-site-factory"
},
},
{
"name": "Example site",
"external_link": "https://www.fun-campus.fr",
"link": {"external_link": "https://www.fun-campus.fr"},
},
],
},
],
"fr": [
{"name": "A propos", "internal_link": "annex__about"},
{"name": "Plan du site", "internal_link": "annex__sitemap"},
{"name": "Style guide", "external_link": "/styleguide/"},
{"name": "A propos", "link": {"internal_link": "annex__about"}},
{"name": "Plan du site", "link": {"internal_link": "annex__sitemap"}},
{"name": "Style guide", "link": {"external_link": "/styleguide/"}},
{
"title": "Communauté Richie",
"items": [
{"name": "Site web", "external_link": "https://richie.education"},
{
"name": "Site web",
"link": {"external_link": "https://richie.education"},
},
{
"name": "Github",
"external_link": "https://github.com/openfun/richie",
"link": {"external_link": "https://github.com/openfun/richie"},
},
{
"name": "Usine à sites",
"external_link": "https://github.com/openfun/richie-site-factory",
"link": {
"external_link": "https://github.com/openfun/richie-site-factory"
},
},
{
"name": "Site exemple",
"external_link": "https://www.fun-campus.fr",
"link": {"external_link": "https://www.fun-campus.fr"},
},
],
},
Expand Down
22 changes: 13 additions & 9 deletions src/richie/apps/demo/management/commands/create_demo_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def create_demo_site():
# Create pages as described in PAGES_INFOS
pages_created = recursive_page_creation(site, defaults.PAGES_INFO)

def get_internal_link(page):
return f"cms.page:{page.id}"

# Create the footer links
def create_footer_link(**link_info):
"""
Expand All @@ -89,9 +92,10 @@ def create_footer_link(**link_info):
Links can be nested into a NestedItemPlugin, in this case link_info contains
a target key.
"""
if "internal_link" in link_info:
if "internal_link" in link_info["link"]:
link_info = link_info.copy()
link_info["internal_link"] = pages_created[link_info["internal_link"]]
link_page = pages_created[link_info["link"]["internal_link"]]
link_info["link"] = {"internal_link": get_internal_link(link_page)}
add_plugin(plugin_type="LinkPlugin", **link_info)

footer_static_ph = StaticPlaceholder.objects.get_or_create(code="footer")[0]
Expand Down Expand Up @@ -486,7 +490,7 @@ def create_footer_link(**link_info):
target=courses_section,
name=content["courses_button_title"],
template=content["button_template_name"],
internal_link=pages_created["courses"],
link={"internal_link": get_internal_link(pages_created["courses"])},
)

# Add highlighted blogposts
Expand All @@ -512,7 +516,7 @@ def create_footer_link(**link_info):
target=blogposts_section,
name=content["blogposts_button_title"],
template=content["button_template_name"],
internal_link=pages_created["blogposts"],
link={"internal_link": get_internal_link(pages_created["blogposts"])},
)

# Add highlighted programs
Expand All @@ -538,7 +542,7 @@ def create_footer_link(**link_info):
target=programs_section,
name=content["programs_button_title"],
template=content["button_template_name"],
internal_link=pages_created["programs"],
link={"internal_link": get_internal_link(pages_created["programs"])},
)

# Add highlighted organizations
Expand Down Expand Up @@ -566,7 +570,7 @@ def create_footer_link(**link_info):
target=organizations_section,
name=content["organizations_button_title"],
template=content["button_template_name"],
internal_link=pages_created["organizations"],
link={"internal_link": get_internal_link(pages_created["organizations"])},
)

# Add highlighted subjects
Expand All @@ -592,7 +596,7 @@ def create_footer_link(**link_info):
target=subjects_section,
name=content["subjects_button_title"],
template=content["button_template_name"],
internal_link=pages_created["categories"],
link={"internal_link": get_internal_link(pages_created["categories"])},
)

# Add highlighted persons
Expand All @@ -618,7 +622,7 @@ def create_footer_link(**link_info):
target=persons_section,
name=content["persons_button_title"],
template=content["button_template_name"],
internal_link=pages_created["persons"],
link={"internal_link": get_internal_link(pages_created["persons"])},
)

# Add Glimpse quotes with empty title
Expand Down Expand Up @@ -756,7 +760,7 @@ def create_footer_link(**link_info):
target=sample_section,
name=content["section_sample_button_title"],
template=content["button_template_name"],
internal_link=pages_created["home"],
link={"internal_link": get_internal_link(pages_created["home"])},
)
# Add a licence
if licences:
Expand Down
8 changes: 4 additions & 4 deletions tests/plugins/section/test_templates_section_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def test_templates_section_default_flat(self):
placeholder,
plugin_type="LinkPlugin",
language="en",
external_link="http://www.example.com/1",
link={"external_link": "http://www.example.com/1"},
name="Example 1",
target=parent,
)
add_plugin(
placeholder,
plugin_type="LinkPlugin",
language="en",
external_link="http://www.example.com/2",
link={"external_link": "http://www.example.com/2"},
name="Example 2",
target=parent,
)
Expand Down Expand Up @@ -159,15 +159,15 @@ def test_templates_section_default_nested(self):
placeholder,
plugin_type="LinkPlugin",
language="en",
external_link="http://www.example.com/1",
link={"external_link": "http://www.example.com/1"},
name="Example 1",
target=parent,
)
add_plugin(
placeholder,
plugin_type="LinkPlugin",
language="en",
external_link="http://www.example.com/2",
link={"external_link": "http://www.example.com/2"},
name="Example 2",
target=parent,
)
Expand Down

0 comments on commit 8c774ab

Please sign in to comment.