Example #1
0
 def loadDefaultData(self):
     """ """
     NySite.__dict__['loadDefaultData'](self)
     self.loadSkeleton(join(ENVPORTAL_PRODUCT_PATH, 'skel'))
     self.getPropertiesTool().manageMainTopics(maintopics=['country_profile', 'reports', 'themes_indicators', 'projects', 'products', 'publications'])
     manage_addNyPhotoFolder(self, ID_PHOTOARCHIVE, TITLE_PHOTOARCHIVE)
     self._getOb(ID_PHOTOARCHIVE).approveThis()
     #create and configure LinkChecker instance
     manage_addLinkChecker(self, ID_LINKCHECKER, TITLE_LINKCHECKER)
     linkchecker_ob = self._getOb(ID_LINKCHECKER)
     linkchecker_ob.manage_edit(proxy='', batch_size=10, catalog_name=ID_CATALOGTOOL)
     linkchecker_ob.manage_addMetaType(METATYPE_NYURL)
     linkchecker_ob.manage_addProperty(METATYPE_NYURL, 'locator')
     for k,v in self.get_content_urls().items():
         linkchecker_ob.manage_addMetaType(k)
         for p in v:
             linkchecker_ob.manage_addProperty(k, p)
     #create helpdesk instance
     manage_addHelpDesk(self, ID_HELPDESKAGENT, TITLE_HELPDESKAGENT, self.getAuthenticationToolPath(1))
     #create and fill glossaries
     manage_addGlossaryCentre(self, ID_GLOSSARY_KEYWORDS, TITLE_GLOSSARY_KEYWORDS)
     self._getOb(ID_GLOSSARY_KEYWORDS).xliff_import(self.futRead(join(ENVPORTAL_PRODUCT_PATH, 'skel', 'others', 'glossary_keywords.xml')))
     manage_addGlossaryCentre(self, ID_GLOSSARY_COVERAGE, TITLE_GLOSSARY_COVERAGE)
     self._getOb(ID_GLOSSARY_COVERAGE).xliff_import(self.futRead(join(ENVPORTAL_PRODUCT_PATH, 'skel', 'others', 'glossary_coverage.xml')))
     #set glossary for pick lists
     self.keywords_glossary = ID_GLOSSARY_KEYWORDS
     self.coverage_glossary = ID_GLOSSARY_COVERAGE
     self._p_changed = 1
