summaryrefslogtreecommitdiffstats
path: root/tabellio/pfbviews/homenews.py
blob: 7ff74a65bf124d6a90c4d6f6e4c068504a39679a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from five import grok
from zope import schema
from zope.interface import implements
from z3c.relationfield.schema import RelationChoice
from Products.Five import BrowserView

from plone.directives import form, dexterity
from plone.dexterity.content import Item
from plone.formwidget.contenttree import ObjPathSourceBinder
from plone.app.textfield import RichText
from plone.namedfile.field import NamedImage

from tabellio.pfbviews import MessageFactory as _

class IHomeNews(form.Schema):
    picture = NamedImage(title=_(u'Picture'), required=False)
    homepage_text = RichText(title=_(u'Homepage Text'), required=True)
    text = RichText(title=_(u'Text'), required=False)
    on_homepage = schema.Bool(title=_(u'Include on homepage'), default=True)

class HomeNews(Item):
    implements(IHomeNews)

class View(grok.View):
    grok.context(IHomeNews)
    grok.require('zope2.View')

class PictureView(BrowserView):
    def __call__(self):
        if not self.context.picture:
            return None
        self.request.response.setHeader('Content-type', self.context.picture.contentType)
        return self.context.picture.data