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

Plone 5 (tests OK) #20

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ after_success:
- coveralls
addons:
firefox: "latest"
install:
install:
- pip install coveralls
- make bin/test
env:
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ Changelog
0.4.1 (unreleased)
------------------

- Fix plone.protect error
[laulaz]

- Renaming based on EN translation
This also fixes tests on local machine
[laulaz]

- Fix controlpanel in Plone 5.
[pbauer]


0.4.0 (2018-06-25)
------------------
Expand Down
11 changes: 10 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
# Get more strings from
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Framework :: Plone",
"Framework :: Plone :: 4.3",
"Framework :: Plone :: 5.0",
"Framework :: Plone :: 5.1",
"Programming Language :: Python",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
],
keywords='Plone content diagnosis',
author='Godefroid Chapelle',
author_email='[email protected]',
url='http://svn.plone.org/svn/collective/',
url='https://github.com/collective/collective.jekyll',
license='gpl',
packages=find_packages('src'),
package_dir={'': 'src'},
Expand All @@ -49,4 +53,9 @@
'pytest',
'gocept.pytestlayer',
]),
entry_points="""
# -*- Entry points: -*-
[z3c.autoinclude.plugin]
target = plone
""",
)
48 changes: 27 additions & 21 deletions src/collective/jekyll/browser/collection_view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
batch topicContents;">
<table class="listing"
summary="Content listing"
tal:define="vocab python:here.listMetaDataFields(False);
use_view_action site_properties/typesUseViewActionInListings|python:();"
tal:define="use_view_action site_properties/typesUseViewActionInListings|python:();"
i18n:attributes="summary summary_content_listing;">
<thead>
<tr>
Expand All @@ -27,8 +26,8 @@
tal:attributes="title type/help; href type/url" />
<span tal:condition="python:view.getSymptomName() == type.name">&#x25bc;</span>
</th>
<th tal:repeat="field here/getCustomViewFields"
tal:content="python:vocab.getValue(field, field)"
<th tal:repeat="field here/selectedViewFields"
tal:content="python:field[1]"
i18n:translate=""/>
</tr>
</thead>
Expand All @@ -44,38 +43,45 @@
tal:replace="structure symptom/@@status" />
</td>
</tal:symptoms>
<tal:fields repeat="field here/getCustomViewFields"
<tal:fields repeat="field here/customViewFields"
define="normalizeString nocall:context/@@plone/normalizeString;
toLocalizedTime nocall: context/@@plone/toLocalizedTime;
url obj/getURL;
obj_type obj/portal_type;
obj_type_class python:'contenttype-' + normalizeString(obj_type);
obj_description obj/Description;
obj_typeinfo python: here.portal_types.getTypeInfo(obj_type);
obj_icon python:plone_view.getIcon(obj);
obj_has_image python:obj.getIcon;
obj_wf_state obj/review_state|python: wtool.getInfoFor(obj, 'review_state', '');
obj_wf_state_class python:'state-' + normalizeString(obj_wf_state);
obj_url python:url+'/view' if obj_type in use_view_action else url;
title_or_id obj/pretty_title_or_id">
<tal:block define="value python: getattr(obj, field, None)">
<td tal:condition="python: field != 'Title'"
tal:content="python:here.formatCatalogMetadata(value)"
<td tal:condition="python: field != 'Title' and field not in ['ModificationDate',
'CreationDate', 'EffectiveDate',
'ExpirationDate', ]"
tal:content="value"
Copy link
Member

Choose a reason for hiding this comment

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

I prefer logic to be kept in view classes. Would it be possible to move this tal:condition test to a method on a view class ?

i18n:translate=""/>
<td tal:condition="python:field in ['ModificationDate',
'CreationDate', 'EffectiveDate',
'ExpirationDate', ]">
<span tal:replace="python:toLocalizedTime(value,long_format=1)">
August 16, 2001 at 23:35:59
</span>
</td>
<td tal:condition="python: field == 'Title'">
<a href="#" tal:attributes="href obj_url;
title obj_description;">
<img src="#"
height="16"
width="16"
tal:condition="obj_icon/url"
tal:attributes="src obj_icon/url;
alt obj_icon/description;
title obj_icon/title;
width obj_icon/width;
height obj_icon/height;"/>
<a href="#"
tal:condition="obj_has_image"
tal:attributes="href obj_url;
title obj_description;">
<img class="thumb-icon"
tal:define="getIcon python:obj.getURL() +'/@@images/image/icon'"
Copy link
Member

Choose a reason for hiding this comment

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

python: in the template is often a smell. I would compute the image URL in the view class.

tal:attributes="src string:$getIcon;alt obj/Description">
</a>
<a href="#"
tal:condition="python: obj.portal_type != 'Link'"
tal:attributes="href obj_url;
class string:${obj_wf_state_class};
class string:${obj_type_class} ${obj_wf_state_class} url;
title obj_description;"
tal:content="title_or_id">
Item Title
Expand All @@ -84,7 +90,7 @@
<a href="#"
tal:condition="python: obj.portal_type == 'Link'"
tal:attributes="href obj/getRemoteUrl;
class string:${obj_wf_state_class} link-plain;
class string:${obj_type_class} ${obj_wf_state_class} link-plain;
title obj_description;"
class="link-plain"
tal:content="title_or_id" />
Expand Down
4 changes: 1 addition & 3 deletions src/collective/jekyll/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="collective.jekyll">

<adapter factory=".controlpanel.JekyllControlPanelAdapter" />

<browser:page
name="jekyll-controlpanel"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
Expand All @@ -17,7 +15,7 @@
/>

<browser:page
for="plone.app.collection.interfaces.ICollection"
for="plone.app.contenttypes.interfaces.ICollection"
name="diagnosis_view"
class=".diagnosis.DiagnosisCollectionView"
template="collection_view.pt"
Expand Down
59 changes: 9 additions & 50 deletions src/collective/jekyll/browser/controlpanel.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,16 @@
from zope.interface import implements
from zope.component import adapts
from zope.component import getUtility
from zope.formlib import form
from zope.schema.interfaces import IVocabularyFactory

from Products.CMFDefault.formlib.schema import SchemaAdapterBase
from Products.CMFPlone.interfaces import IPloneSiteRoot

from plone.registry.interfaces import IRegistry
from plone.app.controlpanel.form import ControlPanelForm
from plone.app.controlpanel.widgets import MultiCheckBoxThreeColumnWidget

# -*- coding: utf-8 -*-
from collective.jekyll import jekyllMessageFactory as _
from collective.jekyll.interfaces import IJekyllSettings
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
from plone.app.registry.browser.controlpanel import RegistryEditForm
from plone.z3cform import layout


class JekyllControlPanelAdapter(SchemaAdapterBase):

adapts(IPloneSiteRoot)
implements(IJekyllSettings)

def __init__(self, context):
super(JekyllControlPanelAdapter, self).__init__(context)
registry = getUtility(IRegistry)
self.settings = registry.forInterface(IJekyllSettings, False)
vocabFactory = getUtility(IVocabularyFactory,
name="collective.jekyll.SymptomsVocabulary")
self.symptoms = vocabFactory(context)

def getActiveSymptoms(self):
if self.settings.activeSymptoms is None:
return [s.value for s in self.symptoms]

activeSymptoms = []
for symptom in self.symptoms:
if symptom.value in self.settings.activeSymptoms:
activeSymptoms.append(symptom.value)
return activeSymptoms

def setActiveSymptoms(self, value):
self.settings.activeSymptoms = value

activeSymptoms = property(getActiveSymptoms,
setActiveSymptoms)


class JekyllControlPanel(ControlPanelForm):

class JekyllControlPanelForm(RegistryEditForm):
schema = IJekyllSettings
label = _("Content quality")
description = _("You can activate / deactivate symptoms using this form.")
form_name = _("Symptoms activation")

form_fields = form.FormFields(IJekyllSettings)
active_symptoms = form_fields['activeSymptoms']
active_symptoms.custom_widget = MultiCheckBoxThreeColumnWidget
active_symptoms.custom_widget.cssClass = 'label'

JekyllControlPanel = layout.wrap_form(
JekyllControlPanelForm, ControlPanelFormWrapper)
2 changes: 1 addition & 1 deletion src/collective/jekyll/browser/diagnosis.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def items(self):
return results

def _getResults(self):
return self.context.getQuery(brains=True)
return list(self.context.results(brains=True))

def getSymptomName(self):
name = self.request.get('symptom_name', None)
Expand Down
24 changes: 16 additions & 8 deletions src/collective/jekyll/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@
description="Installs the collective.jekyll package"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>


<genericsetup:registerProfile
name="uninstall"
title="uninstall collective.jekyll"
directory="profiles/uninstall"
description="Uninstall the collective.jekyll package"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

<i18n:registerTranslations directory="locales" />

<adapter
Expand Down Expand Up @@ -66,37 +74,37 @@
factory=".symptoms.TitleFormatSymptom" />

<subscriber
for="Products.Archetypes.interfaces.IExtensibleMetadata"
for="plone.dexterity.interfaces.IDexterityContent"
provides=".interfaces.ISymptom"
factory=".symptoms.DescriptionLengthSymptom" />

<subscriber
for="Products.Archetypes.interfaces.IExtensibleMetadata"
for="plone.dexterity.interfaces.IDexterityContent"
provides=".interfaces.ISymptom"
factory=".symptoms.DescriptionFormatSymptom" />

<subscriber
for="Products.ATContentTypes.interfaces.IATDocument"
for="plone.app.contenttypes.behaviors.richtext.IRichText"
provides=".interfaces.ISymptom"
factory=".symptoms.BodyTextPresentSymptom" />

<subscriber
for="Products.ATContentTypes.interfaces.IATDocument"
for="plone.app.contenttypes.behaviors.richtext.IRichText"
provides=".interfaces.ISymptom"
factory=".symptoms.SpacesInBodySymptom" />

<subscriber
for="Products.ATContentTypes.interfaces.IATDocument"
for="plone.app.contenttypes.behaviors.richtext.IRichText"
provides=".interfaces.ISymptom"
factory=".symptoms.LinksInBodySymptom" />

<subscriber
for="Products.ATContentTypes.interfaces.IATNewsItem"
for="plone.app.contenttypes.interfaces.INewsItem"
provides=".interfaces.ISymptom"
factory=".symptoms.ImagePresentSymptom" />

<subscriber
for="Products.ATContentTypes.interfaces.IATNewsItem"
for="plone.app.contenttypes.interfaces.INewsItem"
provides=".interfaces.ISymptom"
factory=".symptoms.ImageSizeSymptom" />

Expand Down
5 changes: 5 additions & 0 deletions src/collective/jekyll/ignored.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from collective.jekyll.interfaces import IIgnoredSymptomNames
from persistent.dict import PersistentDict
from plone.protect.auto import safeWrite
from zope.annotation.interfaces import IAnnotations
from zope.interface import implements
from zope.component import ComponentLookupError
Expand All @@ -20,6 +21,10 @@ def _getNamesDict(self):
annotations = IAnnotations(self.context)
except ComponentLookupError:
return {}
try:
safeWrite(annotations.obj.__annotations__)
except AttributeError:
pass
return annotations.setdefault(
JEKYLL_IGNORED_SYMPTOMS, PersistentDict())

Expand Down
Loading