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

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

Alterados parametros passados para a portlet Utilidades

File size: 31.7 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')
415    saap._setProperty('remote_url','http://saapdemo.interlegis.gov.br/saap/index_saap_html')
416   
417def addSaal(portal):
418    portal.invokeFactory('Folder', id='saal', title='SAAL', excludeFromNav=1)
419
420def setupPortal(portal):
421    portal.manage_changeProperties(title='Portal das Casas Legislativas',
422                                   email_from_address='admin-stc@interlegis.gov.br',
423                                   email_from_name= 'Administrador')
424
425def setupSlots(portal):
426    left_slots =  ('here/portlet_navigation/macros/portlet', \
427                   'here/portlet_preferencias/macros/portlet', \
428                   'here/portlet_gazette/macros/portlet', \
429                   'here/sin_tool/macros/Zope-PT', \
430                   'here/portlet_recent/macros/portlet',)
431    portal._setPropValue('left_slots', left_slots)
432    right_slots = ('here/portlet_calendar/macros/portlet', \
433                   'here/popoll_slot2/macros/popollBox', \
434                   'here/portlet_review/macros/portlet', \
435                   'here/portlet_utilidades/macros/portlet',
436                   'here/portlet_previsao/macros/portlet',)
437    portal._setPropValue('right_slots', right_slots)
438
439def deleteAction(portal):
440    portal_actions = getToolByName(portal, 'portal_actions')
441    idx = 0
442    for action in portal_actions.listActions():
443        if action.getId() == 'index_html':
444            portal_actions.deleteActions((idx,))
445            break
446        idx += 1
447
448def deleteAction2(portal):
449    portal_actions = getToolByName(portal, 'portal_actions')
450    idx = 0
451    for action in portal_actions.listActions():
452        if action.getId() == 'sitemap':
453            portal_actions.deleteActions((idx,))
454            break
455        idx += 1
456
457def deleteAction3(portal):
458    portal_actions = getToolByName(portal, 'portal_actions')
459    idx = 0
460    for action in portal_actions.listActions():
461        if action.getId() == 'contact':
462            portal_actions.deleteActions((idx,))
463            break
464        idx += 1
465
466def deleteAction4(portal):
467    portal_actions = getToolByName(portal, 'portal_actions')
468    idx = 0
469    for action in portal_actions.listActions():
470        if action.getId() == 'plone_setup':
471            portal_actions.deleteActions((idx,))
472            break
473        idx += 1
474
475def deleteCategoria(portal):
476    portal_actions = getToolByName(portal, 'portal_actions')
477    idx = 0
478    for actions in portal_actions.listActions():
479        if actions.getCategory() == 'site_actions':
480            portal_actions.deleteActions((idx,))
481            break
482        idx += 1
483
484def setupActions(portal):
485    portal_actions = getToolByName(portal, 'portal_actions')
486    portal_actions.addAction(id='index_html', name='Página Inicial', action='string:$portal_url', condition='', permission='View', category='portal_tabs', visible=1)
487
488    portal_actions.addAction(id='ouvidoria', name='Ouvidoria', action='string:${portal_url}/ouvidoria', condition='', permission='View', category='portal_tabs', visible=1)
489
490    portal_actions.addAction(id='saap', name='SAAP', action='string: ${portal_url}/saap', condition='member', permission='View', category='portal_tabs', visible=1)
491
492    portal_actions.addAction(id='saal', name='SAAL', action='string: ${portal_url}/saal', condition='member', permission='View', category='portal_tabs', visible=1)
493 
494    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)
495
496    portal_actions.addAction(id='sitemap', name='Site Map', action='string: ${portal_url}/sitemap', condition='', permission='View', category='portal_tabs', visible=1)
497
498    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)
499
500def setupCssmanager(portal):
501    cssmanager = getToolByName(portal, 'portal_cssmanager')
502    cssmanager.manage_addToMapping('base_properties','Plone Css')
503
504def setupGroups(portal):
505    portal_groups = getToolByName(portal, 'portal_groups')
506    portal_groups.toggleGroupWorkspacesCreation()
507
508def setupScriptsBackup(portal):
509    portal.manage_addProduct['OFSP'].manage_addFolder('scripts_backup')
510    scripts_backup = getattr(portal, 'scripts_backup', None)
511    scripts_backup.manage_addProduct['ExternalMethod'].manage_addExternalMethod('backupFile','Backup zope.conf e products', PROJECTNAME+'.BackupPortalModelo', 'backupFile')
512    scripts_backup.manage_addProduct['ExternalMethod'].manage_addExternalMethod('packDB','Pack Data.fs', PROJECTNAME+'.BackupPortalModelo', 'packDB')
513    scripts_backup.manage_addProduct['ExternalMethod'].manage_addExternalMethod('moveBackup','Move Data.fs para iretorio backup', PROJECTNAME+'.BackupPortalModelo', 'moveBackup')
514
515def setupMemberdata(portal):
516    portal_memberdata = getToolByName(portal, 'portal_memberdata')
517    portal_memberdata.listed = (False)
518    if not portal_memberdata.hasProperty('sexo'):
519        portal_memberdata._setProperty('sexo', '', 'string')
520    if not portal_memberdata.hasProperty('idade'):
521        portal_memberdata._setProperty('idade', '', 'string')
522    if not portal_memberdata.hasProperty('endereco'):
523        portal_memberdata._setProperty('endereco', '', 'string')
524    if not portal_memberdata.hasProperty('bairro'):
525        portal_memberdata._setProperty('bairro', '', 'string')
526    if not portal_memberdata.hasProperty('cidade'):
527        portal_memberdata._setProperty('cidade', '', 'string')
528    if not portal_memberdata.hasProperty('estado'):
529        portal_memberdata._setProperty('estado', '', 'string')
530    if not portal_memberdata.hasProperty('fone_res'):
531        portal_memberdata._setProperty('fone_res', '', 'string')
532
533def setupMetadata(portal):
534    portal_metadata = getToolByName(portal, 'portal_metadata')
535    portal_metadata.updateElementPolicy(
536            element='Subject',
537            content_type='Event',
538            is_required=0,
539            supply_default=0,
540            default_value='',
541            enforce_vocabulary=0,
542            allowed_vocabulary=('Encontro', 'Convenção', 'Reunião', 'Evento Social', 'Trabalho'))
543
544def setupPortalCss(portal):
545    portal_css = getToolByName(portal, 'portal_css')
546    portal_css.manage_removeStylesheet('generated.css')
547    portal_css.manage_addStylesheet(id='generated.css', expression='', media='screen', rel='stylesheet',
548                             rendering='import', enabled=False)
549
550def setupProperties(portal):
551    portal_properties = getToolByName(portal, 'portal_properties')
552    portal_properties.site_properties.default_language = 'pt-br'
553    portal_properties.site_properties.localTimeFormat = '%d/%m/%Y'
554    portal_properties.site_properties.localLongTimeFormat = '%d/%m/%Y %H:%M'
555    portal_properties.site_properties.disable_folder_sections = (True)
556    portal_properties.navtree_properties.includeTop = (False)
557    portal_properties.navtree_properties.idsNotToList = ('Members','portal_ombudsman',)
558    portal_properties.navtree_properties.metaTypesNotToList = ('ATImage','ATFile','ATEvent','ATLink','ATNewsItem',)
559
560    portal_properties.manage_addPropertySheet('portal_casas_properties','Propriedades do Portal das Casas')
561    if not portal_properties.portal_casas_properties.hasProperty('estado'):
562        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')
563    if not portal_properties.portal_casas_properties.hasProperty('idade'):
564        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')
565    if not portal_properties.portal_casas_properties.hasProperty('sexo'):
566        portal_properties.portal_casas_properties._setProperty('sexo', ['FE;Feminino','MA;Masculino'], 'lines')
567
568def setupPublicatorUtilidades(portal):
569    portal_url = getToolByName(portal, 'portal_url')
570    url = portal_url(relative_to_portal=1)
571    partes = url.split('8080')
572    instancia = partes[1]
573    items_utilidades = [{'RemoteURL':'http://www.interlegis.gov.br', 'Description':'Programa Interlegis', 'Title':'Programa Interlegis', 'NewWindow':'on', 'RelativeContentURL':'utilidades/link-interlegis', 'RelativeURL':instancia+'/utilidades/link-interlegis'}, {'RemoteURL':'http://www.seado.gov.br', 'Description':'Senado Federal', 'Title':'Senado Federal', 'NewWindow':'on', 'RelativeContentURL':'utilidades/link-senado', 'RelativeURL':instancia+'/utilidades/link-senado'}, {'RemoteURL':'http://www.camara.gov.br', 'Description':'Câmara dos Deputados', 'Title':'Câmara dos Deputados', 'NewWindow':'on', 'RelativeContentURL':'utilidades/link-camara', 'RelativeURL':instancia+'/utilidades/link-camara'}]
574    portal_publicator = getToolByName(portal, 'portal_publicator')
575    portal_publicator.addPublicationBox(id='links_utilidades',
576                           name='Utilidades',
577                           content_type=['Link'],
578                           n_items=5,
579                           search_states=['published'],
580                           items=items_utilidades)
581
582def setupPublicatorPrevisao(portal):
583    portal_publicator = getToolByName(portal, 'portal_publicator')
584    portal_publicator.addPublicationBox(id='previsao',
585                           name='Previsão do Tempo',
586                           content_type=['Link'],
587                           n_items=1,
588                           search_states=['published'],
589                           with_image=1,
590                           image_states = ['published'],
591                           images_folder='imagens')
592
593def setupPublicatorDestaque(portal):
594    portal_publicator = getToolByName(portal, 'portal_publicator')
595    portal_publicator.addPublicationBox(id='destaque',
596                           name='Notícia Destaque',
597                           content_type=['News Item'],
598                           n_items=1,
599                           search_states=['published'],
600                           with_image=1,
601                           image_states = ['published'],
602                           images_folder='imagens/noticias')
603
604def setupPublicatorNoticia(portal):
605    portal_publicator = getToolByName(portal, 'portal_publicator')
606    portal_publicator.addPublicationBox(id='noticia',
607                           name='Últimas Notícias',
608                           search_states=['published'],
609                           content_type=['News Item'],
610                           n_items=5)
611
612def setupPublicatorBanner(portal):
613    portal_url = getToolByName(portal, 'portal_url')
614    url = portal_url(relative_to_portal=1)
615    partes = url.split('8080')
616    instancia = partes[1]
617    items_banners = [{'Description':'Senado Federal', 'RemoteUrl':'http://www.senado.gov.br', 'RelativeContentURL':'utilidades/link-senado', 'ImageURL':'imagens/banners/banner_senado.jpg', 'RelativeURL':instancia+'/utilidades/link-senado', 'NewWindow': 'on'}, {'Description':'Programa Interlegis', 'RemoteUrl':'http://www.interlegis.gov.br', 'RelativeContentURL':'utilidades/link-interlegis', 'ImageURL':'imagens/banners/banner_interlegis.jpg', 'RelativeURL':instancia+'/utilidades/link-interlegis', 'RemoteURL':'http://www.camara.gov.br', 'NewWindow': 'on'}, {'Description':'Câmara dos Deputados', 'RemoteUrl':'http://www.camara.gov.br', 'RelativeContentURL':'utilidades/link-camara', 'ImageURL':'imagens/banners/banner_camara.jpg', 'RelativeURL':instancia+'/utilidades/link-camara', 'NewWindow': 'on'}]
618    portal_publicator = getToolByName(portal, 'portal_publicator')
619    portal_publicator.addPublicationBox(id='banners',
620                           name='Banners',
621                           content_type=['Link'],
622                           n_items=8,
623                           search_states=['published'],
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    sin_tool.manage_configSin(submit='Set Config', config=ARQUIVO)   
632
633def setupSkin(portal):
634    portal_skins = getToolByName(portal, 'portal_skins')
635    path = portal_skins.getSkinPath('Plone Default')
636    path = [elem.strip() for elem in path.split(',') if elem != '.svn']
637    path = ','.join(path)
638    portal_skins.addSkinSelection('Portal Casas', path)
639    portal_skins.manage_properties(default_skin = 'Portal Casas',
640                                   request_varname = 'plone_skin',
641                                   del_skin = 0,
642                                   chosen = [])
643
644def setupTipo(portal):
645    portal_types = getToolByName(portal, 'portal_types')
646    portal_types['Plone Site'].global_allow = False
647    addable_types=['Folder', 'OmbudsmanFolder']
648    portal_types['Plone Site'].filter_content_types = True
649    portal_types['Plone Site'].allowed_content_types = addable_types
650
651def addBackup(portal):
652    DIR = INSTANCE_HOME+'backup'
653    os.system('mkdir backup')
654
655def addScheduler(portal):
656    portal.manage_addProduct['ZopeScheduler'].manage_addZopeScheduler()
657    zope_scheduler = getattr(portal, 'zope_scheduler', None)
658    zope_scheduler.manage_addTask('scripts_backup/packDB', ('0',), ('8',), [2,3,4,5], [3,4,5,6,], ('11',))
659    zope_scheduler.manage_addTask('scripts_backup/moveBackup', ('40',), ('8',), [2,3,4,5], [3,4,5,6,], ('11',))
660    zope_scheduler.manage_addTask('scripts_backup/backupFile', ('20',), ('8',), [2,3,4,5], [3,4,5,6,], ('11',))
661
662
663def uninstall(self):
664    pass
665
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.