Example #2
0
 def loadDefaultData(self):
     """ """
     NySite.__dict__['loadDefaultData'](self)
     self.loadSkeleton(join(ENVPORTAL_PRODUCT_PATH, 'skel'))
     self.getPropertiesTool().manageMainTopics(maintopics=['country_profile', 'reports', 'themes_indicators', 'projects', 'products', 'publications'])
     manage_addNyPhotoFolder(self, ID_PHOTOARCHIVE, TITLE_PHOTOARCHIVE)
     self._getOb(ID_PHOTOARCHIVE).approveThis()
     #create and configure LinkChecker instance
     manage_addLinkChecker(self, ID_LINKCHECKER, TITLE_LINKCHECKER)
     linkchecker_ob = self._getOb(ID_LINKCHECKER)
     linkchecker_ob.manage_edit(proxy='', batch_size=10, catalog_name=ID_CATALOGTOOL)
     linkchecker_ob.manage_addMetaType(METATYPE_NYURL)
     linkchecker_ob.manage_addProperty(METATYPE_NYURL, 'locator')
     for k,v in self.get_content_urls().items():
         linkchecker_ob.manage_addMetaType(k)
         for p in v:
             linkchecker_ob.manage_addProperty(k, p)
     #create helpdesk instance
     manage_addHelpDesk(self, ID_HELPDESKAGENT, TITLE_HELPDESKAGENT, self.getAuthenticationToolPath(1))
     #create and fill glossaries
     manage_addGlossaryCentre(self, ID_GLOSSARY_KEYWORDS, TITLE_GLOSSARY_KEYWORDS)
     self._getOb(ID_GLOSSARY_KEYWORDS).xliff_import(self.futRead(join(ENVPORTAL_PRODUCT_PATH, 'skel', 'others', 'glossary_keywords.xml')))
     manage_addGlossaryCentre(self, ID_GLOSSARY_COVERAGE, TITLE_GLOSSARY_COVERAGE)
     self._getOb(ID_GLOSSARY_COVERAGE).xliff_import(self.futRead(join(ENVPORTAL_PRODUCT_PATH, 'skel', 'others', 'glossary_coverage.xml')))
     #set glossary for pick lists
     self.keywords_glossary = ID_GLOSSARY_KEYWORDS
     self.coverage_glossary = ID_GLOSSARY_COVERAGE
     self._p_changed = 1
    def test_cut_paste(self):
        return #TODO: cannot paste from the test; some photos are not correctly pasted (d and d, e-34, and pasting when id exists)
        photos_zip = load_test_file('data/test.zip', globals())
        manage_addNyPhotoGallery(self.portal.myfolder, id='mygallery2', title='My second photo gallery', submitted=1, contributor='contributor')
        manage_addNyPhotoFolder(self.portal.myfolder.mygallery2, id='myalbum', title='My photo album')
        self.portal.myfolder.mygallery2.myalbum.uploadPhotoOrZip(photos_zip)
        import transaction; transaction.commit()

        album_source = self.portal.myfolder.mygallery2.myalbum
        album_destination = self.portal.myfolder.mygallery.myalbum
        pics = [
            {'zip': 'a.gif' , 'portal': 'a.gif'},
            {'zip': 'b.gif' , 'portal': 'b.gif'},
            {'zip': 'c-d.gif' , 'portal': 'c-d.gif'},
            {'zip': 'd and d.gif' , 'portal': 'd_and_d.gif'},
            {'zip': 'e-34.gif' , 'portal': 'e-34.gif'},
            {'zip': 'k.gif' , 'portal': 'k.gif'},
        ]

        photos_zip = zipfile.ZipFile(photos_zip)

        paste_data = album_source.cutObjects(ids=[pic['portal'] for pic in pics])
        album_destination.pasteObjects(cp_data=paste_data)

        for pic in pics:
            self.failIf(pic['portal'] not in album_destination.objectIds(), '%s not in destination.' % pic['portal'])
            self.browser.go('http://localhost/%s/%s/view?display=Original' % (album_destination.absolute_url(1), pic['portal']))
            self.failUnlessEqual(photos_zip.read(pic['zip']), self.browser.get_html(), '%s contents doesn\'t match original.' % pic['portal'])
 def afterSetUp(self):
     from Products.Naaya.NyFolder import addNyFolder
     addNyFolder(self.portal, 'myfolder', contributor='contributor', submitted=1)
     manage_addNyPhotoGallery(self.portal.myfolder, id='mygallery', title='My photo gallery', submitted=1, contributor='contributor')
     manage_addNyPhotoFolder(self.portal.myfolder.mygallery, id='myalbum', title='My photo album')
     addNyPhoto(self.portal.myfolder.mygallery.myalbum, id="myphoto1", title="My photo 1")
     addNyPhoto(self.portal.myfolder.mygallery.myalbum, id="myphoto2", title="My photo 2")
     self.portal.myfolder.approveThis()
     import transaction; transaction.commit()
Example #5
0
 def afterSetUp(self):
     from Products.Naaya.NyFolder import addNyFolder
     from Products.NaayaPhotoArchive.NyPhotoGallery import manage_addNyPhotoGallery
     from Products.NaayaPhotoArchive.NyPhotoFolder import manage_addNyPhotoFolder
     from Products.NaayaPhotoArchive.NyPhoto import addNyPhoto
     addNyFolder(self.portal, 'myfolder', contributor='contributor', submitted=1)
     manage_addNyPhotoGallery(self.portal.myfolder, id='g', title='My gallery', submitted=1, contributor='admin')
     manage_addNyPhotoFolder(self.portal.myfolder.g, id='f', title='My folder', submitted=1, contributor='admin')
     addNyPhoto(self.portal.myfolder.g.f, id='myphoto', title='My photo', submitted=1, contributor='contributor')
     import transaction; transaction.commit()
