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

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

Acrescentada folha de estilo para a Casa com a variavel nota_rodape para a Casa adicionar dados dela

File size: 20.5 KB
Linha 
1from Products.CMFCore.utils import getToolByName
2from Products.ExternalMethod.ExternalMethod import manage_addExternalMethod
3from Products.ILPortalCasas.config import *
4from Products.ILPortalCasas.config_install import *
5from Products.ILPortalCasas.Extensions.install_taxonomy import *
6from Products.ILPortalCasas.Previsao import Previsao
7from Acquisition import aq_base
8import sys, os
9
10def install(self):
11    portal = self
12    setupControlPanel(portal)
13    setupWorkflow(portal)
14    setupTING(portal)
15    setupIndex(portal)
16    addTaxonomy(portal)
17    addOuvidoria(portal)
18    setupPortal(portal)
19    setupSlots(portal)
20    deleteAction(portal)
21    deleteAction2(portal)
22    deleteAction3(portal)
23    deleteAction4(portal)
24    deleteCategoria(portal)
25    setupActions(portal)
26    setupCss(portal)
27    setupCssmanager(portal)
28    setupFactory(portal)
29    setupMembership(portal)
30    setupGroups(portal)
31    setupLanguages(portal)
32    setupScripts(portal)
33    setupMetadata(portal)
34    setupProperties(portal)
35    setupPublicatorUtilidades(portal)
36    setupPublicatorDestaque(portal)
37    setupPublicatorNoticia(portal)
38    setupPublicatorBanner(portal)
39    setupRSS(portal)
40    setupSin(portal)
41    setupSkin(portal)
42    setupTipo(portal)
43    addBackup(portal)
44    addScheduler(portal)
45    installPrevisao(portal)
46    customizeBaseProperties(portal)
47
48def setupControlPanel(portal):
49    portal.portal_controlpanel.registerConfiglet(**AJUDA_configlet)
50
51def setupWorkflow(portal):
52    portal_workflow = getToolByName(portal, 'portal_workflow')
53    portal_workflow.setDefaultChain('portal_modelo_workflow')
54    portal_workflow.setChainForPortalTypes( ['CalendarX', 'ATAudio', 'Recordings', 'ATPhoto', 'ATVideo', 'ATAudioFolder', 'ATPhotoAlbum'], "plone_workflow")
55
56def setupTING(portal):
57    portal_catalog = getToolByName(portal, 'portal_catalog')
58    indexes = portal_catalog.getIndexObjects()
59
60    try:
61        portal_catalog.manage_delIndex('SearchableText')
62    except:
63        pass
64
65    encoding = portal.portal_properties.site_properties.default_charset
66    portal_catalog.manage_addIndex('SearchableText', 'TextIndexNG2', extra={'default_encoding' : encoding})
67    portal_catalog.manage_reindexIndex('SearchableText', portal.REQUEST)
68
69def setupIndex(portal):
70    front_page = getattr(portal, 'front-page', None)
71    if front_page is not None:
72        portal._delObject('front-page')
73        portal.manage_changeProperties(default_page='pagina-inicial')
74
75def addTaxonomy(portal):
76    createTaxonomy(portal)
77
78def addOuvidoria(portal):
79    # Configurando lista de opções
80    omb_tool = getToolByName(portal, 'portal_ombudsman')
81    omb_tool.setVocab_sex( ['1;Feminino','2;Masculino'] )
82    omb_tool.setVocab_region( ['AC;Acre','AL;Alagoas','AP;Amapá','AM;Amazonas','BA;Bahia','CE;Ceará',\
83                               'DF;Distrito Federal','ES;Espírito Santo','GO;Goiás','MA;Maranhão',\
84                               'MT;Mato Grosso','MS;Mato Grosso do Sul','MG;Minas Gerais','PA;Pará',\
85                               'PB;Paraíba','PR;Paraná','PE;Pernambuco','PI;Piauí','RJ;Rio de Janeiro',\
86                               'RN;Rio Grande do Norte','RS;Rio Grande do Sul','RO;Rondônia',\
87                               'RR;Roraima','SC;Santa Catarina','SP;São Paulo','SE;Sergipe','TO;Tocantins'] )
88    omb_tool.setVocab_age( ['1;Menos que 15','2;Entre 16 e 20','3;Entre 21 e 30','4;Entre 31 e 40',\
89                            '5;Entre 41 e 50','6;Entre 51 e 60','7;Entre 61 e 70','8;Acima de 71'] )
90    ouvidoria = getattr(portal, 'ouvidoria', None)
91    if ouvidoria is None:
92        portal.invokeFactory('Ombudsman', id='ouvidoria', title='Ouvidoria')
93
94def setupPortal(portal):
95    portal.manage_changeProperties(title='Portal das Casas Legislativas',
96                                   email_from_address='admin-stc@interlegis.gov.br',
97                                   email_from_name= 'Administrador')
98
99def setupSlots(portal):
100    left_slots =  ('here/portlet_navigation/macros/portlet', \
101                   'here/portlet_preferencias/macros/portlet', \
102                   'here/portlet_gazette/macros/portlet', \
103                   'here/sin_tool/macros/Interlegis', \
104                   'here/portlet_recent/macros/portlet',)
105    portal._setPropValue('left_slots', left_slots)
106    right_slots = ('here/portlet_calendar/macros/portlet', \
107                   'here/popoll_slot2/macros/popollBox', \
108                   'here/portlet_review/macros/portlet', \
109                   'here/portlet_utilidades/macros/portlet', \
110                   'here/portlet_previsao/macros/portlet',)
111    portal._setPropValue('right_slots', right_slots)
112
113def deleteAction(portal):
114    portal_actions = getToolByName(portal, 'portal_actions')
115    idx = 0
116    for action in portal_actions.listActions():
117        if action.getId() == 'index_html':
118            portal_actions.deleteActions((idx,))
119            break
120        idx += 1
121
122def deleteAction2(portal):
123    portal_actions = getToolByName(portal, 'portal_actions')
124    idx = 0
125    for action in portal_actions.listActions():
126        if action.getId() == 'sitemap':
127            portal_actions.deleteActions((idx,))
128            break
129        idx += 1
130
131def deleteAction3(portal):
132    portal_actions = getToolByName(portal, 'portal_actions')
133    idx = 0
134    for action in portal_actions.listActions():
135        if action.getId() == 'contact':
136            portal_actions.deleteActions((idx,))
137            break
138        idx += 1
139
140def deleteAction4(portal):
141    portal_actions = getToolByName(portal, 'portal_actions')
142    idx = 0
143    for action in portal_actions.listActions():
144        if action.getId() == 'plone_setup':
145            portal_actions.deleteActions((idx,))
146            break
147        idx += 1
148
149def deleteCategoria(portal):
150    portal_actions = getToolByName(portal, 'portal_actions')
151    idx = 0
152    for actions in portal_actions.listActions():
153        if actions.getCategory() == 'site_actions':
154            portal_actions.deleteActions((idx,))
155            break
156        idx += 1
157
158def setupActions(portal):
159    portal_actions = getToolByName(portal, 'portal_actions')
160    portal_actions.addAction(id='index_html', name='Página Inicial', action='string:$portal_url', condition='', permission='View', category='portal_tabs', visible=1)
161
162    portal_actions.addAction(id='ouvidoria', name='Ouvidoria', action='string:${portal_url}/ouvidoria', condition='', permission='View', category='portal_tabs', visible=1)
163
164    portal_actions.addAction(id='saap', name='SAAP', action='string: ${portal_url}/saap', condition='member', permission='View', category='portal_tabs', visible=1)
165
166    portal_actions.addAction(id='saal', name='SAAL', action='string: ${portal_url}/saal', condition='member', permission='View', category='portal_tabs', visible=0)
167 
168    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)
169
170    portal_actions.addAction(id='sitemap', name='Site Map', action='string: ${portal_url}/sitemap', condition='', permission='View', category='portal_tabs', visible=1)
171
172    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)
173
174def setupCss(portal):
175    css = getToolByName(portal, 'portal_css')
176    css.manage_addStylesheet(id='portalCasas.css', media='all', enabled=True)
177
178def setupCssmanager(portal):
179    cssmanager = getToolByName(portal, 'portal_cssmanager')
180    cssmanager.manage_addToMapping('base_properties','Plone Css')
181
182def setupFactory(portal):
183    portal_factory = getToolByName(portal, 'portal_factory')
184    portal_factory.manage_setPortalFactoryTypes(listOfTypeIds=['Conta', 'Document', 'Event', 'File', 'Folder', 'Image', 'Link', 'News Item', 'Ombudsman', 'OmbudsmanClaim', 'OmbudsmanResponse', 'PrestacaoContas', 'DespesaPessoal', 'DisponibilidadeCaixa', 'Limites', 'RestosPagar', 'Previsao', 'Topic', 'Window', 'Newsletter', 'NewsletterBTree', 'NewsletterReference', 'NewsletterTheme', 'NewsletterTopic', 'Ploneboard', 'PloneboardComment', 'PloneboardConversation', 'PloneboardForum', 'Recordings', 'Subscriber', 'Section', 'ATVideo', 'ATPhotoAlbum', 'ATPhoto', 'ATMediaFile', 'ATAudioFolder', 'ATAudio'])
185
186def setupMembership(portal):
187    portal_membership = getToolByName(portal, 'portal_membership')
188    portal_membership.setMemberareaCreationFlag()
189
190def setupGroups(portal):
191    portal_groups = getToolByName(portal, 'portal_groups')
192    portal_groups.toggleGroupWorkspacesCreation()
193
194def setupLanguages(portal):
195    languages = getToolByName(portal, 'portal_languages')
196    defaultLanguage = 'pt-br'
197    supportedLanguages = ['pt-br']
198    languages.manage_setLanguageSettings(defaultLanguage, supportedLanguages,
199                                         setCookieN=True, setRequestN=False,
200                                         setPathN=True, setForcelanguageUrls=True,
201                                         setAllowContentLanguageFallback=False,
202                                         setUseCombinedLanguageCodes=True,
203                                         startNeutral=True, displayFlags=False)
204
205def setupScripts(portal):
206    scripts = getattr(portal, 'scripts', None)
207    if scripts is None:
208        portal.manage_addProduct['OFSP'].manage_addFolder('scripts')
209        scripts = getattr(portal, 'scripts', None)
210        scripts.manage_addProduct['ExternalMethod'].manage_addExternalMethod('backupFile','Backup zope.conf e products', PROJECTNAME+'.BackupPortalModelo', 'backupFile')
211        scripts.manage_addProduct['ExternalMethod'].manage_addExternalMethod('packDB','Pack Data.fs', PROJECTNAME+'.BackupPortalModelo', 'packDB')
212        scripts.manage_addProduct['ExternalMethod'].manage_addExternalMethod('moveBackup','Move Data.fs para iretorio backup', PROJECTNAME+'.BackupPortalModelo', 'moveBackup')
213        scripts.manage_addProduct['PythonScripts'].manage_addPythonScript('atualizaPrevisao')
214        scripts['atualizaPrevisao'].ZPythonScript_edit('', 'context.portal_previsao.generatePrevisao()')
215
216def installPrevisao(portal):
217    tool_previsao = getToolByName(portal, 'portal_previsao')
218    #gerando a primeira previsao
219    tool_previsao.setUsePrevisao(1);
220    tool_previsao.setURLPrevisao('http://reia.inmet.gov.br/prev_clima_tempo/dbHTMLCapreCid_B.php?cidade=BRASILIA&uf=DF&microreg=BRASILIA')
221    tool_previsao.generatePrevisao()
222
223def setupMetadata(portal):
224    portal_metadata = getToolByName(portal, 'portal_metadata')
225    portal_metadata.updateElementPolicy(
226            element='Subject',
227            content_type='Event',
228            is_required=0,
229            supply_default=0,
230            default_value='',
231            enforce_vocabulary=0,
232            allowed_vocabulary=('Encontro', 'Convenção', 'Reunião', 'Evento Social', 'Trabalho'))
233
234def setupProperties(portal):
235    portal_properties = getToolByName(portal, 'portal_properties')
236    portal_properties.site_properties.allowAnonymousViewAbout = (False)
237    portal_properties.site_properties.default_language = 'pt-br'
238    portal_properties.site_properties.localTimeFormat = '%d/%m/%Y'
239    portal_properties.site_properties.localLongTimeFormat = '%d/%m/%Y %H:%M'
240    portal_properties.site_properties.disable_folder_sections = (True)
241    portal_properties.navtree_properties.includeTop = (False)
242    portal_properties.navtree_properties.idsNotToList = ('Members','portal_ombudsman', 'portal_previsao', 'ouvidoria', 'portal_windowZ', 'news', 'events',)
243    portal_properties.navtree_properties.metaTypesNotToList = ('ATImage', 'ATFile', 'ATEvent', 'ATLink', 'ATNewsItem', 'OmbudsmanClaim', 'OmbudsmanResponse', 'Conta', 'ATPhoto',)
244
245    portal_properties.manage_addPropertySheet('portal_casas_properties','Propriedades do Portal das Casas')
246    if not portal_properties.portal_casas_properties.hasProperty('nota_rodape'):
247        portal_properties.portal_casas_properties._setProperty('nota_rodape', 'Copyright &copy; Interlegis <br /> Av. N2 - Anexo "E" do Senado Federal <br /> Brasília DF -   Cep: 70165-900 <br /> Fone: (061)3311-2556 Fax: (061)3311-2797', 'text')
248
249def setupPublicatorUtilidades(portal):
250    portal_url = getToolByName(portal, 'portal_url')
251    url = portal_url(relative_to_portal=1)
252    plone_id = portal_url.getPortalObject().getId()
253    items_utilidades = [{'RemoteUrl':'http://www.interlegis.gov.br', 'Description':'Programa Interlegis', 'Title':'Programa Interlegis', 'NewWindow':'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-interlegis', 'RelativeContentURL':'utilidades/link-interlegis', 'Id':'link-interlegis'}, {'RemoteUrl':'http://www.senado.gov.br', 'Description':'Senado Federal', 'Title':'Senado Federal', 'NewWindow':'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-senado', 'RelativeContentURL':'utilidades/link-senado', 'Id':'link-senado'}, {'RemoteUrl':'http://www.camara.gov.br', 'Description':'Câmara dos Deputados', 'Title':'Câmara dos Deputados', 'NewWindow':'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-camara', 'RelativeContentURL':'utilidades/link-camara', 'Id':'link-camara'}]
254    portal_publicator = getToolByName(portal, 'portal_publicator')   
255    portal_publicator.addPublicationBox(id='links_utilidades',
256                           name='Utilidades',
257                           content_type=['Link'],
258                           n_items=5,
259                           search_states=['published'],
260                           items=items_utilidades)
261
262def setupPublicatorDestaque(portal):
263    portal_publicator = getToolByName(portal, 'portal_publicator')
264    portal_publicator.addPublicationBox(id='destaque',
265                           name='Notícia Destaque',
266                           content_type=['News Item'],
267                           n_items=1,
268                           search_states=['published'])
269
270def setupPublicatorNoticia(portal):
271    portal_publicator = getToolByName(portal, 'portal_publicator')
272    portal_publicator.addPublicationBox(id='noticia',
273                           name='Últimas Notícias',
274                           search_states=['published'],
275                           content_type=['News Item'],
276                           n_items=5)
277
278def setupPublicatorBanner(portal):
279    portal_url = getToolByName(portal, 'portal_url')
280    url = portal_url(relative_to_portal=1)
281    plone_id = portal_url.getPortalObject().getId()
282    items_banners = [{'Description':'Senado Federal', 'Title':'Senado Federal', 'RemoteUrl':'http://www.senado.gov.br', 'RelativeContentURL':'utilidades/link-senado', 'ImageURL':'imagens/banners/banner_senado.jpg', 'NewWindow': 'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-senado', 'Id':'link-senado'}, {'Description':'Programa Interlegis', 'Title':'Programa Interlegis', 'RemoteUrl':'http://www.interlegis.gov.br', 'RelativeContentURL':'utilidades/link-interlegis', 'ImageURL':'imagens/banners/banner_interlegis.jpg', 'RemoteURL':'http://www.camara.gov.br', 'NewWindow': 'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-interlegis', 'Id':'link-interlegis'}, {'Description':'Câmara dos Deputados', 'Title':'Câmara dos Deputados', 'RemoteUrl':'http://www.camara.gov.br', 'RelativeContentURL':'utilidades/link-camara', 'ImageURL':'imagens/banners/banner_camara.jpg', 'NewWindow': 'on', 'RelativeURL':'/'+plone_id+'/utilidades/link-camara', 'Id':'link-camara'}]
283    portal_publicator = getToolByName(portal, 'portal_publicator')
284    portal_publicator.addPublicationBox(id='banners',
285                           name='Banners',
286                           content_type=['Link'],
287                           n_items=5,
288                           search_states=['published'],
289                           with_image=1,
290                           images_folder='imagens/banners',
291                           image_states=['published'],
292                           items=items_banners)
293
294def setupRSS(portal):
295    rss = getToolByName(portal, 'portal_syndication')
296    idx = 0
297    for action in rss.listActions():
298        if action.getId() == 'syndication':
299            rss.deleteActions((idx,))
300            break
301        idx += 1
302
303    rss.addAction('syndication', 'Syndication', 'string:${folder_url}/synPropertiesForm', 'python: folder is object and portal.portal_syndication.isSiteSyndicationAllowed()', 'Manage Properties', 'object', 1)
304    rss.editProperties(isAllowed=1)
305
306    noticias = getattr(portal, 'noticias', None)
307    if noticias.portal_syndication.isSiteSyndicationAllowed():
308        noticias.portal_syndication.enableSyndication(noticias)
309
310def setupSin(portal):
311    sin_tool = getToolByName(portal, 'sin_tool')
312    sin_tool.manage_configSin(submit='Set Config', config=ARQUIVO)   
313
314def setupSkin(portal):
315    portal_skins = getToolByName(portal, 'portal_skins')
316    path = portal_skins.getSkinPath('Plone Default')
317    path = [elem.strip() for elem in path.split(',') if elem != '.svn']
318    path = ','.join(path)
319    portal_skins.addSkinSelection('Portal Casas', path)
320    portal_skins.manage_properties(default_skin = 'Portal Casas',
321                                   request_varname = 'plone_skin',
322                                   del_skin = 0,
323                                   chosen = [] )
324
325def setupTipo(portal):
326    portal_types = getToolByName(portal, 'portal_types')
327    portal_types['Plone Site'].global_allow = False
328    addable_types=['Folder', 'Ombudsman', 'Document']
329    portal_types['Plone Site'].filter_content_types = True
330    portal_types['Plone Site'].allowed_content_types = addable_types
331
332def addBackup(portal):
333    DIR = INSTANCE_HOME
334    BACKUP = INSTANCE_HOME+'/backup'
335    if os.path.exists(BACKUP):
336        pass
337    else:
338        os.system('mkdir %s/backup' % DIR)
339
340def addScheduler(portal):
341    zope_scheduler = getattr(portal, 'zope_scheduler', None)
342    if zope_scheduler is None:
343        portal.manage_addProduct['ZopeScheduler'].manage_addZopeScheduler()
344        zope_scheduler = getattr(portal, 'zope_scheduler', None)
345        zope_scheduler.manage_addTask('scripts/packDB', ('0',), ('22',), [None], [1,3,5], (None))
346        zope_scheduler.manage_addTask('scripts/moveBackup', ('00',), ('23',), [None], [1,3,5], (None))
347        zope_scheduler.manage_addTask('scripts/backupFile', ('20',), ('23',), [None], [1,3,5], (None))
348        zope_scheduler.manage_addTask('scripts/atualizaPrevisao', ('0',), ('1','7','13','19',), [None], [None], (None))
349
350def customizeBaseProperties(portal):
351    skins_tool = getToolByName(portal, 'portal_skins')
352    skin_folder = getattr(skins_tool, 'ILPortalCasas_public')
353    base_prop = getattr(skin_folder, 'base_properties')
354    custom_folder = getattr(skins_tool, 'custom')
355    if base_prop.getId() not in custom_folder.objectIds():
356        base_prop.manage_doCustomize('custom')
357   
358
359
360def uninstall(self):
361    portal = self
362    # the ids of the objects to keep
363    locked_ids = ('historia', 'camara', 'agenda', 'processos-legislativos', 'leis', 'legislacao', 'prestacao-contas', \
364                  'licitacoes', 'editais', 'contabilidade', 'utilidades', 'imagens', 'enquetes', 'newsletters', \
365                  'foruns', 'noticias', 'eventos', 'saap', 'saal', 'scripts_backup', 'zope_scheduler', 'ouvidoria')
366    po = self.portal_quickinstaller.ILPortalCasas.portalobjects
367    for id in locked_ids:
368        if id in po:
369            po.remove(id)
370
371
372    portal._delObject('portal_previsao')
373
374
375    rss = getToolByName(portal, 'portal_syndication')
376    idx = 0
377    for action in rss.listActions():
378        if action.getId() == 'syndication':
379            rss.deleteActions((idx,))
380            break
381        idx += 1
382    noticias = getattr(portal, 'noticias', None)
383    if noticias.portal_syndication.isSiteSyndicationAllowed():
384        noticias.portal_syndication.disableSyndication(noticias)
385
386
387    portal_controlpanel = getToolByName(portal,'portal_controlpanel')
388    portal_controlpanel.unregisterConfiglet('ajuda_portal_casas')
389    portal_controlpanel.unregisterConfiglet(PREVISAO_configlet['id'])
390
391
392    portal_types = getToolByName(portal, 'portal_types')
393    portal_types['Plone Site'].global_allow = True
394    portal_types['Plone Site'].filter_content_types = False
395
396
397    portal_publicator = getToolByName(portal, 'portal_publicator')
398    portal_publicator.deletePublicationBoxes(['banners', 'links_utilidades', 'destaque', 'noticia'])
399
400    events = getattr(portal, 'eventos', None)
401    addable_types = ['Event', 'Topic']
402    if getattr(events.aq_base, 'setConstrainTypesMode', None) is not None:
403        events.setConstrainTypesMode(1)
404        events.setImmediatelyAddableTypes(addable_types)
405        events.setLocallyAllowedTypes(addable_types)
406
407    news = getattr(portal, 'noticias', None)
408    addable_types = ['News Item', 'Topic']
409    if getattr(events.aq_base, 'setConstrainTypesMode', None) is not None:
410        news.setConstrainTypesMode(1)
411        news.setImmediatelyAddableTypes(addable_types)
412        news.setLocallyAllowedTypes(addable_types)
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.