source: publico/PortalInterlegis/produtos/il.portal.theme/trunk/il/portal/theme/browser/tile.py @ 6079

Última Alteração nesse arquivo desde 6079 foi 6079, incluída por lucasaquino, 8 anos atrás

Registra tile related

File size: 1.9 KB
Linha 
1from zope.interface import Interface
2from z3c.form import form, field
3from plone.z3cform import layout
4from plone import tiles
5from zope.schema import Text
6from plone.app.textfield import RichText
7from plone.app.textfield.interfaces import ITransformer
8
9from z3c.relationfield.schema import RelationChoice, RelationList
10
11from plone.formwidget.autocomplete.widget import (
12    AutocompleteMultiFieldWidget,
13    )
14from plone.formwidget.contenttree import (
15    ContentTreeFieldWidget,
16    ObjPathSourceBinder,
17    )
18
19
20class IRichTextTileData(Interface):
21   
22    text = RichText(title=u'Text')
23
24class RichTextTile(tiles.PersistentTile):
25
26    def __call__(self):
27        text = ''
28        if self.data['text']:
29            transformer = ITransformer(self.context, None)
30            if transformer is not None:
31                text = transformer(self.data['text'], 'text/x-html-safe')
32        return '<html><body>%s</body></html>' % text
33
34class IPlainTextTileData(Interface):
35   
36    text = Text(title=u"Text")
37   
38class PlainTextTile(tiles.PersistentTile):
39
40    def __call__(self):
41        text = ''
42        if self.data['text']:
43            text = self.data['text']
44        return '<html><body>%s</body></html>' % text
45
46class IRelatedItensTileData(Interface):
47   
48    related_itens = RelationChoice(title=u"Escolha o item relacionado",
49                       required=False,
50                       source=ObjPathSourceBinder())
51   
52    #import pdb;pdb.set_trace()
53   
54class RelatedForm(form.EditForm):
55    fields = field.Fields(IRelatedItensTileData)
56    fields['related_itens'].widgetFactory = ContentTreeFieldWidget
57   
58RelatedView = layout.wrap_form(RelatedForm)
59
60class RelatedItensTile(tiles.PersistentTile):
61
62    def __call__(self):
63        relateditens = ''
64        if self.data['related_itens']:
65            relateditens = self.data['related_itens']
66        return '<html><body>%s</body></html>' % relateditens
67   
Note: Veja TracBrowser para ajuda no uso do navegador do trac.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.