Esempio n. 1
0
    def test_main(self):
        """ Add, Find, Edit and Delete Naaya Extended Files """
        #add NyExFile
        addNyExFile(self._portal().info, id='file1', title='file1', lang='en')
        addNyExFile(self._portal().info, id='file1_fr', title='file1_fr', lang='fr')

        meta = self._portal().getCatalogedObjectsCheckView(meta_type=['Naaya Extended File'])

        #get added NyExFile
        for x in meta:
            if x.getLocalProperty('title', 'en') == 'file1':
                meta = x
            if x.getLocalProperty('title', 'fr') == 'file1_fr':
                meta_fr = x

        self.assertEqual(meta.getLocalProperty('title', 'en'), 'file1')
        self.assertEqual(meta_fr.getLocalProperty('title', 'fr'), 'file1_fr')

        #change NyExFile title
        meta.saveProperties(title='file1_edited', lang='en')
        meta_fr.saveProperties(title='file1_fr_edited', lang='fr')

        self.assertEqual(meta.getLocalProperty('title', 'en'), 'file1_edited')
        self.assertEqual(meta_fr.getLocalProperty('title', 'fr'), 'file1_fr_edited')

        #delete NyExFile
        self._portal().info.manage_delObjects([meta.getId()])
        self._portal().info.manage_delObjects([meta_fr.getId()])

        meta = self._portal().getCatalogedObjectsCheckView(meta_type=['Naaya Extended File'])
        self.assertEqual(meta, [])
Esempio n. 2
0
 def afterSetUp(self):
     self.portal.manage_install_pluggableitem('Naaya Extended File')
     from Products.Naaya.NyFolder import addNyFolder
     from naaya.content.exfile.exfile_item import addNyExFile
     addNyFolder(self.portal, 'myfolder', contributor='contributor', submitted=1)
     addNyExFile(self.portal.myfolder, id='myexfile', title='My file', submitted=1, contributor='contributor')
     import transaction; transaction.commit()
    def saveProperties(self, title='', description='', sortorder='', start_date='', end_date='',
                       public_registration='', allow_file='', file='', lang='', REQUEST=None):
        """ """

        if not title:
            self.setSession('title', title)
            self.setSession('description', description)
            self.setSessionErrors(['The Title field must have a value.'])
            if REQUEST:
                return REQUEST.RESPONSE.redirect('%s/edit_html?lang=%s' % (self.absolute_url(), lang))
            else:
                raise ValueError('The title field must have a value.')

        if file and not file.read():
            self.setSession('title', title)
            self.setSession('description', description)
            self.setSessionErrors(['File must not be empty'])
            return REQUEST.RESPONSE.redirect('%s/edit_html?lang=%s' % (self.absolute_url(), lang))

        exfile = self.get_exfile()

        if file and exfile:
            exfile.saveUpload(file=file, lang=lang)
            downloadfilename=file.filename
            exfile._setLocalPropValue('downloadfilename', lang, downloadfilename)
        elif file and not exfile:
            addNyExFile(self, title=title, file=file, lang=lang, source='file')

        releasedate = self.releasedate
        self.updateRequestRoleStatus(public_registration, lang)
        self.save_properties(title, description, sortorder, start_date, end_date, public_registration, allow_file, releasedate, lang)

        if REQUEST:
            self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate())
            REQUEST.RESPONSE.redirect('%s/edit_html?lang=%s' % (self.absolute_url(), lang))
Esempio n. 4
0
 def afterSetUp(self):
     self.portal.manage_install_pluggableitem('Naaya Extended File')
     from Products.Naaya.NyFolder import addNyFolder
     from naaya.content.exfile.exfile_item import addNyExFile
     addNyFolder(self.portal, 'myfolder', contributor='contributor', submitted=1)
     addNyExFile(self.portal.myfolder, id='myexfile', title='My file', submitted=1, contributor='contributor')
     import transaction; transaction.commit()
    def saveProperties(self,
                       title='',
                       description='',
                       sortorder='',
                       start_date='',
                       end_date='',
                       public_registration='',
                       allow_file='',
                       file='',
                       lang='',
                       REQUEST=None):
        """ """

        if not title:
            self.setSession('title', title)
            self.setSession('description', description)
            self.setSessionErrors(['The Title field must have a value.'])
            if REQUEST:
                return REQUEST.RESPONSE.redirect('%s/edit_html?lang=%s' %
                                                 (self.absolute_url(), lang))
            else:
                raise ValueError('The title field must have a value.')

        if file and not file.read():
            self.setSession('title', title)
            self.setSession('description', description)
            self.setSessionErrors(['File must not be empty'])
            return REQUEST.RESPONSE.redirect('%s/edit_html?lang=%s' %
                                             (self.absolute_url(), lang))

        exfile = self.get_exfile()

        if file and exfile:
            exfile.saveUpload(file=file, lang=lang)
            downloadfilename = file.filename
            exfile._setLocalPropValue('downloadfilename', lang,
                                      downloadfilename)
        elif file and not exfile:
            addNyExFile(self, title=title, file=file, lang=lang, source='file')

        releasedate = self.releasedate
        self.updateRequestRoleStatus(public_registration, lang)
        self.save_properties(title, description, sortorder, start_date,
                             end_date, public_registration, allow_file,
                             releasedate, lang)

        if REQUEST:
            self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES,
                                     date=self.utGetTodayDate())
            REQUEST.RESPONSE.redirect('%s/edit_html?lang=%s' %
                                      (self.absolute_url(), lang))
Esempio n. 6
0
    def test_syndication(self):
        self.portal.publisher = 'The publisher'
        self.portal.creator = 'The creator'
        addNyExFile(self.portal['info'], id='9000', title='The exfile')
        exfile = self.portal['info']['9000']
        tree = etree.XML(exfile.syndicateThis())
        exfile_type = tree.xpath('./dc:type', namespaces=rdf_ns_map)[0]
        exfile_format = tree.xpath('./dc:format', namespaces=rdf_ns_map)[0]
        exfile_source = tree.xpath('./dc:source', namespaces=rdf_ns_map)[0]
        exfile_creator = tree.xpath('./dc:creator', namespaces=rdf_ns_map)[0]
        exfile_publisher = tree.xpath('./dc:publisher', namespaces=rdf_ns_map)[0]

        self.assertEqual(exfile_type.text, 'Text')
        self.assertEqual(exfile_format.text, 'application')
        self.assertEqual(exfile_source.text, self.portal.publisher)
        self.assertEqual(exfile_creator.text, self.portal.creator)
        self.assertEqual(exfile_publisher.text, self.portal.publisher)
Esempio n. 7
0
    def test_main(self):
        """ Add, Find, Edit and Delete Naaya Extended Files """
        #add NyExFile
        addNyExFile(self._portal().info, id='file1', title='file1', lang='en')
        addNyExFile(self._portal().info,
                    id='file1_fr',
                    title='file1_fr',
                    lang='fr')

        meta = self._portal().getCatalogedObjectsCheckView(
            meta_type=['Naaya Extended File'])

        #get added NyExFile
        for x in meta:
            if x.getLocalProperty('title', 'en') == 'file1':
                meta = x
            if x.getLocalProperty('title', 'fr') == 'file1_fr':
                meta_fr = x

        self.assertEqual(meta.getLocalProperty('title', 'en'), 'file1')
        self.assertEqual(meta_fr.getLocalProperty('title', 'fr'), 'file1_fr')

        #change NyExFile title
        meta.saveProperties(title='file1_edited', lang='en')
        meta_fr.saveProperties(title='file1_fr_edited', lang='fr')

        self.assertEqual(meta.getLocalProperty('title', 'en'), 'file1_edited')
        self.assertEqual(meta_fr.getLocalProperty('title', 'fr'),
                         'file1_fr_edited')

        #delete NyExFile
        self._portal().info.manage_delObjects([meta.getId()])
        self._portal().info.manage_delObjects([meta_fr.getId()])

        meta = self._portal().getCatalogedObjectsCheckView(
            meta_type=['Naaya Extended File'])
        self.assertEqual(meta, [])
Esempio n. 8
0
 def afterSetUp(self):
     portal = self.app.portal
     portal.manage_install_pluggableitem('Naaya Extended File')
     addNyFolder(portal, 'test_folder')
     addNyExFile(portal.test_folder, id='test_file', title='Test file')