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

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

alteração na instalação do Produto

File size: 9.5 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    if 'boletins' not in portal.objectIds():
153        portal.invokeFactory('Folder', id='boletins', title='Boletins', excludeFromNav=0)
154
155        newsletters = getattr(aq_base(portal), 'boletins')
156        addable_types = ['Subscriber','NewsletterTheme']
157        if getattr(newsletters.aq_base, 'setConstrainTypesMode', None) is not None:
158            newsletters.setConstrainTypesMode(1)
159            newsletters.setImmediatelyAddableTypes(addable_types)
160            newsletters.setLocallyAllowedTypes(addable_types)
161
162def addForuns(portal):
163    if 'foruns' not in portal.objectIds():
164        portal.invokeFactory('Ploneboard', id='foruns', title='Fóruns')
165
166def addChats(portal):
167    if 'chats' not in portal.objectIds():
168        portal.invokeFactory('Folder', id='chats', title='Chats', excludeFromNav=0)
169
170        chat = getattr(aq_base(portal), 'chats')
171        addable_types = ['PloneChat']
172        if getattr(chat.aq_base, 'setConstrainTypesMode', None) is not None:
173            chat.setConstrainTypesMode(1)
174            chat.setImmediatelyAddableTypes(addable_types)
175            chat.setLocallyAllowedTypes(addable_types)
176
177def addEnquetes(portal):
178    if 'enquetes' not in portal.objectIds():
179        portal.invokeFactory('Folder', id='enquetes', title='Enquetes', excludeFromNav=0)
180
181        enquete = getattr(aq_base(portal), 'enquetes')
182        addable_types = ['PlonePopoll']
183        if getattr(enquete.aq_base, 'setConstrainTypesMode', None) is not None:
184            enquete.setConstrainTypesMode(1)
185            enquete.setImmediatelyAddableTypes(addable_types)
186            enquete.setLocallyAllowedTypes(addable_types)
187
188def addImagens(portal):
189    if 'imagens' not in portal.objectIds():
190        portal.invokeFactory('Folder', id='imagens', title='Imagens', excludeFromNav=0)
191
192        imagem = getattr(aq_base(portal), 'imagens')
193        addable_types = ['Image','Folder']
194        if getattr(imagem.aq_base, 'setConstrainTypesMode', None) is not None:
195            imagem.setConstrainTypesMode(1)
196            imagem.setImmediatelyAddableTypes(addable_types)
197            imagem.setLocallyAllowedTypes(addable_types)
198
199def setupActions(portal):
200    portal_actions = getToolByName(portal, 'portal_actions')
201    portal_actions.addAction(id='boletins', name='Boletins', action='string:${portal_url}/boletins', condition='', permission='View', category='portal_tabs', visible=1)
202    portal_actions.addAction(id='chats', name='Chats', action='string:${portal_url}/chats', condition='', permission='View', category='portal_tabs', visible=1)
203    portal_actions.addAction(id='foruns', name='Fóruns', action='string:${portal_url}/foruns', condition='', permission='View', category='portal_tabs', visible=1)
204
205
206def setupTipo(portal):
207    portal_types = getToolByName(portal, 'portal_types')
208    portal_types['Plone Site'].global_allow = False
209    addable_types=['Folder']
210    portal_types['Plone Site'].filter_content_types = True
211    portal_types['Plone Site'].allowed_content_types = addable_types
212
213
214def addJavaScript(portal):
215    portal.portal_javascripts.manage_addScript(id='menu_superior.js',
216                                               expression='',
217                                               inline=False,
218                                               enabled=True,
219                                               cookable=True,
220                                               REQUEST=None,)
221
222
223def addCSS(portal):
224    portal.portal_css.manage_addStylesheet(id='menu_superior.css',
225                                               expression='',
226                                               media='screen',
227                                               rel='sylesheet',
228                                               title='',
229                                               rendering='import',
230                                               enabled=True,
231                                               cookable=True,
232                                               REQUEST=None,)
233
234def uninstall(self):
235    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.