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

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

Alteracoes na introducao

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