def setUp(self): super(DestinetTestCase, self).setUp() # EW setup portal_id = self.portal.getId() self.app._delObject(portal_id) portal_id = 'demo-design' manage_addEnviroWindowsSite(self.app, portal_id) self.portal = self.app[portal_id] # Destinet setup addNyFolder(self.portal, 'topics') addNyFolder(self.portal.topics, 'atopic') addNyFolder(self.portal, 'who-who') addNyFolder(self.portal['who-who'], 'atarget_group') addNyFolder(self.portal['who-who'], 'destinet-users') addNyFolder(self.portal, 'resources') addNyFolder(self.portal, 'market-place') addNyFolder(self.portal, 'News') addNyFolder(self.portal, 'events') addNyFolder(self.portal, 'countries') addNyFolder(self.portal.countries, 'georgia', title='Georgia') addNyFolder(self.portal.countries, 'southgeorgia', title='South Georgia') schema = self.portal.portal_schemas['NyURL'] schema.addWidget('topics', widget_type='SelectMultiple', data_type='list') schema.addWidget('target-groups', widget_type='SelectMultiple', data_type='list') self.portal.getSchemaTool().addSchema('registration', 'registration') schema = self.portal.portal_schemas['registration'] schema.addWidget('groups', widget_type='SelectMultiple', data_type='list') nycontactschema = self.portal.portal_schemas['NyContact'] nycontactschema.addWidget('category-organization', widget_type="GeoType", data_type='str', required=True) nycontactschema.addWidget('category-marketplace', widget_type="GeoType", data_type='str', required=False) nycontactschema.addWidget('category-supporting-solutions', widget_type="GeoType", data_type='str', required=False) #import pdb; pdb.set_trace() manage_addDestinetPublisher(self.portal) cat = self.portal.getCatalogTool() cat.addIndex('pointer', 'FieldIndex') # set bundle naaya_b = bundles.get("Naaya") ew_b = bundles.get("EW") bundle = bundles.get("DESTINET-demo-design") ew_b.set_parent(naaya_b) bundle.set_parent(ew_b) self.portal.set_bundle(bundle)
def install_finish(self, REQUEST): """ """ install_data = self.getSession(SESSION_INSTALL_DATA, self.getInstallData()) if install_data['location'] == '': l_location = self.utGetROOT() else: l_location = self.unrestrictedTraverse(install_data['location'], self.utGetROOT()) #create the portal with the default structure id = self.utCleanupId(install_data['id']) if not id: id = PREFIX_SITE + self.utGenRandomId(6) manage_addEnviroWindowsSite(l_location, id=id, title=install_data['site_title']) ob = l_location._getOb(id) #add user and role (admin) if install_data['username'] != '' and install_data['password'] != '': ob.getAuthenticationTool().manage_addUser( install_data['username'], install_data['password'], install_data['password'], ['Manager'], '', install_data['administrator_name'], install_data['administrator_name'], install_data['administrator_email']) try: REQUEST.SESSION.delete('site_errors') except: pass try: REQUEST.SESSION.delete('site_infos') except: pass #add and set defaut language properties_tool = ob.getPropertiesTool() for lang in install_data['languages']: properties_tool.manage_addLanguage(lang) #properties_tool.manage_changeDefaultLang(install_data['language']) #change portal metadata ob.admin_metadata( site_title=install_data['site_title'], site_subtitle=install_data['subtitle'], description=install_data['description'], publisher=install_data['publisher'], contributor=install_data['contributor'], creator=install_data['creator'], rights=install_data['rights'], ) #change portal layout ob.admin_layout(theMasterList=install_data['skin'], theSlaveList=install_data['skin_style']) #change portal logo if install_data['site_logo'] != 'Nothing': image_ob = ob.getLayoutTool()._getOb('logo.gif') image_ob.update_data(data=install_data['site_logo']) image_ob._p_changed = 1 #administrator area ob.admin_email(mail_server_name=install_data['mail_server_name'], mail_server_port=install_data['mail_server_port'], administrator_email=install_data['administrator_email'], notify_on_errors_email=install_data['notify_on_errors']) ob.admin_properties(http_proxy=install_data['http_proxy'], portal_url=install_data['portal_url']) #latest uploads & news ob.portal_syndication.latestuploads_rdf.manageProperties( title='Latest uploads', description='Latest uploads', numberofitems=install_data['number_latest_uploads']) ob.portal_syndication.latestnews_rdf.manageProperties( title='Latest news', description='Latest news', numberofitems=install_data['number_announcements']) #additional products for l_product in self.getProductsStruct(install_data).keys(): if l_product == 'Remote links checking': if flagNaayaLinkChecker == 1: #product is present, add instance manage_addLinkChecker( ob, self.getKeyForProduct(install_data, l_product, 'id'), self.getKeyForProduct(install_data, l_product, 'title')) linkchecker_metatype = [ 'Naaya URL', 'Naaya Folder', 'Naaya Document' ] ob.portal_linkchecker.use_catalog = 1 ob.portal_linkchecker.catalog_name = "portal_catalog" ob.portal_linkchecker.batch_size = 20 #add default Linkchecker metatype for meta in linkchecker_metatype: ob.portal_linkchecker.manage_addMetaType(MetaType=meta) if meta == 'Naaya URL': ob.portal_linkchecker.manage_addProperty( MetaType=meta, Property='description') ob.portal_linkchecker.manage_addProperty( MetaType=meta, Property='locator') elif meta == 'Naaya Folder': ob.portal_linkchecker.manage_addProperty( MetaType=meta, Property='description') elif meta == 'Naaya Document': ob.portal_linkchecker.manage_addProperty( MetaType=meta, Property='description') ob.portal_linkchecker.manage_addProperty( MetaType=meta, Property='body') elif l_product == 'Discussion forum': if flagNaayaForum == 1: #product is present, add instance manage_addNyForum( ob, self.getKeyForProduct(install_data, l_product, 'id'), self.getKeyForProduct(install_data, l_product, 'title'), self.getKeyForProduct(install_data, l_product, 'description')) current_per = ob.getAuthenticationTool().getPermission( 'Add comments') current_per['permissions'].append( 'Add Naaya Forum Message') ob.getAuthenticationTool().editPermission( name='Authenticated', permissions=current_per) # send emails to appliants: administrator and contact p_to = [ install_data['administrator_email'], install_data['contact_email'] ] new_status = APPLICATION_STATUS_APPROVED p_from = self.unrestrictedTraverse( install_data['applications_url']).email_from #p_from = self. manuale = 'http://ew.eea.europa.eu/naaya/' p_subject = 'Your portal application on EnviroWindows has been approved' p_content = """ You have applied for an EnviroWindows-compliant portal hosted on the EnviroWindows servers. The application has been approved and your portal has been created at: %s An account was created for you on this portal with management rights: Username: %s Password: %s In order to get help on content contribution and portal administration, please consult: %s Regards, EnviroWindows Team **************************************************** IMPORTANT NOTICE: This is an automatic service. Please do not reply to this message. **************************************************** """ % (ob.absolute_url(), install_data['username'], install_data['password'], manuale) self.unrestrictedTraverse( install_data['ewindows_portal_url']).getEmailTool().sendEmail( p_content, p_to, p_from, p_subject) DestinationURL = install_data['DestinationURL'] self.delSession(SESSION_INSTALL_DATA) if DestinationURL == 'manage_main': return self.manage_main(self, REQUEST, update_menu=1) else: return REQUEST.RESPONSE.redirect('%s?action=finish' % DestinationURL)
def install_finish(self, REQUEST): """ """ install_data = self.getSession(SESSION_INSTALL_DATA, self.getInstallData()) if install_data['location'] == '': l_location = self.utGetROOT() else: l_location = self.unrestrictedTraverse(install_data['location'], self.utGetROOT()) #create the portal with the default structure id = self.utCleanupId(install_data['id']) if not id: id = PREFIX_SITE + self.utGenRandomId(6) manage_addEnviroWindowsSite(l_location, id=id, title=install_data['site_title']) ob = l_location._getOb(id) #add user and role (admin) if install_data['username'] != '' and install_data['password'] != '': ob.getAuthenticationTool().manage_addUser(install_data['username'], install_data['password'], install_data['password'], ['Manager'], '', install_data['administrator_name'], install_data['administrator_name'], install_data['administrator_email']) try: REQUEST.SESSION.delete('site_errors') except: pass try: REQUEST.SESSION.delete('site_infos') except: pass #add and set defaut language properties_tool = ob.getPropertiesTool() for lang in install_data['languages']: properties_tool.manage_addLanguage(lang) #properties_tool.manage_changeDefaultLang(install_data['language']) #change portal metadata ob.admin_metadata( site_title=install_data['site_title'], site_subtitle=install_data['subtitle'], description=install_data['description'], publisher=install_data['publisher'], contributor=install_data['contributor'], creator=install_data['creator'], rights=install_data['rights'], ) #change portal layout ob.admin_layout( theMasterList=install_data['skin'], theSlaveList=install_data['skin_style'] ) #change portal logo if install_data['site_logo'] != 'Nothing': image_ob = ob.getLayoutTool()._getOb('logo.gif') image_ob.update_data(data=install_data['site_logo']) image_ob._p_changed=1 #administrator area ob.admin_email(mail_server_name=install_data['mail_server_name'], mail_server_port=install_data['mail_server_port'], administrator_email=install_data['administrator_email'], notify_on_errors_email=install_data['notify_on_errors'] ) ob.admin_properties(http_proxy=install_data['http_proxy'], portal_url=install_data['portal_url'] ) #latest uploads & news ob.portal_syndication.latestuploads_rdf.manageProperties(title='Latest uploads', description='Latest uploads', numberofitems=install_data['number_latest_uploads'] ) ob.portal_syndication.latestnews_rdf.manageProperties(title='Latest news', description='Latest news', numberofitems=install_data['number_announcements'] ) #additional products for l_product in self.getProductsStruct(install_data).keys(): if l_product == 'Remote links checking': if flagNaayaLinkChecker == 1: #product is present, add instance manage_addLinkChecker(ob, self.getKeyForProduct(install_data, l_product, 'id'), self.getKeyForProduct(install_data, l_product, 'title') ) linkchecker_metatype = ['Naaya URL', 'Naaya Folder', 'Naaya Document'] ob.portal_linkchecker.use_catalog = 1 ob.portal_linkchecker.catalog_name="portal_catalog" ob.portal_linkchecker.batch_size = 20 #add default Linkchecker metatype for meta in linkchecker_metatype: ob.portal_linkchecker.manage_addMetaType(MetaType=meta) if meta == 'Naaya URL': ob.portal_linkchecker.manage_addProperty(MetaType=meta, Property='description') ob.portal_linkchecker.manage_addProperty(MetaType=meta, Property='locator') elif meta == 'Naaya Folder': ob.portal_linkchecker.manage_addProperty(MetaType=meta, Property='description') elif meta == 'Naaya Document': ob.portal_linkchecker.manage_addProperty(MetaType=meta, Property='description') ob.portal_linkchecker.manage_addProperty(MetaType=meta, Property='body') elif l_product == 'Discussion forum': if flagNaayaForum == 1: #product is present, add instance manage_addNyForum(ob, self.getKeyForProduct(install_data, l_product, 'id'), self.getKeyForProduct(install_data, l_product, 'title'), self.getKeyForProduct(install_data, l_product, 'description') ) current_per = ob.getAuthenticationTool().getPermission('Add comments') current_per['permissions'].append('Add Naaya Forum Message') ob.getAuthenticationTool().editPermission(name='Authenticated', permissions=current_per) # send emails to appliants: administrator and contact p_to = [install_data['administrator_email'], install_data['contact_email']] new_status = APPLICATION_STATUS_APPROVED p_from = self.unrestrictedTraverse(install_data['applications_url']).email_from #p_from = self. manuale = 'http://ew.eea.europa.eu/naaya/' p_subject = 'Your portal application on EnviroWindows has been approved' p_content = """ You have applied for an EnviroWindows-compliant portal hosted on the EnviroWindows servers. The application has been approved and your portal has been created at: %s An account was created for you on this portal with management rights: Username: %s Password: %s In order to get help on content contribution and portal administration, please consult: %s Regards, EnviroWindows Team **************************************************** IMPORTANT NOTICE: This is an automatic service. Please do not reply to this message. **************************************************** """ % (ob.absolute_url(), install_data['username'], install_data['password'], manuale) self.unrestrictedTraverse(install_data['ewindows_portal_url']).getEmailTool().sendEmail(p_content, p_to, p_from, p_subject) DestinationURL = install_data['DestinationURL'] self.delSession(SESSION_INSTALL_DATA) if DestinationURL == 'manage_main': return self.manage_main(self, REQUEST, update_menu=1) else: return REQUEST.RESPONSE.redirect('%s?action=finish' % DestinationURL)