Merge branch 'release/0.8.x' into develop

This commit is contained in:
Iacopo Spalletti 2017-07-26 01:43:39 +02:00
commit baa3eccab9
No known key found for this signature in database
GPG Key ID: BDCBC2EB289F60C6
7 changed files with 55 additions and 24 deletions

View File

@ -34,6 +34,15 @@ Implement Features
Look through the GitHub issues for features. Anything tagged with "feature" Look through the GitHub issues for features. Anything tagged with "feature"
is open to whoever wants to implement it. is open to whoever wants to implement it.
Branching model
~~~~~~~~~~~~~~~
When planning a code cotnribution, these is the project branching model:
* new features goes to develop
* bugfixes for releases goes to release/Y.Z.x branches
* master is just a snapshot of the latest stable release and should not be targeted
Write Documentation Write Documentation
=================== ===================
@ -81,7 +90,11 @@ tests, including testing other Python versions with tox::
$ tox $ tox
<<<<<<< HEAD
To get tox, just pip install them into your virtualenv. To get tox, just pip install them into your virtualenv.
=======
To get flake8 and tox, just pip install them into your virtualenv.
>>>>>>> release/0.8.x
6. Commit your changes and push your branch to GitHub:: 6. Commit your changes and push your branch to GitHub::
@ -101,7 +114,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put 2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the your new functionality into a function with a docstring, and add the
feature to the list in README.rst. feature to the list in README.rst.
3. The pull request should work for Python 2.7, 3.4, and 3.5. Check 3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6. Check
https://travis-ci.org/nephila/djangocms-blog/pull_requests https://travis-ci.org/nephila/djangocms-blog/pull_requests
and make sure that the tests pass for all supported Python versions. and make sure that the tests pass for all supported Python versions.

View File

@ -26,12 +26,12 @@ History
******************* *******************
0.8.13 (unreleased) 0.8.13 (2017-07-25)
******************* *******************
* Drop python 2.6 compatibility * Dropped python 2.6 compatibility
* Fixed exceptions in __str__ * Fixed exceptions in __str__
* Drop python 2.6 compatibility * Fixed issue with duplicated categories in menu
******************* *******************
0.8.12 (2017-03-11) 0.8.12 (2017-03-11)

View File

@ -105,6 +105,7 @@ HELPER_SETTINGS = dict(
} }
}, },
BLOG_AUTO_SETUP=False, BLOG_AUTO_SETUP=False,
ALLOWED_HOSTS=['*'],
) )
try: try:

View File

@ -3,6 +3,6 @@ from __future__ import absolute_import, print_function, unicode_literals
__author__ = 'Iacopo Spalletti' __author__ = 'Iacopo Spalletti'
__email__ = 'i.spalletti@nephila.it' __email__ = 'i.spalletti@nephila.it'
__version__ = '0.9b9' __version__ = '0.9b10'
default_app_config = 'djangocms_blog.apps.BlogAppConfig' default_app_config = 'djangocms_blog.apps.BlogAppConfig'

View File

@ -48,6 +48,13 @@ class BlogCategoryMenu(CMSAttachMenu):
namespace=self.instance.application_namespace namespace=self.instance.application_namespace
) )
config = self._config[self.instance.application_namespace] config = self._config[self.instance.application_namespace]
if hasattr(self, 'instance') and self.instance:
if not getattr(request, 'toolbar', False) or not request.toolbar.edit_mode:
if self.instance == self.instance.get_draft_object():
return []
else:
if self.instance == self.instance.get_public_object():
return []
if config and config.menu_structure in (MENU_TYPE_COMPLETE, MENU_TYPE_CATEGORIES): if config and config.menu_structure in (MENU_TYPE_COMPLETE, MENU_TYPE_CATEGORIES):
categories_menu = True categories_menu = True
if config and config.menu_structure in (MENU_TYPE_COMPLETE, MENU_TYPE_POSTS): if config and config.menu_structure in (MENU_TYPE_COMPLETE, MENU_TYPE_POSTS):
@ -86,23 +93,28 @@ class BlogCategoryMenu(CMSAttachMenu):
if config: if config:
categories = categories.namespace(self.instance.application_namespace) categories = categories.namespace(self.instance.application_namespace)
if config and not config.menu_empty_categories: if config and not config.menu_empty_categories:
categories = categories.filter(pk__in=used_categories) categories = categories.active_translations(language).filter(
pk__in=used_categories
).distinct()
else: else:
categories = categories.active_translations(language).distinct() categories = categories.active_translations(language).distinct()
categories = categories.order_by('parent__id', 'translations__name').\ categories = categories.order_by('parent__id', 'translations__name').\
select_related('app_config').prefetch_related('translations') select_related('app_config').prefetch_related('translations')
added_categories = []
for category in categories: for category in categories:
node = NavigationNode( if category.pk not in added_categories:
category.name, node = NavigationNode(
category.get_absolute_url(), category.name,
'{0}-{1}'.format(category.__class__.__name__, category.pk), category.get_absolute_url(),
( '{0}-{1}'.format(category.__class__.__name__, category.pk),
'{0}-{1}'.format( (
category.__class__.__name__, category.parent.id '{0}-{1}'.format(
) if category.parent else None category.__class__.__name__, category.parent.id
) if category.parent else None
)
) )
) nodes.append(node)
nodes.append(node) added_categories.append(category.pk)
return nodes return nodes

View File

