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

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

Corrige erro de exibicao das anotacoes do tile (tile.plaintext ainda gera AttributeError?)

File size: 2.8 KB
Linha 
1# -*- coding: utf-8 -*-
2from zope.interface import Interface
3from zope.schema import Text, Choice, List
4from z3c.form import form, field
5
6from plone.z3cform import layout
7from plone import tiles
8
9#from z3c.relationfield.schema import RelationChoice
10#from z3c.relationfield.schema import RelationList
11
12from plone.app.textfield import RichText
13from plone.app.textfield.interfaces import ITransformer
14
15#from plone.formwidget.autocomplete.widget import AutocompleteMultiFieldWidget
16from plone.formwidget.contenttree import ContentTreeFieldWidget
17from plone.formwidget.contenttree import MultiContentTreeFieldWidget
18from plone.formwidget.contenttree import PathSourceBinder
19#from plone.formwidget.contenttree import ObjPathSourceBinder
20
21
22class IRichTextTileData(Interface):
23
24    text = RichText(title=u'Text')
25
26
27class RichTextTile(tiles.PersistentTile):
28
29    def __call__(self):
30        text = ''
31        if self.data['text']:
32            transformer = ITransformer(self.context, None)
33            if transformer is not None:
34                text = transformer(self.data['text'], 'text/x-html-safe')
35        return '<html><body>%s</body></html>' % text
36
37
38class IPlainTextTileData(Interface):
39
40    text = Text(title=u"Text")
41
42
43class PlainTextTile(tiles.PersistentTile):
44
45    def __call__(self):
46        text = ''
47        if self.data['text']:
48            text = self.data['text']
49        return '<html><body>%s</body></html>' % text
50
51
52class IRelatedItemsTileData(Interface):
53
54    """
55    related_item = RelationChoice(title=u"Item relacionado",
56                       required=False,
57                       source=ObjPathSourceBinder())
58    """
59    related_item = Choice(title=u"Item relacionado",
60                          description=u"Selecione somente um item, por favor",
61                          required=False,
62                          source=PathSourceBinder())
63
64    related_items = List(title=u"Múltiplos ítens",
65                         description=u"Selecione quantos ítens quiser",
66                         value_type=Choice(title=u"Selection",
67                                           source=PathSourceBinder()))
68    #import pdb;pdb.set_trace()
69
70
71class RelatedForm(form.EditForm):
72    fields = field.Fields(IRelatedItemsTileData)
73    fields['related_item'].widgetFactory = ContentTreeFieldWidget
74    fields['related_items'].widgetFactory = MultiContentTreeFieldWidget
75    mode = 'display'
76
77RelatedView = layout.wrap_form(RelatedForm)
78
79
80class RelatedItemsTile(tiles.PersistentTile):
81
82    def __call__(self):
83        related_item = related_items = ''
84        if self.data['related_item']:
85            related_item = self.data['related_item']
86        if self.data['related_items']:
87            related_items = self.data['related_items']
88        return '<html><body>%s | %s</body></html>' % (related_item, related_items)
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.