Example #6
0
    def loadDefaultData(self):
        """ """
        #set default 'Naaya' configuration
        NySite.__dict__['createPortalTools'](self)
        NySite.__dict__['loadDefaultData'](self)

        #load site skeleton - configuration
        self.loadSkeleton(join(CHM2_PRODUCT_PATH, 'skel'))

        #remove Naaya default content
        self.getLayoutTool().manage_delObjects('skin')

        #set default PhotoFolder
        manage_addNyPhotoFolder(self, ID_PHOTOARCHIVE, TITLE_PHOTOARCHIVE)
        self._getOb(ID_PHOTOARCHIVE).approveThis()

        #create and configure LinkChecker instance
        manage_addLinkChecker(self, ID_LINKCHECKER, TITLE_LINKCHECKER)
        linkchecker_ob = self._getOb(ID_LINKCHECKER)
        linkchecker_ob.manage_edit(proxy='', batch_size=10, catalog_name=ID_CATALOGTOOL)
        linkchecker_ob.manage_addMetaType(METATYPE_NYURL)
        linkchecker_ob.manage_addProperty(METATYPE_NYURL, 'locator')
        for k,v in self.get_content_urls().items():
            linkchecker_ob.manage_addMetaType(k)
            for p in v:
                linkchecker_ob.manage_addProperty(k, p)

        #create helpdesk instance
        manage_addHelpDesk(self, ID_HELPDESKAGENT, TITLE_HELPDESKAGENT, self.getAuthenticationToolPath(1))
        #create NaayaCalendar instance
        manage_addEventCalendar(self, id="portal_calendar", title='Calendar of Events', description='',
                            day_len='2', cal_meta_types='Naaya Event', start_day='Monday', catalog=self.getCatalogTool().id, REQUEST=None)
        #create index for Naaya Calendar
        extra=Extra_for_DateRangeIndex(since_field='start_date', until_field='end_date')
        self.getCatalogTool().manage_addIndex("resource_interval", 'DateRangeIndex', extra=extra)
        #create and fill glossaries
        manage_addGlossaryCentre(self, ID_GLOSSARY_KEYWORDS, TITLE_GLOSSARY_KEYWORDS)
        self._getOb(ID_GLOSSARY_KEYWORDS).xliff_import(self.futRead(join(CHM2_PRODUCT_PATH, 'skel', 'others', 'glossary_keywords.xml')))
        self.add_glossary_coverage()

        #portal_map custom index
        custom_map_index = self.futRead(join(CHM2_PRODUCT_PATH, 'skel', 'others', 'map_index.zpt'))
        portal_map = self.getGeoMapTool()
        manage_addPageTemplate(portal_map, id='map_index', title='', text='')
        map_index = portal_map._getOb(id='map_index')
        map_index.pt_edit(text=custom_map_index, content_type='')
        
        #set glossary for pick lists
        self.keywords_glossary = ID_GLOSSARY_KEYWORDS
        self.coverage_glossary = ID_GLOSSARY_COVERAGE
        self._p_changed = 1
        #add Forum instance
        manage_addNyForum(self, id='portal_forum', title='CHM Forum', description='', categories=['CHM', 'Biodiversity', 'Other'], file_max_size=0, REQUEST=None)
 def _update_photo_folder(self, doc, old_id):
     parent = doc.getParentNode()
     lang = doc.gl_get_selected_language()
     title = doc.getVersionLocalProperty('title', lang)
     album_id = manage_addNyPhotoFolder(parent, doc.getId(), title,'', '', '',
                                        doc.sortorder, doc.releasedate, lang, '', '',
                                        doc.open_for_comments())
     album = parent._getOb(album_id)
     # To be used in step 2
     setattr(album, '_old_id', old_id)
     max_photos = len(doc.objectIds('Naaya Photo'))
     if max_photos > 100:
         setattr(album, 'max_photos', max_photos)
     # Update languages
     for language in doc.get_languages_mapping():
         lang = language['code']
         title = doc.getVersionLocalProperty('title', lang)
         if title:
             doc._setLocalPropValue('title', lang, title)
             doc.recatalogNyObject(doc)
     return album_id
