Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: ✅(demo) improve demo site page tree #345

Merged
merged 1 commit into from Sep 4, 2018
Merged

Conversation

sveetch
Copy link
Collaborator

@sveetch sveetch commented Sep 3, 2018

Purpose

Page tree is just a flat list of pages, all enabled in navigation.
But we don't want every pages to be in menus and need a more advanced
architecture to be able to create an additional menu for annexe page
like About, Help, Legal mentions, etc..

Proposal

This commit hides some pages from menus and add a new page "Annexe"
where "About" page is moved in.

@@ -26,6 +26,7 @@

logger = logging.getLogger("richie.commands.core.create_demo_site")

DEMO_ANNEXE_PAGE_ID = "annexe"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it "annex" in english so:

ANNEX_PAGE_ID = "annex"

@@ -111,28 +130,59 @@ def clear_cms_data():
Person.objects.all().delete()


def create_demo_site():
def recursive_page_creation(site, pages, parent=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is becoming too complicated for just one child page, and you have created empty pages so the final solution where you add content to each page will not look like this...

For the moment, maybe just add this to the create_demo_site method:

languages=[l[0] for l in settings.LANGUAGES]
about_page = create_i18n_page(
    languages=languages,
    parent=pages_created["annex"],
    published=True,
)
create_text_plugin(
    about_page,
    "main_content",
    languages=languages,
)

@@ -79,6 +79,16 @@ def _after_postgeneration(cls, instance, create, results=None):
for language in instance.extended_object.get_languages():
instance.extended_object.publish(language)

@factory.post_generation
# pylint: disable=no-self-use,unused-argument
def in_navigation(self, create, extracted, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just modify the existing method "extended_object" like so:

@factory.lazy_attribute
def extended_object(self):
    return create_i18n_page(
        title=self.title,
        languages=self.languages,
        template=self.template,
        in_navigation=self.in_navigation,
        parent=self.parent,
    )

Page tree is just a flat list of pages, all enabled in navigation.
But we don't want every pages to be in menus and need a more advanced
architecture to be able to create an additional menu for annexe page
like About, Help, Legal mentions, etc..

This commit hides some pages from menus and add a new page "Annexe"
where "About" page is moved in.
@sveetch sveetch merged commit fc81a74 into master Sep 4, 2018
@sveetch sveetch deleted the demo_new_page_tree branch September 4, 2018 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants