Skip to content

Commit

Permalink
Do not use formlib if you are on Plone5
Browse files Browse the repository at this point in the history
  • Loading branch information
ale-rt committed Mar 31, 2017
1 parent 5f68c8f commit 1eb6f83
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/collective/polls/portlet/voteportlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@
from plone.memoize.instance import memoize
from plone.portlets.interfaces import IPortletDataProvider
from plone.portlets.interfaces import IPortletManager
from Products.CMFPlone.utils import getFSVersionTuple
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zope import schema
from zope.component import ComponentLookupError
from zope.component import getUtility
from zope.component import queryUtility
from zope.formlib import form
from zope.interface import alsoProvides
from zope.interface import implementer
from zope.schema.interfaces import IContextSourceBinder
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary


if getFSVersionTuple()[0] <= 4:
from zope.formlib import form
else:
form = None


def PossiblePolls(context):
portal_state = api.content.get_view(
name='plone_portal_state',
Expand All @@ -28,7 +34,11 @@ def PossiblePolls(context):
)
utility = queryUtility(IPollUtility, name='collective.polls')
navigation_root = portal_state.navigation_root()
polls = utility.recent_polls(context=navigation_root, show_all=False, limit=999999)
polls = utility.recent_polls(
context=navigation_root,
show_all=False,
limit=999999,
)

values = [SimpleTerm(value='latest', title=_(u'Latest opened poll'))]
values.extend(
Expand Down Expand Up @@ -148,7 +158,9 @@ class AddForm(base.AddForm):
"""Portlet add form."""

schema = IVotePortlet
form_fields = form.Fields(IVotePortlet)

if form is not None:
form_fields = form.Fields(IVotePortlet)

def create(self, data):
return Assignment(**data)
Expand All @@ -158,4 +170,5 @@ class EditForm(base.EditForm):
"""Portlet edit form."""

schema = IVotePortlet
form_fields = form.Fields(IVotePortlet)
if form is not None:
form_fields = form.Fields(IVotePortlet)

0 comments on commit 1eb6f83

Please sign in to comment.