Example #8
0
    def loadDefaultData(self):
        """ """
        # set default 'Naaya' configuration
        NySite.__dict__["createPortalTools"](self)
        NySite.__dict__["loadDefaultData"](self)

        # load site skeleton - configuration
        self.loadSkeleton(join(CHM2_PRODUCT_PATH, "skel"))

        # remove Naaya default content
        self.getLayoutTool().manage_delObjects("skin")

        # set default PhotoFolder
        manage_addNyPhotoFolder(self, ID_PHOTOARCHIVE, TITLE_PHOTOARCHIVE)
        self._getOb(ID_PHOTOARCHIVE).approveThis()

        # create and configure LinkChecker instance
        manage_addLinkChecker(self, ID_LINKCHECKER, TITLE_LINKCHECKER)
        linkchecker_ob = self._getOb(ID_LINKCHECKER)
        linkchecker_ob.manage_edit(proxy="", batch_size=10, catalog_name=ID_CATALOGTOOL)
        linkchecker_ob.manage_addMetaType(METATYPE_NYURL)
        linkchecker_ob.manage_addProperty(METATYPE_NYURL, "locator")
        for k, v in self.get_content_urls().items():
            linkchecker_ob.manage_addMetaType(k)
            for p in v:
                linkchecker_ob.manage_addProperty(k, p)

        # create helpdesk instance
        manage_addHelpDesk(self, ID_HELPDESKAGENT, TITLE_HELPDESKAGENT, self.getAuthenticationToolPath(1))
        # create NaayaCalendar instance
        manage_addEventCalendar(
            self,
            id="portal_calendar",
            title="Calendar of Events",
            description="",
            day_len="2",
            cal_meta_types="Naaya Event",
            start_day="Monday",
            catalog=self.getCatalogTool().id,
            REQUEST=None,
        )
        # create index for Naaya Calendar
        extra = Extra_for_DateRangeIndex(since_field="start_date", until_field="end_date")
        self.getCatalogTool().manage_addIndex("resource_interval", "DateRangeIndex", extra=extra)
        # create and fill glossaries
        manage_addGlossaryCentre(self, ID_GLOSSARY_KEYWORDS, TITLE_GLOSSARY_KEYWORDS)
        self._getOb(ID_GLOSSARY_KEYWORDS).xliff_import(
            self.futRead(join(CHM2_PRODUCT_PATH, "skel", "others", "glossary_keywords.xml"))
        )
        self.add_glossary_coverage()

        # portal_map custom index
        custom_map_index = self.futRead(join(CHM2_PRODUCT_PATH, "skel", "others", "map_index.zpt"))
        portal_map = self.getGeoMapTool()
        manage_addPageTemplate(portal_map, id="map_index", title="", text="")
        map_index = portal_map._getOb(id="map_index")
        map_index.pt_edit(text=custom_map_index, content_type="")

        # set glossary for pick lists
        self.keywords_glossary = ID_GLOSSARY_KEYWORDS
        self.coverage_glossary = ID_GLOSSARY_COVERAGE
        self._p_changed = 1
        # add Forum instance
        manage_addNyForum(
            self,
            id="portal_forum",
            title="CHM Forum",
            description="",
            categories=["CHM", "Biodiversity", "Other"],
            file_max_size=0,
            REQUEST=None,
        )