Skip to content

Commit

Permalink
Merge 8a4aad7 into 22763d6
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Jul 3, 2019
2 parents 22763d6 + 8a4aad7 commit 2d2f3f8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -6,6 +6,9 @@ There's a frood who really knows where his towel is.
2.13b4 (unreleased)
^^^^^^^^^^^^^^^^^^^

- Explicity remove the viewlet for folder_contents view (closes `#261 <https://github.com/plonegovbr/brasil.gov.temas/issues/261>`_).
[rodfersou]

- Code refactor to increase future Python 3 compatibility;
add dependency on `six <https://pypi.python.org/pypi/six>`_.
[hvelarde]
Expand Down
14 changes: 14 additions & 0 deletions buildout.cfg
Expand Up @@ -49,3 +49,17 @@ recipe = zc.recipe.egg
eggs = ${instance:eggs}
interpreter = zopepy
scripts = zopepy

[versions]
setuptools = 33.1.1
zc.buildout = 2.9.5

# code analysis
configparser = 3.5.3
enum34 = 1.1.6
flake8 = 3.5.0
mccabe = 0.6.1
pycodestyle = 2.3.1
pyflakes = 1.6.0
pylint = 1.9.3
lazy-object-proxy = 1.3.1
5 changes: 4 additions & 1 deletion sc/social/like/browser/helper.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_inner
from plone import api
from plone.app.content.browser.interfaces import IFolderContentsView
from plone.app.layout.globals.interfaces import IViewView
from plone.formwidget.namedfile.converter import b64decode_file
from plone.memoize.view import memoize
Expand Down Expand Up @@ -43,9 +44,11 @@ def plugins_enabled(self):
return configs.plugins_enabled or []

@memoize
def enabled(self, view=None):
def enabled(self, view):
if view and not IViewView.providedBy(view):
return False
if view and IFolderContentsView.providedBy(view):
return False
enabled_portal_types = self.enabled_portal_types()
return self.context.portal_type in enabled_portal_types

Expand Down
2 changes: 1 addition & 1 deletion sc/social/like/browser/viewlets.py
Expand Up @@ -54,7 +54,7 @@ def enabled(self):
except WorkflowException:
# no workflow on context, like in site root
published = True
return all([published, self.helper.enabled(), self.plugins()])
return all([published, self.helper.enabled(self.view), self.plugins()])

# HACK: fixes https://bitbucket.org/takaki/sc.social.like/issue/1
def update(self):
Expand Down
10 changes: 9 additions & 1 deletion sc/social/like/tests/test_viewlets.py
Expand Up @@ -124,7 +124,8 @@ def test_metadata_viewlet_rendering(self):
self.assertIn('og:locale', html)
self.assertIn('og:site_name', html)

@unittest.skipIf(skip_profiling, 'Skipping performance measure and code profiling')
@unittest.skipIf(
skip_profiling, 'Skipping performance measure and code profiling')
def test_metadata_viewlet_rendering_performance(self):
self._enable_all_plugins()
times, limit = 1000, 5 # rendering 1000 times must take less than 5ms
Expand Down Expand Up @@ -177,6 +178,13 @@ def test_social_viewlet_is_disabled_on_content_edit(self):
html = self.obj.restrictedTraverse('@@edit')() # Dexterity
self.assertNotIn('id="viewlet-social-like"', html)

# TODO: find why folder_contents view is not available in Plone 5
@unittest.skipIf(IS_PLONE_5, "Plone 5 don't have this view")
def test_viewlet_is_not_present_in_foldercontents(self):
view = api.content.get_view(
name=u'folder_contents', context=self.obj, request=self.request)
self.assertNotIn('id="viewlet-social-like"', view())

def test_social_viewlet_rendering(self):
viewlet = self.viewlet(self.obj)
html = viewlet.render()
Expand Down

0 comments on commit 2d2f3f8

Please sign in to comment.