@ -6,6 +6,7 @@ from django.utils.translation import activate
from menus.menu_pool import menu_pool from menus.menu_pool import menu_pool
from parler.utils.context import smart_override, switch_language from parler.utils.context import smart_override, switch_language
from djangocms_blog.models import BlogCategory
from djangocms_blog.settings import ( from djangocms_blog.settings import (
MENU_TYPE_CATEGORIES, MENU_TYPE_COMPLETE, MENU_TYPE_NONE, MENU_TYPE_POSTS, MENU_TYPE_CATEGORIES, MENU_TYPE_COMPLETE, MENU_TYPE_NONE, MENU_TYPE_POSTS,
) )
@ -46,9 +47,10 @@ class MenuTest(BaseTest):
for lang in ('en', 'it'): for lang in ('en', 'it'):
with smart_override(lang): with smart_override(lang):
self._reset_menus() self._reset_menus()
request = self.get_page_request(pages[1], self.user, pages[1].get_absolute_url(lang)) request = self.get_page_request(pages[1], self.user, pages[1].get_absolute_url(lang), edit=True)
nodes = menu_pool.get_nodes(request) nodes = menu_pool.get_nodes(request)
nodes_url = set([node.url for node in nodes]) self.assertTrue(len(nodes), BlogCategory.objects.all().count() + len(pages))
nodes_url = set([node.get_absolute_url() for node in nodes])
cats_url = set([cat.get_absolute_url() for cat in self.cats if cat.has_translation(lang)]) cats_url = set([cat.get_absolute_url() for cat in self.cats if cat.has_translation(lang)])
self.assertTrue(cats_url.issubset(nodes_url)) self.assertTrue(cats_url.issubset(nodes_url))
@ -57,9 +59,11 @@ class MenuTest(BaseTest):
for lang in ('en', 'it'): for lang in ('en', 'it'):
with smart_override(lang): with smart_override(lang):
self._reset_menus() self._reset_menus()
request = self.get_page_request(pages[1], self.user, pages[1].get_absolute_url(lang)) request = self.get_page_request(pages[1].get_draft_object(), self.user, pages[1].get_draft_object().get_absolute_url(lang))
nodes = menu_pool.get_nodes(request) nodes = menu_pool.get_nodes(request)
nodes_url = set([node.url for node in nodes]) urls = [node.get_absolute_url() for node in nodes]
nodes_url = [node.get_absolute_url() for node in nodes]
self.assertTrue(len(nodes_url), BlogCategory.objects.all().count() + len(pages))
self.assertFalse(posts[0].get_absolute_url(lang) in nodes_url) self.assertFalse(posts[0].get_absolute_url(lang) in nodes_url)
self.assertTrue(posts[1].get_absolute_url(lang) in nodes_url) self.assertTrue(posts[1].get_absolute_url(lang) in nodes_url)
@ -94,7 +98,7 @@ class MenuTest(BaseTest):
with smart_override(lang): with smart_override(lang):
self._reset_menus() self._reset_menus()
nodes = menu_pool.get_nodes(request) nodes = menu_pool.get_nodes(request)
nodes_url = set([node.url for node in nodes]) nodes_url = set([node.get_absolute_url() for node in nodes])
self.assertFalse(cats_url[lang].issubset(nodes_url)) self.assertFalse(cats_url[lang].issubset(nodes_url))
self.assertFalse(posts_url[lang].issubset(nodes_url)) self.assertFalse(posts_url[lang].issubset(nodes_url))
@ -107,7 +111,7 @@ class MenuTest(BaseTest):
with smart_override(lang): with smart_override(lang):
self._reset_menus() self._reset_menus()
nodes = menu_pool.get_nodes(request) nodes = menu_pool.get_nodes(request)
nodes_url = set([node.url for node in nodes]) nodes_url = set([node.get_absolute_url() for node in nodes])
self.assertFalse(cats_url[lang].issubset(nodes_url)) self.assertFalse(cats_url[lang].issubset(nodes_url))
self.assertTrue(posts_url[lang].issubset(nodes_url)) self.assertTrue(posts_url[lang].issubset(nodes_url))
@ -120,7 +124,7 @@ class MenuTest(BaseTest):
with smart_override(lang): with smart_override(lang):
self._reset_menus() self._reset_menus()
nodes = menu_pool.get_nodes(request) nodes = menu_pool.get_nodes(request)
nodes_url = set([node.url for node in nodes]) nodes_url = set([node.get_absolute_url() for node in nodes])
self.assertTrue(cats_url[lang].issubset(nodes_url)) self.assertTrue(cats_url[lang].issubset(nodes_url))
self.assertFalse(posts_url[lang].issubset(nodes_url)) self.assertFalse(posts_url[lang].issubset(nodes_url))
@ -133,7 +137,7 @@ class MenuTest(BaseTest):
with smart_override(lang): with smart_override(lang):
self._reset_menus() self._reset_menus()
nodes = menu_pool.get_nodes(request) nodes = menu_pool.get_nodes(request)
nodes_url = set([node.url for node in nodes]) nodes_url = set([node.get_absolute_url() for node in nodes])
self.assertTrue(cats_url[lang].issubset(nodes_url)) self.assertTrue(cats_url[lang].issubset(nodes_url))
self.assertTrue(posts_url[lang].issubset(nodes_url)) self.assertTrue(posts_url[lang].issubset(nodes_url))

View File

@ -10,6 +10,7 @@ deps =
django18: cmsplugin-filer<1.2 django18: cmsplugin-filer<1.2
django18: django-haystack django18: django-haystack
django18: djangocms-admin-style>1.2,<1.3 django18: djangocms-admin-style>1.2,<1.3
django18: django-parler>=1.6
django19: Django>=1.9,<1.10 django19: Django>=1.9,<1.10
django19: django-mptt>=0.8 django19: django-mptt>=0.8
django19: django-filer<1.3 django19: django-filer<1.3