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

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

Acertado dia do mes do backup

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