source: publico/ILPortal/trunk/Extensions/AppInstall.py @ 772

Última Alteração nesse arquivo desde 772 foi 772, incluída por paulovieira, 14 anos atrás

adicionado templates do menu superior

File size: 9.2 KB
Linha 
1from Products.CMFCore.utils import getToolByName
2from StringIO import StringIO
3from Products.ILPortal.vocabularies import VOCABULARIOS_DINAMICOS
4from Products.ILPortal.utils import setVocabulariosDinamicos
5from Products.CMFPlone.migrations.migration_util import safeEditProperty
6from Acquisition import aq_base
7
8
9INDEX_HTML = '''<html metal:use-macro="here/main_template/macros/master">
10
11<div metal:fill-slot="portlets_one_slot">
12   <div metal:use-macro="here/portlet_chamadas/macros/portlet"></div>
13   <div metal:use-macro="here/portlet_events/macros/portlet"></div>
14</div>
15
16<div metal:fill-slot="main">
17   <div metal:use-macro="here/portlet_noticias/macros/portlet"></div>
18   <div metal:use-macro="here/portlet_ultimas_noticias/macros/portlet"></div>
19</div>
20
21<div metal:fill-slot="portlets_two_slot">
22   <div metal:use-macro="here/portlet_review/macros/portlet"></div>
23   <div metal:use-macro="here/global_personalbar/macros/portlet"></div>
24   <div metal:use-macro="here/portlet_produtos/macros/portlet"></div>
25   <div metal:use-macro="here/portlet_box_03/macros/portlet"></div>
26</div>
27
28</html>
29
30'''
31
32
33def install(self):
34    out = StringIO()
35    portal = getToolByName(self, 'portal_url').getPortalObject()
36
37    setupPortal(portal)
38    setupSlots(portal)
39    deleteAction(portal)
40    replaceIndex(portal)
41    deletePastas(portal)
42    setupPublicatorChamadas(portal)
43    setupPublicatorDestaques(portal)
44    setupPublicatorOpniao(portal)
45    setupPublicatorProdutos(portal)
46#   addNewsletters(portal)
47#   addForuns(portal)
48#   addEnquetes(portal)
49#   addImagens(portal)
50#   addChats(portal)
51    addJavaScript(portal)
52    addCSS(portal)
53#    setupActions(portal)
54    setupTipo(portal)
55
56
57    setVocabulariosDinamicos(self, VOCABULARIOS_DINAMICOS)
58    print >>out, 'Criados vocabularios no ATVocabularyManager'
59
60    setPloneProperties(self, portal, out)
61    return 'Feito!'
62
63
64def setupPortal(portal):
65    portal.manage_changeProperties(title='Portal Interlegis',
66                                   email_from_address='admin-stc@interlegis.gov.br',
67                                   email_from_name= 'Administrador')
68def setupSlots(portal):
69    left_slots =  ('here/portlet_navigation/macros/portlet', )
70    portal._setPropValue('left_slots', left_slots)
71
72    right_slots = ('here/portlet_review/macros/portlet', \
73                   'here/global_personalbar/macros/portlet', )
74    portal._setPropValue('right_slots', right_slots)
75
76def deleteAction(portal):
77    portal_actions = getToolByName(portal, 'portal_actions')
78    idx = 0
79    for action in portal_actions.listActions():
80        if action.getId() == 'index_html':
81            portal_actions.deleteActions((idx,))
82            break
83        idx += 1
84
85def replaceIndex(portal):
86     
87    if 'front-page' in portal.objectIds():
88       portal.manage_delObjects('front-page')
89    portal.manage_addProduct['PageTemplates'].manage_addPageTemplate('index_html', '', INDEX_HTML)
90
91def deletePastas(portal):
92    if 'news' in portal.objectIds():
93       portal.manage_delObjects('news')
94    if 'events' in portal.objectIds():
95       portal.manage_delObjects('events')
96
97def setupPublicatorChamadas(portal):
98    portal_publicator = getToolByName(portal, 'portal_publicator')
99    portal_publicator.addPublicationBox(id='box_01',
100                           name='Chamadas',
101                           content_type=['News Item','Document'],
102                           n_items=2,
103                           with_image=1,
104                           image_states=['published'],)
105
106def setupPublicatorDestaques(portal):
107    portal_publicator = getToolByName(portal, 'portal_publicator')
108    portal_publicator.addPublicationBox(id='box_02',
109                           name='Destaques',
110                           content_type=['News Item','Document'],
111                           n_items=5,
112                           with_image=0,
113                           image_states=['published'],)
114
115def setupPublicatorOpniao(portal):
116    portal_publicator = getToolByName(portal, 'portal_publicator')
117    portal_publicator.addPublicationBox(id='box_03',
118                           name='Opinião',
119                           content_type=['Document'],
120                           n_items=2,
121                           with_image=1,
122                           image_states=['published'],)
123
124def setupPublicatorProdutos(portal):
125    portal_publicator = getToolByName(portal, 'portal_publicator')
126    portal_publicator.addPublicationBox(id='box_04',
127                           name='Produtos',
128                           content_type=['File'],
129                           n_items=2,
130                           with_image=1,
131                           image_states=['published'],)
132
133
134def setPloneProperties(self, portal, out):
135    print >>out, 'Customizando o Plone para o ILPortal...'
136    portal_properties = getToolByName(portal, 'portal_properties')
137    site_properties = getattr(portal_properties, 'site_properties')
138    safeEditProperty(site_properties, 'localTimeFormat', '%d/%m/%Y', 'string')
139    safeEditProperty(site_properties, 'localLongTimeFormat', '%d/%m/%Y %H:%M', 'string')
140    safeEditProperty(site_properties, 'default_language', 'pt-br', 'string')
141    safeEditProperty(site_properties, 'calendar_starting_year', 1900, 'int')
142    portal_properties.site_properties.disable_folder_sections = (True)
143    portal_properties.navtree_properties.includeTop = (False)
144    portal_properties.navtree_properties.idsNotToList = ('Members',)
145    portal_properties.navtree_properties.enable_wf_state_filtering = (True)
146    portal_properties.navtree_properties.wf_states_to_show = ('published',)
147
148    print >>out, 'Plone para ILPortal customizado!\n'
149
150
151def addNewsletters(portal):
152    portal.invokeFactory('Folder', id='boletins', title='Boletins', excludeFromNav=0)
153
154    newsletters = getattr(aq_base(portal), 'boletins')
155    addable_types = ['Subscriber','NewsletterTheme']
156    if getattr(newsletters.aq_base, 'setConstrainTypesMode', None) is not None:
157        newsletters.setConstrainTypesMode(1)
158        newsletters.setImmediatelyAddableTypes(addable_types)
159        newsletters.setLocallyAllowedTypes(addable_types)
160
161def addForuns(portal):
162    portal.invokeFactory('Ploneboard', id='foruns', title='Fóruns')
163
164def addChats(portal):
165    portal.invokeFactory('Folder', id='chats', title='Chats', excludeFromNav=0)
166
167    chat = getattr(aq_base(portal), 'chats')
168    addable_types = ['PloneChat']
169    if getattr(chat.aq_base, 'setConstrainTypesMode', None) is not None:
170        chat.setConstrainTypesMode(1)
171        chat.setImmediatelyAddableTypes(addable_types)
172        chat.setLocallyAllowedTypes(addable_types)
173
174def addEnquetes(portal):
175    portal.invokeFactory('Folder', id='enquetes', title='Enquetes', excludeFromNav=0)
176
177    enquete = getattr(aq_base(portal), 'enquetes')
178    addable_types = ['PlonePopoll']
179    if getattr(enquete.aq_base, 'setConstrainTypesMode', None) is not None:
180        enquete.setConstrainTypesMode(1)
181        enquete.setImmediatelyAddableTypes(addable_types)
182        enquete.setLocallyAllowedTypes(addable_types)
183
184def addImagens(portal):
185    portal.invokeFactory('Folder', id='imagens', title='Imagens', excludeFromNav=0)
186
187    imagem = getattr(aq_base(portal), 'imagens')
188    addable_types = ['Image','Folder']
189    if getattr(imagem.aq_base, 'setConstrainTypesMode', None) is not None:
190        imagem.setConstrainTypesMode(1)
191        imagem.setImmediatelyAddableTypes(addable_types)
192        imagem.setLocallyAllowedTypes(addable_types)
193
194def setupActions(portal):
195    portal_actions = getToolByName(portal, 'portal_actions')
196    portal_actions.addAction(id='boletins', name='Boletins', action='string:${portal_url}/boletins', condition='', permission='View', category='portal_tabs', visible=1)
197    portal_actions.addAction(id='chats', name='Chats', action='string:${portal_url}/chats', condition='', permission='View', category='portal_tabs', visible=1)
198    portal_actions.addAction(id='foruns', name='Fóruns', action='string:${portal_url}/foruns', condition='', permission='View', category='portal_tabs', visible=1)
199
200
201def setupTipo(portal):
202    portal_types = getToolByName(portal, 'portal_types')
203    portal_types['Plone Site'].global_allow = False
204    addable_types=['Folder']
205    portal_types['Plone Site'].filter_content_types = True
206    portal_types['Plone Site'].allowed_content_types = addable_types
207
208
209def addJavaScript(portal):
210    portal.portal_javascripts.manage_addScript(id='menu_superior.js',
211                                               expression='',
212                                               inline=False,
213                                               enabled=True,
214                                               cookable=True,
215                                               REQUEST=None,)
216
217
218def addCSS(portal):
219    portal.portal_css.manage_addStylesheet(id='menu_superior.css',
220                                               expression='',
221                                               media='screen',
222                                               rel='sylesheet',
223                                               title='',
224                                               rendering='import',
225                                               enabled=True,
226                                               cookable=True,
227                                               REQUEST=None,)
228
229def uninstall(self):
230    pass
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.