macroprocesso.py 1.54 KB
# -*- coding: utf-8 -*-

from zope import schema
from plone.dexterity.content import Container
from plone.supermodel import model
from plone.autoform import directives as form
from z3c.form.browser.text import TextWidget
from plone.app.z3cform.wysiwyg import WysiwygFieldWidget

from five import grok

from plone.namedfile.field import NamedBlobImage
from pf.biblioteca import MessageFactory as _


class IMacroProcesso(model.Schema):
    """
    Macroprocesso
    """
    # http://docs.plone.org/external/plone.app.dexterity/docs/reference/fields.html
    # http://docs.plone.org/external/plone.app.dexterity/docs/reference/widgets.html
    # https://pythonhosted.org/z3c.form/browser/README.html
    # http://docs.plone.org/develop/addons/schema-driven-forms/customising-form-behaviour/widgets.html
    # https://pypi.python.org/pypi/plone.autoform
    form.widget('title', TextWidget, klass="macroprocesso-title")
    title = schema.TextLine(
        title=_(u"Título"),
        description=u'',
        required=True,
        max_length=55
    )

    description = schema.Text(
        title=_(u"Descrição"),
        description=u"",
        required=False,
    )
    form.widget(description=WysiwygFieldWidget)

    imagem = NamedBlobImage(
        title=_(u"Imagem do Macroprocesso"),
        description=_(u"Selecione uma imagem representativa do Macroprocesso"),
        required=True,
    )


class MacroProcesso(Container):
    grok.implements(IMacroProcesso)

    def canSetDefaultPage(self):
        """ User don't can set default page """
        return False