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

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

Ao instalar adiciona pasta Ouvidoria

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