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

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

Ao instalar produto cria diretorio backup na raiz da instancia para realizacao dos backups

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