source: publico/ILPortalCasas/trunk/Extensions/AppInstall.py @ 1481

Última Alteração nesse arquivo desde 1481 foi 1481, incluída por rafahelabazzanella, 13 anos atrás

Criado aconfig_install para as configurcoes da instalacao

File size: 35.4 KB
Linha 
1from Products.CMFCore.utils import getToolByName
2from Products.CMFPlone.utils import _createObjectByType
3from Products.ExternalMethod.ExternalMethod import manage_addExternalMethod
4from Products.ILPortalCasas.config import *
5from Products.ILPortalCasas.config_install import *
6from Acquisition import aq_base
7import sys, os
8
9def install(self):
10    portal = self
11    setupControlPanel(portal)
12    setupWorkflow(portal)
13    replaceIndex(portal)
14    deletePastas(portal)
15    addHistoria(portal)
16    addCamara(portal)
17    addAgenda(portal)
18    addProcessos(portal)
19    addLeis(portal)
20    addLicitacoes(portal)
21    addContabilidade(portal)
22    addUtilidades(portal)
23    addImagens(portal)
24    addEnquetes(portal)
25    addNewsletters(portal)
26    addForuns(portal)
27    addNoticia(portal)
28    addEvento(portal)
29    addOuvidoria(portal)
30    addSaap(portal)
31    addSaal(portal)
32    setupPortal(portal)
33    setupSlots(portal)
34    deleteAction(portal)
35    deleteAction2(portal)
36    deleteAction3(portal)
37    deleteAction4(portal)
38    deleteCategoria(portal)
39    setupActions(portal)
40    setupCssmanager(portal)
41    setupGroups(portal)
42    setupScriptsBackup(portal)
43    setupMemberdata(portal)
44    setupMetadata(portal)
45    setupPortalCss(portal)
46    setupProperties(portal)
47    setupPublicatorUtilidades(portal)
48    setupPublicatorDestaque(portal)
49    setupPublicatorNoticia(portal)
50    setupPublicatorBanner(portal)
51    setupSin(portal)
52    setupSkin(portal)
53    setupWebmail(portal)
54    setupTipo(portal)
55    addBackup(portal)
56    addScheduler(portal)
57
58def setupControlPanel(portal):
59    portal_controlpanel = getToolByName(portal,'portal_controlpanel')
60    portal_controlpanel.registerConfiglet(
61        'ajuda_portal_casas', #id of your Tool
62        'Ajuda Configuração ILPortalCasas', # Title of your Troduct
63        'string:${portal_url}/ajuda_portal_casas/ajuda',
64        'python:True', # a condition
65        'Manage Portal', # access permission
66        'Plone', # section to which the configlet should be added: (Plone,Products,Members)
67        1, # visibility
68        'ILPortalCasas',
69        'info_icon.gif', # icon in control_panel
70        'Ajuda para configuração do ILPortalCasas',
71        None,
72    )
73
74def setupWorkflow(portal):
75    portal_workflow = getToolByName(portal, 'portal_workflow')
76    portal_workflow.setDefaultChain('portal_modelo_workflow')
77    portal_workflow.setChainForPortalTypes( ['CalendarX', 'ATAudio', 'Recordings', 'ATPhoto', 'ATVideo', 'ATAudioFolder', 'ATPhotoAlbum'], "plone_workflow")
78
79def replaceIndex(portal):
80    front_page = getattr(portal, 'front-page', None)
81    if front_page is not None:
82        portal._delObject('front-page')
83        portal.manage_addProduct['PageTemplates'].manage_addPageTemplate('index_html', '', INDEX_HTML)
84    else:
85        pass
86
87def deletePastas(portal):
88    news = getattr(portal, 'news', None)
89    if news is not None:
90        portal.manage_delObjects('news')
91    events = getattr(portal, 'events', None)
92    if events is not None:
93        portal.manage_delObjects('events')
94
95def addHistoria(portal):
96    historia = getattr(portal, 'historia', None)
97    if historia is None:
98        portal.invokeFactory('Folder', id='historia', title='História')
99        hist = getattr(aq_base(portal), 'historia')
100        addable_types = ['Folder','File','Link','Document','DisplayPage', 'ATPhoto', 'ATPhotoAlbum']
101        if getattr(hist.aq_base, 'setConstrainTypesMode', None) is not None:
102            hist.setConstrainTypesMode(1)
103            hist.setImmediatelyAddableTypes(addable_types)
104            hist.setLocallyAllowedTypes(addable_types)
105
106        portal_workflow = getToolByName(portal, 'portal_workflow')
107        historia = getattr(portal, 'historia', None)
108        if historia is not None:
109            portal_workflow.doActionFor(historia, 'publish')
110        historia.invokeFactory('Folder', id='historia-camara', title='História da Câmara')
111        historia_camara = getattr(historia, 'historia-camara', None)
112        if historia_camara is not None:
113            portal_workflow.doActionFor(historia_camara, 'publish')
114        historia.invokeFactory('Folder', id='historia-cidade', title='História da Cidade')
115        historia_cidade = getattr(historia, 'historia-cidade', None)
116        if historia_cidade is not None:
117            portal_workflow.doActionFor(historia_cidade, 'publish')
118
119def addCamara(portal):
120    camara = getattr(portal, 'camara', None)
121    if camara is None:
122        portal.invokeFactory('Folder', id='camara', title='A Câmara')
123        cam = getattr(aq_base(portal), 'camara')
124        addable_types = ['Folder','File','Link','Document','DisplayPage', 'ATVideo', 'ATAudio', 'ATAudioFolder', 'Recordings', 'ATPhoto', 'ATPhotoAlbum']
125        if getattr(cam.aq_base, 'setConstrainTypesMode', None) is not None:
126            cam.setConstrainTypesMode(1)
127            cam.setImmediatelyAddableTypes(addable_types)
128            cam.setLocallyAllowedTypes(addable_types)
129
130        portal_workflow = getToolByName(portal, 'portal_workflow')
131        camara = getattr(portal, 'camara', None)
132        if camara is not None:
133            portal_workflow.doActionFor(camara, 'publish')
134            camara.invokeFactory('Folder', id='funcao', title='Função e Definição')
135            funcao = getattr(camara, 'funcao', None)
136            if funcao is not None:
137                portal_workflow.doActionFor(funcao, 'publish')
138            camara.invokeFactory('Folder', id='departamentos', title='Departamentos')
139            departamentos = getattr(camara, 'departamentos', None)
140            if departamentos is not None:
141                portal_workflow.doActionFor(departamentos, 'publish')
142            camara.invokeFactory('Folder', id='vereadores', title='Vereadores')
143            vereadores = getattr(camara, 'vereadores', None)
144            if vereadores is not None:
145                portal_workflow.doActionFor(vereadores, 'publish')
146            vereadores.invokeFactory('Folder', id='em-servico', title='Em Servico')
147            informacoes = getattr(vereadores, 'em-servico', None)
148            if informacoes is not None:
149                portal_workflow.doActionFor(informacoes, 'publish')
150            vereadores.invokeFactory('Folder', id='ex-vereadores', title='Ex-Vereadores')
151            ex_vereadores = getattr(vereadores, 'ex-vereadores', None)
152            if ex_vereadores is not None:
153                portal_workflow.doActionFor(ex_vereadores, 'publish')
154            vereadores.invokeFactory('Folder', id='discursos', title='Discursos')
155            discursos = getattr(vereadores, 'discursos', None)
156            if discursos is not None:
157                portal_workflow.doActionFor(discursos, 'publish')
158            vereadores.invokeFactory('Folder', id='fale-vereador', title='Fale com o Vereador')
159            fale_vereador = getattr(vereadores, 'fale-vereador', None)
160            if fale_vereador is not None:
161                portal_workflow.doActionFor(fale_vereador, 'publish')
162            camara.invokeFactory('Folder', id='comissoes', title='Comissões')
163            comissoes = getattr(camara, 'comissoes', None)
164            if comissoes is not None:
165                portal_workflow.doActionFor(comissoes, 'publish')
166            camara.invokeFactory('Folder', id='mesa-diretora', title='Mesa Diretora')
167            mesa_diretora = getattr(camara, 'mesa-diretora', None)
168            if mesa_diretora is not None:
169                portal_workflow.doActionFor(mesa_diretora, 'publish')
170
171def addAgenda(portal):
172    agenda = getattr(portal, 'agenda', None)
173    if agenda is None:
174        portal.invokeFactory('CalendarX', id='agenda', title='Agenda')
175        agenda = getattr(portal, 'agenda', None)
176        agenda.manage_addProperty('right_slots', [''], 'lines')
177
178def addProcessos(portal):
179    processos = getattr(portal, 'processos-legislativos', None)
180    if processos is None:
181        portal.invokeFactory('Folder', id='processos-legislativos', title='Processos Legislativos')
182        proc = getattr(aq_base(portal), 'processos-legislativos')
183        addable_types = ['Folder','File','Link','Document','DisplayPage', 'ATVideo', 'ATAudio', 'ATAudioFolder', 'Recordings']
184        if getattr(proc.aq_base, 'setConstrainTypesMode', None) is not None:
185            proc.setConstrainTypesMode(1)
186            proc.setImmediatelyAddableTypes(addable_types)
187            proc.setLocallyAllowedTypes(addable_types)
188
189        portal_workflow = getToolByName(portal, 'portal_workflow')
190        processos = getattr(portal, 'processos-legislativos', None)
191        if processos is not None:
192            portal_workflow.doActionFor(processos, 'publish')
193        processos.invokeFactory('Folder', id='ordem-dia', title='Ordem do Dia')
194        ordem = getattr(processos, 'ordem-dia', None)
195        if ordem is not None:
196            portal_workflow.doActionFor(ordem, 'publish')
197        processos.invokeFactory('Folder', id='sessoes', title='Sessões')
198        sessoes = getattr(processos, 'sessoes', None)
199        if sessoes is not None:
200            portal_workflow.doActionFor(sessoes, 'publish')
201        sessoes.invokeFactory('Folder', id='sessoes-online', title='Sessões On-line')
202        sessoes_online = getattr(sessoes, 'sessoes-online', None)
203        if sessoes_online is not None:
204            portal_workflow.doActionFor(sessoes_online, 'publish')
205        processos.invokeFactory('Folder', id='atas', title='Atas')
206        atas = getattr(processos, 'atas', None)
207        if atas is not None:
208            portal_workflow.doActionFor(atas, 'publish')
209
210def addLeis(portal):
211    leis = getattr(portal, 'leis', None)
212    if leis is None:
213        portal.invokeFactory('Folder', id='leis', title='Leis')
214        lei = getattr(aq_base(portal), 'leis')
215        addable_types = ['Folder','File','Link','Document','DisplayPage']
216        if getattr(lei.aq_base, 'setConstrainTypesMode', None) is not None:
217            lei.setConstrainTypesMode(1)
218            lei.setImmediatelyAddableTypes(addable_types)
219            lei.setLocallyAllowedTypes(addable_types)
220
221        portal_workflow = getToolByName(portal, 'portal_workflow')
222        leis = getattr(portal, 'leis', None)
223        if leis is not None:
224            portal_workflow.doActionFor(leis, 'publish')
225        leis.invokeFactory('Folder', id='legislacao-municipal', title='Legislação Municipal')
226        legislacao_municipal = getattr(leis, 'legislacao-municipal', None)
227        if legislacao_municipal is not None:
228            portal_workflow.doActionFor(legislacao_municipal, 'publish')
229        leis.invokeFactory('Folder', id='leis-federais', title='Leis Federais')
230        leis_federais = getattr(leis, 'leis-federais', None)
231        if leis_federais is not None:
232            portal_workflow.doActionFor(leis_federais, 'publish')
233        leis.invokeFactory('Folder', id='leis-estaduais', title='Leis Estaduais')
234        leis_estaduais = getattr(leis, 'leis-estaduais', None)
235        if leis_estaduais is not None:
236            portal_workflow.doActionFor(leis_estaduais, 'publish')
237        leis.invokeFactory('Folder', id='projetos-lei', title='Projetos de Lei')
238        projetos_lei = getattr(leis, 'projetos-lei', None)
239        if projetos_lei is not None:
240            portal_workflow.doActionFor(projetos_lei, 'publish')
241        projetos = getattr(leis, 'projetos-lei', None)
242        projetos.invokeFactory('Folder', id='estatisticas-proposicoes', title='Estatísticas de Proposições')
243        estatisticas_proposicoes = getattr(projetos, 'estatisticas-proposicoes', None)
244        if estatisticas_proposicoes is not None:
245            portal_workflow.doActionFor(estatisticas_proposicoes, 'publish')
246        leis.invokeFactory('Folder', id='legislacao', title='Legislação')
247        legislacao = getattr(leis, 'legislacao', None)
248        if legislacao is not None:
249            portal_workflow.doActionFor(legislacao, 'publish')
250
251def addLicitacoes(portal):
252    licitacoes = getattr(portal, 'licitacoes', None)
253    if licitacoes is None:
254        portal.invokeFactory('Folder', id='licitacoes', title='Licitações')
255        lic = getattr(aq_base(portal), 'licitacoes')
256        addable_types = ['Folder','File','Link','Document','DisplayPage']
257        if getattr(lic.aq_base, 'setConstrainTypesMode', None) is not None:
258            lic.setConstrainTypesMode(1)
259            lic.setImmediatelyAddableTypes(addable_types)
260            lic.setLocallyAllowedTypes(addable_types)
261
262        portal_workflow = getToolByName(portal, 'portal_workflow')
263        licitacoes = getattr(portal, 'licitacoes', None)
264        if licitacoes is not None:
265            portal_workflow.doActionFor(licitacoes, 'publish')
266        licitacoes.invokeFactory('Folder', id='editais', title='Editais')
267        editais = getattr(licitacoes, 'editais', None)
268        if editais is not None:
269            portal_workflow.doActionFor(editais, 'publish')
270        licitacoes.invokeFactory('Folder', id='concursos', title='Concursos')
271        concursos = getattr(licitacoes, 'concursos', None)
272        if concursos is not None:
273            portal_workflow.doActionFor(concursos, 'publish')
274        licitacoes.invokeFactory('Folder', id='pregao', title='Pregão')
275        pregao = getattr(licitacoes, 'pregao', None)
276        if pregao is not None:
277            portal_workflow.doActionFor(pregao, 'publish')
278        licitacoes.invokeFactory('Folder', id='tomada-preco', title='Tomada de Preço')
279        tomada_preco = getattr(licitacoes, 'tomada-preco', None)
280        if tomada_preco is not None:
281            portal_workflow.doActionFor(tomada_preco, 'publish')
282        licitacoes.invokeFactory('Folder', id='convite', title='Convite')
283        convite = getattr(licitacoes, 'convite', None)
284        if convite is not None:
285            portal_workflow.doActionFor(convite, 'publish')
286
287def addContabilidade(portal):
288    contabilidade = getattr(portal, 'contabilidade', None)
289    if contabilidade is None:
290        portal.invokeFactory('Folder', id='contabilidade', title='Contabilidade')
291        cont = getattr(aq_base(portal), 'contabilidade')
292        addable_types = ['Folder','File','Link','Document','DisplayPage']
293        if getattr(cont.aq_base, 'setConstrainTypesMode', None) is not None:
294            cont.setConstrainTypesMode(1)
295            cont.setImmediatelyAddableTypes(addable_types)
296            cont.setLocallyAllowedTypes(addable_types)
297
298        portal_workflow = getToolByName(portal, 'portal_workflow')
299        contabilidade = getattr(portal, 'contabilidade', None)
300        if contabilidade is not None:
301            portal_workflow.doActionFor(contabilidade, 'publish')
302
303def addUtilidades(portal):
304    link = getattr(portal, 'utilidades', None)
305    if link is None:
306        portal.invokeFactory('Folder', id='utilidades', title='Utilidades', excludeFromNav=1)
307        utd = getattr(aq_base(portal), 'utilidades')
308        addable_types = ['Folder', 'Link',]
309        if getattr(utd.aq_base, 'setConstrainTypesMode', None) is not None:
310            utd.setConstrainTypesMode(1)
311            utd.setImmediatelyAddableTypes(addable_types)
312            utd.setLocallyAllowedTypes(addable_types)
313
314        link = getattr(portal, 'utilidades', None)
315        link.invokeFactory('Link', id='link-interlegis', title='Programa Interlegis', remoteUrl='http://www.interlegis.gov.br')
316        link.invokeFactory('Link', id='link-senado', title='Senado Federal', remoteUrl='http://www.senado.gov.br')
317        link.invokeFactory('Link', id='link-camara', title='Câmara dos Deputados', remoteUrl='http://www.camara.gov.br')
318   
319        portal_workflow = getToolByName(portal, 'portal_workflow')
320        interlegis = getattr(link, 'link-interlegis', None)
321        if interlegis is not None:
322            portal_workflow.doActionFor(interlegis, 'publish')
323        senado = getattr(link, 'link-senado', None)
324        if senado is not None:
325            portal_workflow.doActionFor(senado, 'publish')
326        camara = getattr(link, 'link-camara', None)
327        if camara is not None:
328            portal_workflow.doActionFor(camara, 'publish')
329
330def addImagens(portal):
331    imagens = getattr(portal, 'imagens', None)
332    if imagens is None:
333        portal.invokeFactory('Folder', id='imagens', title='Imagens', excludeFromNav=1)
334        portal_workflow = getToolByName(portal, 'portal_workflow')
335        imagem = getattr(aq_base(portal), 'imagens')
336        addable_types = ['Image','Folder','Link']
337        if getattr(imagem.aq_base, 'setConstrainTypesMode', None) is not None:
338            imagem.setConstrainTypesMode(1)
339            imagem.setImmediatelyAddableTypes(addable_types)
340            imagem.setLocallyAllowedTypes(addable_types)
341
342        imagens = getattr(portal, 'imagens', None)
343        imagens.invokeFactory('Folder', id='inoticias', title='Notícias')
344        imagens.invokeFactory('Folder', id='banners', title='Banners')
345        imgban = getattr(imagens, 'banners', None)
346
347        imgban.invokeFactory('Image', id='banner_interlegis.jpg', title='Banner Interlegis')
348        newImage = getattr(imgban, 'banner_interlegis.jpg')
349        newImage.edit(file=file(INSTANCE_HOME+'/Products/ILPortalCasas/Extensions/banner_interlegis.jpg').read())
350        if newImage is not None:
351            portal_workflow.doActionFor(newImage, 'publish')
352
353        imgban.invokeFactory('Image', id='banner_senado.jpg', title='Banner Senado')
354        newImage = getattr(imgban, 'banner_senado.jpg')
355        newImage.edit(file=file(INSTANCE_HOME+'/Products/ILPortalCasas/Extensions/banner_senado.jpg').read())
356        if newImage is not None:
357            portal_workflow.doActionFor(newImage, 'publish')
358
359        imgban.invokeFactory('Image', id='banner_camara.jpg', title='Banner Câmara')
360        newImage = getattr(imgban, 'banner_camara.jpg')
361        newImage.edit(file=file(INSTANCE_HOME+'/Products/ILPortalCasas/Extensions/banner_camara.jpg').read())
362        if newImage is not None:
363            portal_workflow.doActionFor(newImage, 'publish')
364   
365def addEnquetes(portal):
366    enquetes = getattr(portal, 'enquetes', None)
367    if enquetes is None:
368        portal.invokeFactory('Folder', id='enquetes', title='Enquetes', excludeFromNav=1)
369        enquete = getattr(aq_base(portal), 'enquetes')
370        addable_types = ['PlonePopoll']
371        if getattr(enquete.aq_base, 'setConstrainTypesMode', None) is not None:
372            enquete.setConstrainTypesMode(1)
373            enquete.setImmediatelyAddableTypes(addable_types)
374            enquete.setLocallyAllowedTypes(addable_types)
375
376def addNewsletters(portal):
377    newsletters = getattr(portal, 'newsletters', None)
378    if newsletters is None:
379        portal.invokeFactory('Folder', id='newsletters', title='Newsletters', excludeFromNav=1)
380        newsletters = getattr(aq_base(portal), 'newsletters')
381        addable_types = ['Subscriber','NewsletterTheme']
382        if getattr(newsletters.aq_base, 'setConstrainTypesMode', None) is not None:
383            newsletters.setConstrainTypesMode(1)
384            newsletters.setImmediatelyAddableTypes(addable_types)
385            newsletters.setLocallyAllowedTypes(addable_types)
386
387def addForuns(portal):
388    foruns = getattr(portal, 'foruns', None)
389    if foruns is None:
390        portal.invokeFactory('Ploneboard', id='foruns', title='Fóruns')
391        portal_workflow = getToolByName(portal, 'portal_workflow')
392        foruns = getattr(portal, 'foruns', None)
393        if foruns is not None:
394            portal_workflow.doActionFor(foruns, 'publish')
395
396def addNoticia(portal):
397    if 'noticias' not in portal.objectIds():
398        _createObjectByType('Large Plone Folder', portal, id='noticias',
399                            title='Notícias', description='Notícias', excludeFromNav=1)
400    news = getattr(aq_base(portal), 'noticias')
401
402    addable_types = ['News Item']
403    if getattr(news.aq_base, 'setConstrainTypesMode', None) is not None:
404        news.setConstrainTypesMode(1)
405        news.setImmediatelyAddableTypes(addable_types)
406        news.setLocallyAllowedTypes(addable_types)
407
408def addEvento(portal):
409    if 'eventos' not in portal.objectIds():
410        _createObjectByType('Large Plone Folder', portal, id='eventos',
411                            title='Eventos', description='Eventos', excludeFromNav=1)
412    events = getattr(aq_base(portal), 'eventos')
413
414    addable_types = ['Event']
415    if getattr(events.aq_base, 'setConstrainTypesMode', None) is not None:
416        events.setConstrainTypesMode(1)
417        events.setImmediatelyAddableTypes(addable_types)
418        events.setLocallyAllowedTypes(addable_types)
419
420def addOuvidoria(portal):
421    portal.invokeFactory('OmbudsmanFolder', id='ouvidoria', title='Ouvidoria')
422
423def addSaap(portal):
424    saap = getattr(portal, 'saap', None)
425    if saap is None:
426        portal.invokeFactory('Folder', id='saap', title='SAAP', excludeFromNav=1)
427        saap = getattr(portal, 'saap', None)
428        saap.invokeFactory('DisplayPage', id='index_html', remote_url='http://saapdemo.interlegis.gov.br/saap/index_saap_html')
429       # saap._setProperty('remote_url','http://saapdemo.interlegis.gov.br/saap/index_saap_html')
430   
431def addSaal(portal):
432    saal = getattr(portal, 'saal', None)
433    if saal is None:
434        portal.invokeFactory('Folder', id='saal', title='SAAL', excludeFromNav=1)
435
436def setupPortal(portal):
437    portal.manage_changeProperties(title='Portal das Casas Legislativas',
438                                   email_from_address='admin-stc@interlegis.gov.br',
439                                   email_from_name= 'Administrador')
440
441def setupSlots(portal):
442    left_slots =  ('here/portlet_navigation/macros/portlet', \
443                   'here/portlet_preferencias/macros/portlet', \
444                   'here/portlet_gazette/macros/portlet', \
445                   'here/sin_tool/macros/Zope-PT', \
446                   'here/portlet_recent/macros/portlet',)
447    portal._setPropValue('left_slots', left_slots)
448    right_slots = ('here/portlet_calendar/macros/portlet', \
449                   'here/popoll_slot2/macros/popollBox', \
450                   'here/portlet_review/macros/portlet',
451                   'here/portlet_utilidades/macros/portlet',)
452                  # 'here/portlet_previsao/macros/portlet',)
453    portal._setPropValue('right_slots', right_slots)
454
455def deleteAction(portal):
456    portal_actions = getToolByName(portal, 'portal_actions')
457    idx = 0
458    for action in portal_actions.listActions():
459        if action.getId() == 'index_html':
460            portal_actions.deleteActions((idx,))
461            break
462        idx += 1
463
464def deleteAction2(portal):
465    portal_actions = getToolByName(portal, 'portal_actions')
466    idx = 0
467    for action in portal_actions.listActions():
468        if action.getId() == 'sitemap':
469            portal_actions.deleteActions((idx,))
470            break
471        idx += 1
472
473def deleteAction3(portal):
474    portal_actions = getToolByName(portal, 'portal_actions')
475    idx = 0
476    for action in portal_actions.listActions():
477        if action.getId() == 'contact':
478            portal_actions.deleteActions((idx,))
479            break
480        idx += 1
481
482def deleteAction4(portal):
483    portal_actions = getToolByName(portal, 'portal_actions')
484    idx = 0
485    for action in portal_actions.listActions():
486        if action.getId() == 'plone_setup':
487            portal_actions.deleteActions((idx,))
488            break
489        idx += 1
490
491def deleteCategoria(portal):
492    portal_actions = getToolByName(portal, 'portal_actions')
493    idx = 0
494    for actions in portal_actions.listActions():
495        if actions.getCategory() == 'site_actions':
496            portal_actions.deleteActions((idx,))
497            break
498        idx += 1
499
500def setupActions(portal):
501    portal_actions = getToolByName(portal, 'portal_actions')
502    portal_actions.addAction(id='index_html', name='Página Inicial', action='string:$portal_url', condition='', permission='View', category='portal_tabs', visible=1)
503
504    portal_actions.addAction(id='ouvidoria', name='Ouvidoria', action='string:${portal_url}/ouvidoria', condition='', permission='View', category='portal_tabs', visible=1)
505
506    portal_actions.addAction(id='saap', name='SAAP', action='string: ${portal_url}/saap', condition='member', permission='View', category='portal_tabs', visible=1)
507
508    portal_actions.addAction(id='saal', name='SAAL', action='string: ${portal_url}/saal', condition='member', permission='View', category='portal_tabs', visible=1)
509 
510    portal_actions.addAction(id='contact', name='Fale com a Câmara', action='string: ${portal_url}/contact-info', condition='', permission='View', category='portal_tabs', visible=1)
511
512    portal_actions.addAction(id='sitemap', name='Site Map', action='string: ${portal_url}/sitemap', condition='', permission='View', category='portal_tabs', visible=1)
513
514    portal_actions.addAction(id='login_form', name='Acessar', action='string: ${portal_url}/login_form', condition='python:here.portal_membership.isAnonymousUser()', permission='View', category='portal_tabs', visible=1)
515
516def setupCssmanager(portal):
517    cssmanager = getToolByName(portal, 'portal_cssmanager')
518    cssmanager.manage_addToMapping('base_properties','Plone Css')
519
520def setupGroups(portal):
521    portal_groups = getToolByName(portal, 'portal_groups')
522    portal_groups.toggleGroupWorkspacesCreation()
523
524def setupScriptsBackup(portal):
525    scripts_backup = getattr(portal, 'scripts_backup', None)
526    if scripts_backup is None:
527        portal.manage_addProduct['OFSP'].manage_addFolder('scripts_backup')
528        scripts_backup = getattr(portal, 'scripts_backup', None)
529        scripts_backup.manage_addProduct['ExternalMethod'].manage_addExternalMethod('backupFile','Backup zope.conf e products', PROJECTNAME+'.BackupPortalModelo', 'backupFile')
530        scripts_backup.manage_addProduct['ExternalMethod'].manage_addExternalMethod('packDB','Pack Data.fs', PROJECTNAME+'.BackupPortalModelo', 'packDB')
531        scripts_backup.manage_addProduct['ExternalMethod'].manage_addExternalMethod('moveBackup','Move Data.fs para iretorio backup', PROJECTNAME+'.BackupPortalModelo', 'moveBackup')
532
533def setupMemberdata(portal):
534    portal_memberdata = getToolByName(portal, 'portal_memberdata')
535    portal_memberdata.listed = (False)
536    if not portal_memberdata.hasProperty('sexo'):
537        portal_memberdata._setProperty('sexo', '', 'string')
538    if not portal_memberdata.hasProperty('idade'):
539        portal_memberdata._setProperty('idade', '', 'string')
540    if not portal_memberdata.hasProperty('endereco'):
541        portal_memberdata._setProperty('endereco', '', 'string')
542    if not portal_memberdata.hasProperty('bairro'):
543        portal_memberdata._setProperty('bairro', '', 'string')
544    if not portal_memberdata.hasProperty('cidade'):
545        portal_memberdata._setProperty('cidade', '', 'string')
546    if not portal_memberdata.hasProperty('estado'):
547        portal_memberdata._setProperty('estado', '', 'string')
548    if not portal_memberdata.hasProperty('fone_res'):
549        portal_memberdata._setProperty('fone_res', '', 'string')
550
551def setupMetadata(portal):
552    portal_metadata = getToolByName(portal, 'portal_metadata')
553    portal_metadata.updateElementPolicy(
554            element='Subject',
555            content_type='Event',
556            is_required=0,
557            supply_default=0,
558            default_value='',
559            enforce_vocabulary=0,
560            allowed_vocabulary=('Encontro', 'Convenção', 'Reunião', 'Evento Social', 'Trabalho'))
561
562def setupPortalCss(portal):
563    portal_css = getToolByName(portal, 'portal_css')
564    portal_css.manage_removeStylesheet('generated.css')
565    portal_css.manage_addStylesheet(id='generated.css', expression='', media='screen', rel='stylesheet',
566                             rendering='import', enabled=False)
567
568def setupProperties(portal):
569    portal_properties = getToolByName(portal, 'portal_properties')
570    portal_properties.site_properties.default_language = 'pt-br'
571    portal_properties.site_properties.localTimeFormat = '%d/%m/%Y'
572    portal_properties.site_properties.localLongTimeFormat = '%d/%m/%Y %H:%M'
573    portal_properties.site_properties.disable_folder_sections = (True)
574    portal_properties.navtree_properties.includeTop = (False)
575    portal_properties.navtree_properties.idsNotToList = ('Members','portal_ombudsman',)
576    portal_properties.navtree_properties.metaTypesNotToList = ('ATImage', 'ATFile', 'ATEvent', 'ATLink', 'ATNewsItem', 'OmbudsmanClaim', 'OmbudsmanResponsble', )
577
578    portal_properties.manage_addPropertySheet('portal_casas_properties','Propriedades do Portal das Casas')
579    if not portal_properties.portal_casas_properties.hasProperty('estado'):
580        portal_properties.portal_casas_properties._setProperty('estado', ['AC;Acre','AL;Alagoas','AP;Amapá','AM;Amazonas','BA;Bahia','CE;Ceará','DF;Distrito Federal','ES;Espírito Santo','GO;Goiás','MA;Maranhão','MT;Mato Grosso','MS;Mato Grosso do Sul','MG;Minas Gerais','PA;Pará','PB;Paraíba','PR;Paraná','PE;Pernambuco','PI;Piauí','RJ;Rio de Janeiro','RN;Rio Grande do Norte','RS;Rio Grande do Sul','RO;Rondônia','RR;Roraima','SC;Santa Catarina','SP;São Paulo','SE;Sergipe','TO;Tocantins'], 'lines')
581    if not portal_properties.portal_casas_properties.hasProperty('idade'):
582        portal_properties.portal_casas_properties._setProperty('idade', ['0;Menos que 15','1;15 a 20','2;20 a 25','3;25 a 30','4;30 a 35','5;35 a 40','6;45 a 50','7;50 a 55','8;55 a 60','9;60 a 65','10;65 a 70','11;70 a 75','12;75 a 80','13;Acima de 80'], 'lines')
583    if not portal_properties.portal_casas_properties.hasProperty('sexo'):
584        portal_properties.portal_casas_properties._setProperty('sexo', ['FE;Feminino','MA;Masculino'], 'lines')
585
586def setupPublicatorUtilidades(portal):
587    portal_url = getToolByName(portal, 'portal_url')
588    url = portal_url(relative_to_portal=1)
589    plone_id = portal_url.getPortalObject().getId()
590    items_utilidades = [{'RemoteURL':'http://www.interlegis.gov.br', 'Description':'Programa Interlegis', 'Title':'Programa Interlegis', 'NewWindow':'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-interlegis', 'RelativeContentURL':'utilidades/link-interlegis', 'Id':'link-interlegis'}, {'RemoteURL':'http://www.senado.gov.br', 'Description':'Senado Federal', 'Title':'Senado Federal', 'NewWindow':'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-senado', 'RelativeContentURL':'utilidades/link-senado', 'Id':'link-senado'}, {'RemoteURL':'http://www.camara.gov.br', 'Description':'Câmara dos Deputados', 'Title':'Câmara dos Deputados', 'NewWindow':'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-camara', 'RelativeContentURL':'utilidades/link-camara', 'Id':'link-camara'}]
591    portal_publicator = getToolByName(portal, 'portal_publicator')   
592    portal_publicator.addPublicationBox(id='links_utilidades',
593                           name='Utilidades',
594                           content_type=['Link'],
595                           n_items=5,
596                           search_states=['published'],
597                           items=items_utilidades)
598
599def setupPublicatorDestaque(portal):
600    portal_publicator = getToolByName(portal, 'portal_publicator')
601    portal_publicator.addPublicationBox(id='destaque',
602                           name='Notícia Destaque',
603                           content_type=['News Item'],
604                           n_items=1,
605                           search_states=['published'])
606
607def setupPublicatorNoticia(portal):
608    portal_publicator = getToolByName(portal, 'portal_publicator')
609    portal_publicator.addPublicationBox(id='noticia',
610                           name='Últimas Notícias',
611                           search_states=['published'],
612                           content_type=['News Item'],
613                           n_items=5)
614
615def setupPublicatorBanner(portal):
616    portal_url = getToolByName(portal, 'portal_url')
617    url = portal_url(relative_to_portal=1)
618    plone_id = portal_url.getPortalObject().getId()
619    items_banners = [{'Description':'Senado Federal', 'Title':'Senado Federal', 'RemoteUrl':'http://www.senado.gov.br', 'RelativeContentURL':'utilidades/link-senado', 'ImageURL':'imagens/banners/banner_senado.jpg', 'NewWindow': 'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-senado', 'Id':'link-senado'}, {'Description':'Programa Interlegis', 'Title':'Programa Interlegis', 'RemoteUrl':'http://www.interlegis.gov.br', 'RelativeContentURL':'utilidades/link-interlegis', 'ImageURL':'imagens/banners/banner_interlegis.jpg', 'RemoteURL':'http://www.camara.gov.br', 'NewWindow': 'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-interlegis', 'Id':'link-interlegis'}, {'Description':'Câmara dos Deputados', 'Title':'Câmara dos Deputados', 'RemoteUrl':'http://www.camara.gov.br', 'RelativeContentURL':'utilidades/link-camara', 'ImageURL':'imagens/banners/banner_camara.jpg', 'NewWindow': 'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-camara', 'Id':'link-camara'}]
620    portal_publicator = getToolByName(portal, 'portal_publicator')
621    portal_publicator.addPublicationBox(id='banners',
622                           name='Banners',
623                           content_type=['Link'],
624                           n_items=5,
625                           search_states=['published'],
626                           with_image=1,
627                           images_folder='imagens/banners',
628                           image_states=['published'],
629                           items=items_banners)
630
631def setupSin(portal):
632    sin_tool = getToolByName(portal, 'sin_tool')
633    sin_tool.manage_configSin(submit='Set Config', config=ARQUIVO)   
634
635def setupSkin(portal):
636    portal_skins = getToolByName(portal, 'portal_skins')
637    path = portal_skins.getSkinPath('Plone Default')
638    path = [elem.strip() for elem in path.split(',') if elem != '.svn']
639    path = ','.join(path)
640    portal_skins.addSkinSelection('Portal Casas', path)
641    portal_skins.manage_properties(default_skin = 'Portal Casas',
642                                   request_varname = 'plone_skin',
643                                   del_skin = 0,
644                                   chosen = [])
645
646def setupWebmail(portal):
647    portal_webmail = getToolByName(portal, 'portal_webmail')
648    portal_webmail.UsePortalData = (True)   
649
650def setupTipo(portal):
651    portal_types = getToolByName(portal, 'portal_types')
652    portal_types['Plone Site'].global_allow = False
653    addable_types=['Folder', 'OmbudsmanFolder']
654    portal_types['Plone Site'].filter_content_types = True
655    portal_types['Plone Site'].allowed_content_types = addable_types
656
657def addBackup(portal):
658    DIR = INSTANCE_HOME
659    BACKUP = INSTANCE_HOME+'/backup'
660    if os.path.exists(BACKUP):
661        pass
662    else:
663        os.system('mkdir %s/backup' % DIR)
664
665def addScheduler(portal):
666    zope_scheduler = getattr(portal, 'zope_scheduler', None)
667    if zope_scheduler is None:
668        portal.manage_addProduct['ZopeScheduler'].manage_addZopeScheduler()
669        zope_scheduler = getattr(portal, 'zope_scheduler', None)
670        zope_scheduler.manage_addTask('scripts_backup/packDB', ('0',), ('22',), [None], [1,3,5], (None))
671        zope_scheduler.manage_addTask('scripts_backup/moveBackup', ('00',), ('23',), [None], [1,3,5], (None))
672        zope_scheduler.manage_addTask('scripts_backup/backupFile', ('20',), ('23',), [None], [1,3,5], (None))
673
674
675def uninstall(self):
676    portal = self
677    # the ids of the objects to keep
678    locked_ids = ('historia', 'camara', 'agenda', 'processos-legislativos', 'leis', 'legislacao', \
679                  'licitacoes', 'editais', 'contabilidade', 'utilidades', 'imagens', 'enquetes', 'newsletters', \
680                  'foruns', 'noticias', 'eventos', 'saap', 'saal', 'scripts_backup', 'zope_scheduler', 'index_html')
681    po = self.portal_quickinstaller.ILPortalCasas.portalobjects
682    for id in locked_ids:
683        if id in po:
684            po.remove(id)
685
686    portal_controlpanel = getToolByName(portal,'portal_controlpanel')
687    portal_controlpanel.unregisterConfiglet('ajuda_portal_casas')
688
689    portal_types = getToolByName(portal, 'portal_types')
690    portal_types['Plone Site'].global_allow = True
691    portal_types['Plone Site'].filter_content_types = False
692
693    portal_properties = getToolByName(portal, 'portal_properties')
694    portal_properties._delObject('portal_casas_properties')
695
696    portal_publicator = getToolByName(portal, 'portal_publicator')
697    portal_publicator.deletePublicationBoxes(['banners', 'links_utilidades', 'destaque', 'noticia'])
698
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.