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

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

Alterado geracao de external_methods no portal_maintenance

File size: 31.2 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 Acquisition import aq_base
6
7import sys, os
8
9
10INDEX_HTML = '''<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
11      lang="en"
12      metal:use-macro="here/main_template/macros/master"
13      i18n:domain="plone">
14<body>
15<div metal:fill-slot="main">
16  <br />
17
18  <div metal:use-macro="here/portlet_noticia_destaque/macros/portlet" /><br />
19  <div metal:use-macro="here/portlet_noticias/macros/portlet" /><br />
20
21</div>
22</body>
23</html>
24'''
25
26SAAP = '''<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
27      lang="en"
28      i18n:domain="plone">
29<script language="JavaScript1.2">
30    function poponload() {
31        openwindow = window.open("http://saapdemo.interlegis.gov.br/saap/index_saap_html", "saap", "location=0, status=1, scrollbars=0, width=750, height=600");
32        openwindow.moveTo(200,200);
33    }
34</script>
35<body onload="javascript: poponload()">
36    <p>Sera aberta uma janela com o sistema. Se esta nao for aberta, clique <a href="javascript:poponload()">aqui</a>.</p>
37    <p>Se vc clicar no link acima e nao for aberta a janela, va no menu do seu browser e desabilite a opcao "Bloquear janelas popup".</p>
38
39</body>
40</html>
41
42'''
43
44def install(self,reinstall=0):
45    portal = self
46    replaceIndex(portal)
47    deletePastas(portal)
48    addHistoria(portal)
49    addCamara(portal)
50    addAgenda(portal)
51    addProcessos(portal)
52    addLeis(portal)
53    addLicitacoes(portal)
54    addContabilidade(portal)
55    addUtilidades(portal)
56    addImagens(portal)
57    addEnquetes(portal)
58    addNewsletters(portal)
59    addForuns(portal)
60    addNoticia(portal)
61    addEvento(portal)
62#    addOuvidoria(portal)
63    addWebmail(portal)
64    addSaap(portal)
65    addSaal(portal)
66    setupPortal(portal)
67    setupSlots(portal)
68    deleteAction(portal)
69    deleteAction2(portal)
70    deleteAction3(portal)
71    deleteAction4(portal)
72    deleteCategoria(portal)
73    setupActions(portal)
74    setupCssmanager(portal)
75    setupGroups(portal)
76    setupMaintenance(portal)
77    setupMemberdata(portal)
78    setupMembership(portal)
79    setupMetadata(portal)
80    setupPortalCss(portal)
81    setupWorkflow(portal)
82    setupProperties(portal)
83    setupPublicatorUtilidades(portal)
84    setupPublicatorPrevisao(portal)
85    setupPublicatorDestaque(portal)
86    setupPublicatorNoticia(portal)
87    setupPublicatorBanner(portal)
88    setupSin(portal)
89    setupSkin(portal)
90    setupTipo(portal)
91    addBackup(portal)
92
93def replaceIndex(portal):
94    portal.manage_delObjects('front-page')
95    portal.manage_addProduct['PageTemplates'].manage_addPageTemplate('index_html', '', INDEX_HTML)
96
97def deletePastas(portal):
98    portal.manage_delObjects('news')
99    portal.manage_delObjects('events')
100
101def addHistoria(portal):
102    portal.invokeFactory('Folder', id='historia', title='História')
103    hist = getattr(aq_base(portal), 'historia')
104    addable_types = ['Folder','File','Link','Document','DisplayPage']
105    if getattr(hist.aq_base, 'setConstrainTypesMode', None) is not None:
106        hist.setConstrainTypesMode(1)
107        hist.setImmediatelyAddableTypes(addable_types)
108        hist.setLocallyAllowedTypes(addable_types)
109
110    portal_workflow = getToolByName(portal, 'portal_workflow')
111    historia = getattr(portal, 'historia', None)
112    if historia is not None:
113        portal_workflow.doActionFor(historia, 'publish')
114    historia.invokeFactory('Folder', id='historia-camara', title='História da Câmara')
115    historia_camara = getattr(historia, 'historia-camara', None)
116    if historia_camara is not None:
117        portal_workflow.doActionFor(historia_camara, 'publish')
118    historia.invokeFactory('Folder', id='historia-cidade', title='História da Cidade')
119    historia_cidade = getattr(historia, 'historia-cidade', None)
120    if historia_cidade is not None:
121        portal_workflow.doActionFor(historia_cidade, 'publish')
122
123def addCamara(portal):
124    portal.invokeFactory('Folder', id='camara', title='A Câmara')
125    cam = getattr(aq_base(portal), 'camara')
126    addable_types = ['Folder','File','Link','Document','DisplayPage']
127    if getattr(cam.aq_base, 'setConstrainTypesMode', None) is not None:
128        cam.setConstrainTypesMode(1)
129        cam.setImmediatelyAddableTypes(addable_types)
130        cam.setLocallyAllowedTypes(addable_types)
131
132    portal_workflow = getToolByName(portal, 'portal_workflow')
133    camara = getattr(portal, 'camara', None)
134    if camara is not None:
135        portal_workflow.doActionFor(camara, 'publish')
136    camara.invokeFactory('Folder', id='funcao', title='Função e Definição')
137    funcao = getattr(camara, 'funcao', None)
138    if funcao is not None:
139        portal_workflow.doActionFor(funcao, 'publish')
140    camara.invokeFactory('Folder', id='departamentos', title='Departamentos')
141    departamentos = getattr(camara, 'departamentos', None)
142    if departamentos is not None:
143        portal_workflow.doActionFor(departamentos, 'publish')
144    camara.invokeFactory('Folder', id='vereadores', title='Vereadores')
145    vereadores = getattr(camara, 'vereadores', None)
146    if vereadores is not None:
147        portal_workflow.doActionFor(vereadores, 'publish')
148    vereadores.invokeFactory('Folder', id='informacoes', title='Vereadores')
149    informacoes = getattr(vereadores, 'informacoes', None)
150    if informacoes is not None:
151        portal_workflow.doActionFor(informacoes, 'publish')
152    vereadores.invokeFactory('Folder', id='ex-vereadores', title='Ex-Vereadores')
153    ex_vereadores = getattr(vereadores, 'ex-vereadores', None)
154    if ex_vereadores is not None:
155        portal_workflow.doActionFor(ex_vereadores, 'publish')
156    vereadores.invokeFactory('Folder', id='discursos', title='Discursos')
157    discursos = getattr(vereadores, 'discursos', None)
158    if discursos is not None:
159        portal_workflow.doActionFor(discursos, 'publish')
160    vereadores.invokeFactory('Folder', id='fale-vereador', title='Fale com o Vereador')
161    fale_vereador = getattr(vereadores, 'fale-vereador', None)
162    if fale_vereador is not None:
163        portal_workflow.doActionFor(fale_vereador, 'publish')
164    camara.invokeFactory('Folder', id='comissoes', title='Comissões')
165    comissoes = getattr(camara, 'comissoes', None)
166    if comissoes is not None:
167        portal_workflow.doActionFor(comissoes, 'publish')
168    camara.invokeFactory('Folder', id='mesa-diretora', title='Mesa Diretora')
169    mesa_diretora = getattr(camara, 'mesa-diretora', None)
170    if mesa_diretora is not None:
171        portal_workflow.doActionFor(mesa_diretora, 'publish')
172
173def addAgenda(portal):
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    portal.invokeFactory('Folder', id='processos-legislativos', title='Processos Legislativos')
180    proc = getattr(aq_base(portal), 'historia')
181    addable_types = ['Folder','File','Link','Document','DisplayPage']
182    if getattr(proc.aq_base, 'setConstrainTypesMode', None) is not None:
183        proc.setConstrainTypesMode(1)
184        proc.setImmediatelyAddableTypes(addable_types)
185        proc.setLocallyAllowedTypes(addable_types)
186
187    portal_workflow = getToolByName(portal, 'portal_workflow')
188    processos = getattr(portal, 'processos-legislativos', None)
189    if processos is not None:
190        portal_workflow.doActionFor(processos, 'publish')
191    processos.invokeFactory('Folder', id='ordem-dia', title='Ordem do Dia')
192    ordem = getattr(processos, 'ordem-dia', None)
193    if ordem is not None:
194        portal_workflow.doActionFor(ordem, 'publish')
195    processos.invokeFactory('Folder', id='sessoes', title='Sessões')
196    sessoes = getattr(processos, 'sessoes', None)
197    if sessoes is not None:
198        portal_workflow.doActionFor(sessoes, 'publish')
199    sessoes.invokeFactory('Folder', id='sessoes-online', title='Sessões On-line')
200    sessoes_online = getattr(sessoes, 'sessoes-online', None)
201    if sessoes_online is not None:
202        portal_workflow.doActionFor(sessoes_online, 'publish')
203    processos.invokeFactory('Folder', id='atas', title='Atas')
204    atas = getattr(processos, 'atas', None)
205    if atas is not None:
206        portal_workflow.doActionFor(atas, 'publish')
207
208def addLeis(portal):
209    portal.invokeFactory('Folder', id='leis', title='Leis')
210    lei = getattr(aq_base(portal), 'leis')
211    addable_types = ['Folder','File','Link','Document','DisplayPage']
212    if getattr(lei.aq_base, 'setConstrainTypesMode', None) is not None:
213        lei.setConstrainTypesMode(1)
214        lei.setImmediatelyAddableTypes(addable_types)
215        lei.setLocallyAllowedTypes(addable_types)
216
217    portal_workflow = getToolByName(portal, 'portal_workflow')
218    leis = getattr(portal, 'leis', None)
219    if leis is not None:
220        portal_workflow.doActionFor(leis, 'publish')
221    leis.invokeFactory('Folder', id='legislacao-municipal', title='Legislação Municipal')
222    legislacao_municipal = getattr(leis, 'legislacao-municipal', None)
223    if legislacao_municipal is not None:
224        portal_workflow.doActionFor(legislacao_municipal, 'publish')
225    leis.invokeFactory('Folder', id='leis-federais', title='Leis Federais')
226    leis_federais = getattr(leis, 'leis-federais', None)
227    if leis_federais is not None:
228        portal_workflow.doActionFor(leis_federais, 'publish')
229    leis.invokeFactory('Folder', id='leis-estaduais', title='Leis Estaduais')
230    leis_estaduais = getattr(leis, 'leis-estaduais', None)
231    if leis_estaduais is not None:
232        portal_workflow.doActionFor(leis_estaduais, 'publish')
233    leis.invokeFactory('Folder', id='projetos-lei', title='Projetos de Lei')
234    projetos_lei = getattr(leis, 'projetos-lei', None)
235    if projetos_lei is not None:
236        portal_workflow.doActionFor(projetos_lei, 'publish')
237    projetos = getattr(leis, 'projetos-lei', None)
238    projetos.invokeFactory('Folder', id='estatisticas-proposicoes', title='Estatísticas de Proposições')
239    estatisticas_proposicoes = getattr(projetos, 'estatisticas-proposicoes', None)
240    if estatisticas_proposicoes is not None:
241        portal_workflow.doActionFor(estatisticas_proposicoes, 'publish')
242    leis.invokeFactory('Folder', id='legislacao', title='Legislação')
243    legislacao = getattr(leis, 'legislacao', None)
244    if legislacao is not None:
245        portal_workflow.doActionFor(legislacao, 'publish')
246
247def addLicitacoes(portal):
248    portal.invokeFactory('Folder', id='licitacoes', title='Licitações')
249    lic = getattr(aq_base(portal), 'licitacoes')
250    addable_types = ['Folder','File','Link','Document','DisplayPage']
251    if getattr(lic.aq_base, 'setConstrainTypesMode', None) is not None:
252        lic.setConstrainTypesMode(1)
253        lic.setImmediatelyAddableTypes(addable_types)
254        lic.setLocallyAllowedTypes(addable_types)
255
256    portal_workflow = getToolByName(portal, 'portal_workflow')
257    licitacoes = getattr(portal, 'licitacoes', None)
258    if licitacoes is not None:
259        portal_workflow.doActionFor(licitacoes, 'publish')
260    licitacoes.invokeFactory('Folder', id='editais', title='Editais')
261    editais = getattr(licitacoes, 'editais', None)
262    if editais is not None:
263        portal_workflow.doActionFor(editais, 'publish')
264    licitacoes.invokeFactory('Folder', id='concursos', title='Concursos')
265    concursos = getattr(licitacoes, 'concursos', None)
266    if concursos is not None:
267        portal_workflow.doActionFor(concursos, 'publish')
268    licitacoes.invokeFactory('Folder', id='pregao', title='Pregão')
269    pregao = getattr(licitacoes, 'pregao', None)
270    if pregao is not None:
271        portal_workflow.doActionFor(pregao, 'publish')
272    licitacoes.invokeFactory('Folder', id='tomada-preco', title='Tomada de Preço')
273    tomada_preco = getattr(licitacoes, 'tomada-preco', None)
274    if tomada_preco is not None:
275        portal_workflow.doActionFor(tomada_preco, 'publish')
276    licitacoes.invokeFactory('Folder', id='convite', title='Convite')
277    convite = getattr(licitacoes, 'convite', None)
278    if convite is not None:
279        portal_workflow.doActionFor(convite, 'publish')
280
281def addContabilidade(portal):
282    portal.invokeFactory('Folder', id='contabilidade', title='Contabilidade')
283    cont = getattr(aq_base(portal), 'contabilidade')
284    addable_types = ['Folder','File','Link','Document','DisplayPage']
285    if getattr(cont.aq_base, 'setConstrainTypesMode', None) is not None:
286        cont.setConstrainTypesMode(1)
287        cont.setImmediatelyAddableTypes(addable_types)
288        cont.setLocallyAllowedTypes(addable_types)
289
290    portal_workflow = getToolByName(portal, 'portal_workflow')
291    contabilidade = getattr(portal, 'contabilidade', None)
292    if contabilidade is not None:
293        portal_workflow.doActionFor(contabilidade, 'publish')
294
295def addUtilidades(portal):
296    portal.invokeFactory('Folder', id='utilidades', title='Utilidades', excludeFromNav=1)
297    utd = getattr(aq_base(portal), 'utilidades')
298    addable_types = ['Folder','File','Link','Document','DisplayPage']
299    if getattr(utd.aq_base, 'setConstrainTypesMode', None) is not None:
300        utd.setConstrainTypesMode(1)
301        utd.setImmediatelyAddableTypes(addable_types)
302        utd.setLocallyAllowedTypes(addable_types)
303
304    link = getattr(portal, 'utilidades', None)
305    link.invokeFactory('Link', id='interlegis', title='Programa Interlegis', remoteUrl='http://www.interlegis.gov.br')
306    link.invokeFactory('Link', id='senado', title='Senado Federal', remoteUrl='http://www.senado.gov.br')
307    link.invokeFactory('Link', id='camara', title='Câmara dos Deputados', remoteUrl='http://www.camara.gov.br')
308    portal_workflow = getToolByName(portal, 'portal_workflow')
309    interlegis = getattr(link, 'interlegis', None)
310    if interlegis is not None:
311        portal_workflow.doActionFor(interlegis, 'publish')
312    senado = getattr(link, 'senado', None)
313    if senado is not None:
314        portal_workflow.doActionFor(senado, 'publish')
315    camara = getattr(link, 'camara', None)
316    if camara is not None:
317        portal_workflow.doActionFor(camara, 'publish')
318
319def addImagens(portal):
320    portal.invokeFactory('Folder', id='imagens', title='Imagens', excludeFromNav=1)
321    portal_workflow = getToolByName(portal, 'portal_workflow')
322    imagem = getattr(aq_base(portal), 'imagens')
323    addable_types = ['Image','Folder','Link']
324    if getattr(imagem.aq_base, 'setConstrainTypesMode', None) is not None:
325        imagem.setConstrainTypesMode(1)
326        imagem.setImmediatelyAddableTypes(addable_types)
327        imagem.setLocallyAllowedTypes(addable_types)
328
329    imagens = getattr(portal, 'imagens', None)
330    imagens.invokeFactory('Folder', id='inoticias', title='Notícias')
331    imagens.invokeFactory('Folder', id='banners', title='Banners')
332    imgban = getattr(imagens, 'banners', None)
333
334    imgban.invokeFactory('Image', id='banner_interlegis.jpg', title='Banner Interlegis')
335    newImage = getattr(imgban, 'banner_interlegis.jpg')
336    newImage.edit(file=file(INSTANCE_HOME+'/Products/ILPortalCasas/Extensions/banner_interlegis.jpg').read())
337
338    imgban.invokeFactory('Image', id='banner_senado.jpg', title='Banner Senado')
339    newImage = getattr(imgban, 'banner_senado.jpg')
340    newImage.edit(file=file(INSTANCE_HOME+'/Products/ILPortalCasas/Extensions/banner_senado.jpg').read())
341
342    imgban.invokeFactory('Image', id='banner_camara.jpg', title='Banner Câmara')
343    newImage = getattr(imgban, 'banner_camara.jpg')
344    newImage.edit(file=file(INSTANCE_HOME+'/Products/ILPortalCasas/Extensions/banner_camara.jpg').read())
345
346def addEnquetes(portal):
347    portal.invokeFactory('Folder', id='enquetes', title='Enquetes', excludeFromNav=1)
348
349    enquete = getattr(aq_base(portal), 'enquetes')
350    addable_types = ['PlonePopoll']
351    if getattr(enquete.aq_base, 'setConstrainTypesMode', None) is not None:
352        enquete.setConstrainTypesMode(1)
353        enquete.setImmediatelyAddableTypes(addable_types)
354        enquete.setLocallyAllowedTypes(addable_types)
355
356def addNewsletters(portal):
357    portal.invokeFactory('Folder', id='newsletters', title='Newsletters', excludeFromNav=1)
358
359    newsletters = getattr(aq_base(portal), 'newsletters')
360    addable_types = ['Subscriber','NewsletterTheme']
361    if getattr(newsletters.aq_base, 'setConstrainTypesMode', None) is not None:
362        newsletters.setConstrainTypesMode(1)
363        newsletters.setImmediatelyAddableTypes(addable_types)
364        newsletters.setLocallyAllowedTypes(addable_types)
365
366def addForuns(portal):
367    portal.invokeFactory('Ploneboard', id='foruns', title='Fóruns')
368    portal_workflow = getToolByName(portal, 'portal_workflow')
369    foruns = getattr(portal, 'foruns', None)
370    if foruns is not None:
371        portal_workflow.doActionFor(foruns, 'publish')
372
373def addNoticia(portal):
374    if 'news' not in portal.objectIds():
375        _createObjectByType('Large Plone Folder', portal, id='noticias',
376                            title='Notícias', description='Notícias', excludeFromNav=1)
377    news = getattr(aq_base(portal), 'noticias')
378
379    addable_types = ['News Item']
380    if getattr(news.aq_base, 'setConstrainTypesMode', None) is not None:
381        news.setConstrainTypesMode(1)
382        news.setImmediatelyAddableTypes(addable_types)
383        news.setLocallyAllowedTypes(addable_types)
384
385    try:
386        news.manage_addProperty('default_page', ['news_topic','news_listing','index_html'], 'lines')
387    except BadRequest:
388        pass
389
390def addEvento(portal):
391    if 'events' not in portal.objectIds():
392        _createObjectByType('Large Plone Folder', portal, id='eventos',
393                            title='Eventos', description='Eventos', excludeFromNav=1)
394    events = getattr(aq_base(portal), 'eventos')
395
396    addable_types = ['Event']
397    if getattr(events.aq_base, 'setConstrainTypesMode', None) is not None:
398        events.setConstrainTypesMode(1)
399        events.setImmediatelyAddableTypes(addable_types)
400        events.setLocallyAllowedTypes(addable_types)
401
402    try:
403        events.manage_addProperty('default_page', ['events_topic','events_listing','index_html'], 'lines')
404    except BadRequest:
405        pass
406
407#def addOuvidoria(portal):
408#    portal.invokeFactory('OmbudsmanFolder', id='ouvidoria', title='Ouvidoria', excludeFromNav=1)
409
410def addWebmail(portal):
411    portal.invokeFactory('Folder', id='webmail', title='Webmail', excludeFromNav=1)
412    portal_workflow = getToolByName(portal, 'portal_workflow')
413    webmail = getattr(portal, 'webmail', None)
414    if webmail is not None:
415        portal_workflow.doActionFor(webmail, 'publish')
416
417def addSaap(portal):
418    portal.invokeFactory('Folder', id='saap', title='SAAP', excludeFromNav=1)
419    saap = getattr(portal, 'saap', None)
420    saap.manage_addProduct['PageTemplates'].manage_addPageTemplate('index_html', '', SAAP)
421
422def addSaal(portal):
423    portal.invokeFactory('Folder', id='saal', title='SAAL', excludeFromNav=1)
424
425def setupPortal(portal):
426    portal.manage_changeProperties(title='Portal das Casas Legislativas',
427                                   email_from_address='admin-stc@interlegis.gov.br',
428                                   email_from_name= 'Administrador')
429
430def setupSlots(portal):
431    left_slots =  ('here/portlet_navigation/macros/portlet', \
432                   'here/portlet_preferencias/macros/portlet', \
433                   'here/portlet_gazette/macros/portlet', \
434                   'here/sin_tool/macros/Zope-PT', \
435                   'here/portlet_recent/macros/portlet',)
436    portal._setPropValue('left_slots', left_slots)
437    right_slots = ('here/portlet_calendar/macros/portlet', \
438                   'here/popoll_slot2/macros/popollBox', \
439                   'here/portlet_review/macros/portlet', \
440                   'here/portlet_utilidades/macros/portlet', \
441                   'here/portlet_previsao/macros/portlet',)
442    portal._setPropValue('right_slots', right_slots)
443
444def deleteAction(portal):
445    portal_actions = getToolByName(portal, 'portal_actions')
446    idx = 0
447    for action in portal_actions.listActions():
448        if action.getId() == 'index_html':
449            portal_actions.deleteActions((idx,))
450            break
451        idx += 1
452
453def deleteAction2(portal):
454    portal_actions = getToolByName(portal, 'portal_actions')
455    idx = 0
456    for action in portal_actions.listActions():
457        if action.getId() == 'sitemap':
458            portal_actions.deleteActions((idx,))
459            break
460        idx += 1
461
462def deleteAction3(portal):
463    portal_actions = getToolByName(portal, 'portal_actions')
464    idx = 0
465    for action in portal_actions.listActions():
466        if action.getId() == 'contact':
467            portal_actions.deleteActions((idx,))
468            break
469        idx += 1
470
471def deleteAction4(portal):
472    portal_actions = getToolByName(portal, 'portal_actions')
473    idx = 0
474    for action in portal_actions.listActions():
475        if action.getId() == 'plone_setup':
476            portal_actions.deleteActions((idx,))
477            break
478        idx += 1
479
480def deleteCategoria(portal):
481    portal_actions = getToolByName(portal, 'portal_actions')
482    idx = 0
483    for actions in portal_actions.listActions():
484        if actions.getCategory() == 'site_actions':
485            portal_actions.deleteActions((idx,))
486            break
487        idx += 1
488
489def setupActions(portal):
490    portal_actions = getToolByName(portal, 'portal_actions')
491    portal_actions.addAction(id='index_html', name='Página Inicial', action='string:$portal_url', condition='', permission='View', category='portal_tabs', visible=1)
492
493    portal_actions.addAction(id='ouvidoria', name='Ouvidoria', action='string:${portal_url}/ouvidoria', condition='', permission='View', category='portal_tabs', visible=1)
494
495    portal_actions.addAction(id='saap', name='SAAP', action='string: ${portal_url}/saap', condition='member', permission='View', category='portal_tabs', visible=1)
496
497    portal_actions.addAction(id='saal', name='SAAL', action='string: ${portal_url}/saal', condition='member', permission='View', category='portal_tabs', visible=1)
498 
499    portal_actions.addAction(id='webmail', name='Webmail', action='string:${portal_url}/webmail', condition='', permission='View', category='portal_tabs', visible=1)
500
501    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)
502
503    portal_actions.addAction(id='sitemap', name='Site Map', action='string: ${portal_url}/sitemap', condition='', permission='View', category='portal_tabs', visible=1)
504
505    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)
506
507def setupCssmanager(portal):
508    cssmanager = getToolByName(portal, 'portal_cssmanager')
509    cssmanager.manage_addToMapping('base_properties','Plone Css')
510
511def setupGroups(portal):
512    portal_groups = getToolByName(portal, 'portal_groups')
513    portal_groups.toggleGroupWorkspacesCreation()
514
515def setupMaintenance(portal):
516    portal_maintenance = getToolByName(portal, 'portal_maintenance')
517
518    pm_scripts = portal_maintenance.scripts
519    manage_addExternalMethod(pm_scripts,'backupFile',
520                             'Backup zope.conf e products',
521                             PROJECTNAME+'.BackupPortalModelo',
522                             'backupFile')
523
524    manage_addExternalMethod(pm_scripts,'moveBackup',
525                             'Move Data.fs.old',
526                             PROJECTNAME+'.BackupPortalModelo',
527                             'moveBackup')
528
529    pm_tasks = portal_maintenance.tasks
530    pm_tasks.invokeFactory('MaintenanceTask', 'pack')
531    pm_tasks.pack._updateProperty('script_name','packDB')
532    pm_tasks.pack._updateProperty('title','pack')
533    pm_tasks.pack._updateProperty('scheduled_hour','22')
534
535
536def setupMemberdata(portal):
537    portal_memberdata = getToolByName(portal, 'portal_memberdata')
538    portal_memberdata.listed = (False)
539    if not portal_memberdata.hasProperty('sexo'):
540        portal_memberdata._setProperty('sexo', '', 'string')
541    if not portal_memberdata.hasProperty('idade'):
542        portal_memberdata._setProperty('idade', '', 'string')
543    if not portal_memberdata.hasProperty('endereco'):
544        portal_memberdata._setProperty('endereco', '', 'string')
545    if not portal_memberdata.hasProperty('bairro'):
546        portal_memberdata._setProperty('bairro', '', 'string')
547    if not portal_memberdata.hasProperty('cidade'):
548        portal_memberdata._setProperty('cidade', '', 'string')
549    if not portal_memberdata.hasProperty('estado'):
550        portal_memberdata._setProperty('estado', '', 'string')
551    if not portal_memberdata.hasProperty('fone_res'):
552        portal_memberdata._setProperty('fone_res', '', 'string')
553
554def setupMembership(portal):
555    portal_membership = getToolByName(portal, 'portal_membership')
556    portal_membership.setMemberareaCreationFlag()
557
558def setupMetadata(portal):
559    portal_metadata = getToolByName(portal, 'portal_metadata')
560    portal_metadata.updateElementPolicy(
561            element='Subject',
562            content_type='Event',
563            is_required=0,
564            supply_default=0,
565            default_value='',
566            enforce_vocabulary=0,
567            allowed_vocabulary=('Encontro', 'Convenção', 'Reunião', 'Evento Social', 'Trabalho'))
568
569def setupPortalCss(portal):
570    portal_css = getToolByName(portal, 'portal_css')
571    portal_css.manage_removeStylesheet('generated.css')
572    portal_css.manage_addStylesheet(id='generated.css', expression='', media='screen', rel='stylesheet',
573                             rendering='import', enabled=False)
574
575def setupWorkflow(portal):
576    portal_workflow = getToolByName(portal, 'portal_workflow')
577    portal_workflow.setDefaultChain('portal_modelo_workflow')
578
579def setupProperties(portal):
580    portal_properties = getToolByName(portal, 'portal_properties')
581    portal_properties.site_properties.default_language = 'pt-br'
582    portal_properties.site_properties.localTimeFormat = '%d/%m/%Y'
583    portal_properties.site_properties.localLongTimeFormat = '%d/%m/%Y %H:%M'
584    portal_properties.site_properties.disable_folder_sections = (True)
585    portal_properties.navtree_properties.includeTop = (False)
586    portal_properties.navtree_properties.idsNotToList = ('Members','portal_ombudsman',)
587    portal_properties.navtree_properties.metaTypesNotToList = ('ATImage','ATFile','ATEvent','ATLink','ATNewsItem',)
588
589    portal_properties.manage_addPropertySheet('portal_casas_properties','Propriedades do Portal das Casas')
590    if not portal_properties.portal_casas_properties.hasProperty('estado'):
591        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')
592    if not portal_properties.portal_casas_properties.hasProperty('idade'):
593        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')
594    if not portal_properties.portal_casas_properties.hasProperty('sexo'):
595        portal_properties.portal_casas_properties._setProperty('sexo', ['FE;Feminino','MA;Masculino'], 'lines')
596
597def setupPublicatorUtilidades(portal):
598    portal_publicator = getToolByName(portal, 'portal_publicator')
599    portal_publicator.addPublicationBox(id='utilidades',
600                           name='Utilidades',
601                           content_type=['Link'],
602                           n_items=5)
603
604def setupPublicatorPrevisao(portal):
605    portal_publicator = getToolByName(portal, 'portal_publicator')
606    portal_publicator.addPublicationBox(id='previsao',
607                           name='Previsão do Tempo',
608                           content_type=['Link'],
609                           n_items=1,
610                           with_image=1,
611                           image_states = ['published'],
612                           images_folder='imagens')
613
614def setupPublicatorDestaque(portal):
615    portal_publicator = getToolByName(portal, 'portal_publicator')
616    portal_publicator.addPublicationBox(id='destaque',
617                           name='Notícia Destaque',
618                           content_type=['News Item'],
619                           n_items=1,
620                           with_image=1,
621                           image_states = ['published'],
622                           images_folder='imagens/noticias')
623
624def setupPublicatorNoticia(portal):
625    portal_publicator = getToolByName(portal, 'portal_publicator')
626    portal_publicator.addPublicationBox(id='noticia',
627                           name='Últimas Notícias',
628                           content_type=['News Item'],
629                           n_items=5)
630
631def setupPublicatorBanner(portal):
632    portal_url = getToolByName(portal, 'portal_url')
633    url = portal_url(relative_to_portal=1)
634    items_banners = [{'Description':'Senado Federal','RemoteUrl':'http://www.senado.gov.br', 'ImageURL':'/imagens/banners/banner_senado.jpg', 'NewWindow': 'on', 'RelativeContentURL': '/utilidades/senado', 'RelativeURL':url+'/imagens/banners/banner_senado.jpg'},{'Description':'Interlegis', 'RemoteUrl':'http://www.interlegis.gov.br', 'ImageURL':'/imagens/banners/banner_interlegis.jpg', 'NewWindow': 'on', 'RelativeContentURL': '/utilidades/interlegis', 'RelativeURL':url+'/imagens/banners/banner_interlegis.jpg'},{'Description':'Câmara dos Deputados','RemoteUrl':'http://www.camara.gov.br', 'ImageURL':'/imagens/banners/banner_camara.jpg', 'NewWindow': 'on', 'RelativeContentURL': '/utilidades/camara', 'RelativeURL':url+'/imagens/banners/banner_camara.jpg'}]
635    portal_publicator = getToolByName(portal, 'portal_publicator')
636    portal_publicator.addPublicationBox(id='banners',
637                           name='Banners',
638                           content_type=['Link'],
639                           n_items=12,
640                           with_image=1,
641                           images_folder='imagens/banners',
642                           image_states=['published'],
643                           items=items_banners)
644
645def setupSin(portal):
646    sin_tool = getToolByName(portal, 'sin_tool')
647    channel = sin_tool.addChannel('zopept', '1h:http://rss.groups.yahoo.com/group/zope-pt/rss')
648    maps = sin_tool.addMap('Zope-PT', ['zopept'])
649
650def setupSkin(portal):
651    portal_skins = getToolByName(portal, 'portal_skins')
652    path = portal_skins.getSkinPath('Plone Default')
653    path = [elem.strip() for elem in path.split(',') if elem != '.svn']
654    path = ','.join(path)
655    portal_skins.addSkinSelection('Portal Casas', path)
656    portal_skins.manage_properties(default_skin = 'Portal Casas',
657                                   request_varname = 'plone_skin',
658                                   del_skin = 0,
659                                   chosen = [])
660
661def setupTipo(portal):
662    portal_types = getToolByName(portal, 'portal_types')
663    portal_types['Plone Site'].global_allow = False
664    addable_types=['Folder', 'OmbudsmanFolder']
665    portal_types['Plone Site'].filter_content_types = True
666    portal_types['Plone Site'].allowed_content_types = addable_types
667
668def addBackup(portal):
669    DIR = INSTANCE_HOME+'backup'
670    if os.path.exists(DIR):
671      print >> out, 'Ja existe um diretorio com este nome na raiz da sua instancia.'
672    else:
673      os.system('mkdir backup')
674       
675
676def uninstall(self):
677    pass
678
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.