Improved Page and Title extension documentation #5845

Merged
merged 2 commits into from Jan 11, 2017

Projects

None yet

2 participants

@evildmp
Contributor
evildmp commented Jan 10, 2017 edited
  • improved Page example
  • corrected Title example so it actually works properly
  • removed broken example from cms.toolbar.ExtensionToolbar comments
  • bonus: removed out-of-date note about redo/undo from documentation home page

Fixes #5092
Fixes #5083

[ci skip]

@evildmp evildmp Improved Page and Title extension documentation
* improved Page example
* corrected Title example so it actually works properly
* removed broken example from cms.toolbar.ExtensionToolbar comments

Fixes #5092
Fixes #5083

[ci skip]
b4bc252
+ # create a 3-tuple of (title_extension, url, title)
+ nodes = [(title_extension, url, title.title) for (
+ (title_extension, url), title) in zip(urls, titleset)
+ ]
@evildmp
evildmp Jan 10, 2017 Contributor

This shouldn't be necessary! There ought to be a much nicer way to get the language versions' titles. I think it will need different behaviour from get_title_extension_admin() however - what do you think @czpython?

@czpython
czpython Jan 11, 2017 Member

You can do:

# retrieves the instances of the current title extension (if any)
# and the toolbar item URL
urls = self.get_title_extension_admin()

# cycle through the list of nodes
for title_extension, url in nodes:
    title = title_extension.extended_object
    # adds toolbar items
    sub_menu.add_modal_item('Rate %s' % title, url=url, disabled=not self.toolbar.edit_mode)
@evildmp
evildmp Jan 11, 2017 Contributor

That won't work unfortunately, except on titles that already have been extended.

Otherwise, you'll get an attribute error when trying to get the extended_object of None.

@evildmp
evildmp Jan 11, 2017 Contributor

Really, we need get_title_extension_admin() to return more information - but that's going to be a breaking change for many existing implementations that use it.

@evildmp evildmp requested a review from czpython Jan 10, 2017
docs/reference/pages.rst
@@ -6,3 +6,6 @@ Models
A ``Page`` is the basic unit of site structure in django CMS. The CMS uses a hierachical page model: each page
stands in relation to other pages as parent, child or sibling.
+
+ A ``Page`` also has language-specific properties - for example, it will have a title and a slugfor each language it
@czpython
czpython Jan 11, 2017 Member

and a slug for

+ # create a 3-tuple of (title_extension, url, title)
+ nodes = [(title_extension, url, title.title) for (
+ (title_extension, url), title) in zip(urls, titleset)
+ ]
@czpython
czpython Jan 11, 2017 Member

You can do:

# retrieves the instances of the current title extension (if any)
# and the toolbar item URL
urls = self.get_title_extension_admin()

# cycle through the list of nodes
for title_extension, url in nodes:
    title = title_extension.extended_object
    # adds toolbar items
    sub_menu.add_modal_item('Rate %s' % title, url=url, disabled=not self.toolbar.edit_mode)
@evildmp evildmp merged commit 580d06e into divio:release/3.4.x Jan 11, 2017
@evildmp evildmp deleted the evildmp:docs-page-title-extensions branch Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment