コード例 #1
0
ファイル: testContentType.py プロジェクト: bogtan/Naaya
 def test_main(self):
     """ Add, Find, Edit and Delete Naaya Pointers """
     #add NyPointer
     addNyPointer(self._portal().info, id='pointer1', title='pointer1', lang='en')
     addNyPointer(self._portal().info, id='pointer1_fr', title='pointer1_fr', lang='fr')
     
     meta = self._portal().getCatalogedObjectsCheckView(meta_type=['Naaya Pointer'])
     
     #get added NyPointer
     for x in meta:
         if x.getLocalProperty('title', 'en') == 'pointer1':
             meta = x
         if x.getLocalProperty('title', 'fr') == 'pointer1_fr':
             meta_fr = x
     
     self.assertEqual(meta.getLocalProperty('title', 'en'), 'pointer1')
     self.assertEqual(meta_fr.getLocalProperty('title', 'fr'), 'pointer1_fr')
     
     #change NyPointer title
     meta.saveProperties(title='pointer1_edited', lang='en', pointer='http://www.google.com')
     meta_fr.saveProperties(title='pointer1_fr_edited', lang='fr', pointer='http://fr.wikipedia.org')
     
     self.assertEqual(meta.getLocalProperty('title', 'en'), 'pointer1_edited')
     self.assertEqual(meta_fr.getLocalProperty('title', 'fr'), 'pointer1_fr_edited')
     
     #delete NyPointer
     self._portal().info.manage_delObjects([meta.id])
     self._portal().info.manage_delObjects([meta_fr.id])
     
     meta = self._portal().getCatalogedObjectsCheckView(meta_type=['Naaya Pointer'])
     self.assertEqual(meta, [])
コード例 #2
0
ファイル: testFunctional.py プロジェクト: eaudeweb/naaya
 def afterSetUp(self):
     from Products.Naaya.NyFolder import addNyFolder
     from naaya.content.pointer.pointer_item import addNyPointer
     addNyFolder(self.portal, 'myfolder', contributor='contributor', submitted=1)
     addNyPointer(self.portal.myfolder, id='mypointer', title='My pointer',
         pointer='http://www.eaudeweb.ro', submitted=1, contributor='contributor')
     import transaction; transaction.commit()
コード例 #3
0
ファイル: testFunctional.py プロジェクト: eaudeweb/trunk-eggs
 def afterSetUp(self):
     from Products.Naaya.NyFolder import addNyFolder
     from naaya.content.pointer.pointer_item import addNyPointer
     addNyFolder(self.portal, 'myfolder', contributor='contributor', submitted=1)
     addNyPointer(self.portal.myfolder, id='mypointer', title='My pointer',
         pointer='http://www.eaudeweb.ro', submitted=1, contributor='contributor')
     import transaction; transaction.commit()
コード例 #4
0
 def test_pointers_update_on_cut_paste_data(self):
     """ Moving an object that has a pointer to it, updates the pointer """
     cat = self.portal.getCatalogTool()
     cat.addIndex('pointer', 'FieldIndex')
     addNyURL(self.portal.info, id='some_url_ob', title='Some Url',
              url='http://eaudeweb.ro', contributor='simiamih')
     addNyPointer(self.portal.info, id='point', title='point', lang='en',
                  pointer='info/some_url_ob')
     addNyFolder(self.portal.info, id='sub_info')
     transaction.commit()
     cp = self.portal.info.manage_cutObjects('some_url_ob')
     self.portal.info.sub_info.manage_pasteObjects(cp)
     new_path = path_in_site(self.portal.info.sub_info.some_url_ob)
     self.assertEqual(self.portal.info.point.pointer, new_path)
コード例 #5
0
    def test_main(self):
        """ Add, Find, Edit and Delete Naaya Pointers """
        #add NyPointer
        addNyPointer(self.portal.info, id='pointer1', title='pointer1',
                     lang='en')
        addNyPointer(self.portal.info, id='pointer1_fr',
                     title='pointer1_fr', lang='fr')
        slash_pointer = addNyPointer(self.portal.info, id='pointer_slash',
                     title='pointer_slash', pointer=u'/info', lang='en')

        #Check if slash is removed
        assert getattr(self.portal.info.pointer_slash, 'pointer') == u'info'
        self.portal.info.manage_delObjects([slash_pointer])

        meta = self.portal.getCatalogedObjectsCheckView(meta_type=['Naaya Pointer'])

        #get added NyPointer
        for x in meta:
            if x.getLocalProperty('title', 'en') == 'pointer1':
                meta = x
            if x.getLocalProperty('title', 'fr') == 'pointer1_fr':
                meta_fr = x

        self.assertEqual(meta.getLocalProperty('title', 'en'), 'pointer1')
        self.assertEqual(meta_fr.getLocalProperty('title', 'fr'), 'pointer1_fr')

        #change NyPointer title
        meta.saveProperties(title='pointer1_edited', lang='en', pointer='http://www.google.com')
        meta_fr.saveProperties(title='pointer1_fr_edited', lang='fr', pointer='http://fr.wikipedia.org')

        self.assertEqual(meta.getLocalProperty('title', 'en'), 'pointer1_edited')
        self.assertEqual(meta_fr.getLocalProperty('title', 'fr'), 'pointer1_fr_edited')

        #delete NyPointer
        self.portal.info.manage_delObjects([meta.id])
        self.portal.info.manage_delObjects([meta_fr.id])

        meta = self.portal.getCatalogedObjectsCheckView(meta_type=['Naaya Pointer'])
        self.assertEqual(meta, [])
コード例 #6
0
def place_pointers(ob, exclude=[]):
    """ Ads pointers to ob in target_groups, topics and countries """
    props = {
        'title': ob.title,
        'description': getattr(ob, 'description', ''),
        'topics': ob.__dict__.get('topics', []),
        'target-groups': ob.__dict__.get('target-groups', []),
        'geo_location.lat': '',
        'geo_location.lon': '',
        'geo_location.address': '',
        'geo_type': getattr(ob, 'geo_type', ''),
        'coverage': ob.__dict__.get('coverage', ''),
        'keywords': ob.__dict__.get('keywords', ''),
        'sortorder': getattr(ob, 'sortorder', ''),
        'redirect': True,
        'pointer': path_in_site(ob)
    }
    if ob.geo_location:
        if ob.geo_location.lat:
            props['geo_location.lat'] = unicode(ob.geo_location.lat)
        if ob.geo_location.lon:
            props['geo_location.lon'] = unicode(ob.geo_location.lon)
        if ob.geo_location.address:
            props['geo_location.address'] = ob.geo_location.address
    site = ob.getSite()
    target_groups = ob.__dict__.get("target-groups", [])
    topics = ob.__dict__.get("topics", [])
    locations = []  # pointer locations
    if 'target-groups' not in exclude and isinstance(target_groups, list):
        for tgrup in target_groups:
            locations.append(
                site.unrestrictedTraverse("resources/%s" % str(tgrup)))
    if isinstance(topics, list):
        for topic in topics:
            locations.append(
                site.unrestrictedTraverse("topics/%s" % str(topic)))
    locations.extend(get_countries(ob))
    for loc in locations:
        if not props['sortorder']:
            props['sortorder'] = '200'
        p_id = addNyPointer(loc, '', contributor=ob.contributor, **props)
        pointer = getattr(loc, p_id)
        if pointer:
            if ob.approved:
                pointer.approveThis(1, ob.contributor)
            else:
                pointer.approveThis(0, None)
コード例 #7
0
def place_pointers(ob, exclude=[]):
    """ Ads pointers to ob in target_groups, topics and countries """
    props = {
        'title': ob.title,
        'description': getattr(ob, 'description', ''),
        'topics': ob.__dict__.get('topics', []),
        'target-groups': ob.__dict__.get('target-groups', []),
        'geo_location.lat': '',
        'geo_location.lon': '',
        'geo_location.address': '',
        'geo_type': getattr(ob, 'geo_type', ''),
        'coverage': ob.__dict__.get('coverage', ''),
        'keywords': ob.__dict__.get('keywords', ''),
        'sortorder': getattr(ob, 'sortorder', ''),
        'redirect': True,
        'pointer': path_in_site(ob)
    }
    if ob.geo_location:
        if ob.geo_location.lat:
            props['geo_location.lat'] = unicode(ob.geo_location.lat)
        if ob.geo_location.lon:
            props['geo_location.lon'] = unicode(ob.geo_location.lon)
        if ob.geo_location.address:
            props['geo_location.address'] = ob.geo_location.address
    site = ob.getSite()
    target_groups = ob.__dict__.get("target-groups", [])
    topics = ob.__dict__.get("topics", [])
    locations = []  # pointer locations
    if 'target-groups' not in exclude and isinstance(target_groups, list):
        for tgrup in target_groups:
            locations.append(
                site.unrestrictedTraverse("resources/%s" % str(tgrup)))
    if isinstance(topics, list):
        for topic in topics:
            locations.append(
                site.unrestrictedTraverse("topics/%s" % str(topic)))
    locations.extend(get_countries(ob))
    for loc in locations:
        if not props['sortorder']:
            props['sortorder'] = '200'
        p_id = addNyPointer(loc, '', contributor=ob.contributor, **props)
        pointer = getattr(loc, p_id)
        if pointer:
            if ob.approved:
                pointer.approveThis(1, ob.contributor)
            else:
                pointer.approveThis(0, None)
コード例 #8
0
ファイル: core.py プロジェクト: eaudeweb/trunk-eggs
def place_pointer_to_contact(ob, pointer_parent):
    """
    Very much like :func:~destinet.publishing.subscribers.place_pointers:

    """
    props = {
        'title': ob.title,
        'description': getattr(ob, 'description', ''),
        'topics': ob.__dict__.get('topics', []),
        'target-groups': ob.__dict__.get('target-groups', []),
        'geo_location.lat': '',
        'geo_location.lon': '',
        'geo_location.address': '',
        'geo_type': getattr(ob, 'geo_type', ''),
        'coverage': ob.__dict__.get('coverage', ''),
        'keywords': ob.__dict__.get('keywords', ''),
        'sortorder': getattr(ob, 'sortorder', ''),
        'redirect': True,
        'pointer': path_in_site(ob)
    }
    if ob.geo_location:
        if ob.geo_location.lat:
            props['geo_location.lat'] = unicode(ob.geo_location.lat)
        if ob.geo_location.lon:
            props['geo_location.lon'] = unicode(ob.geo_location.lon)
        if ob.geo_location.address:
            props['geo_location.address'] = ob.geo_location.address
    if not props['sortorder']:
        props['sortorder'] = '200'

    p_id = addNyPointer(pointer_parent,
                        ob.getId(),
                        contributor=ob.contributor,
                        **props)
    pointer = pointer_parent._getOb(p_id, None)
    if pointer:
        if ob.approved:
            pointer.approveThis(1, ob.contributor)
        else:
            pointer.approveThis(0, None)
        return pointer
コード例 #9
0
ファイル: core.py プロジェクト: eaudeweb/naaya.destinet.extra
def place_pointer_to_contact(ob, pointer_parent):
    """
    Very much like :func:~destinet.publishing.subscribers.place_pointers:

    """
    props = {
        'title': ob.title,
        'description': getattr(ob, 'description', ''),
        'topics': ob.__dict__.get('topics', []),
        'target-groups': ob.__dict__.get('target-groups', []),
        'geo_location.lat': '',
        'geo_location.lon': '',
        'geo_location.address': '',
        'geo_type': getattr(ob, 'geo_type', ''),
        'coverage': ob.__dict__.get('coverage', ''),
        'keywords': ob.__dict__.get('keywords', ''),
        'sortorder': getattr(ob, 'sortorder', ''),
        'redirect': True,
        'pointer': path_in_site(ob)
    }
    if ob.geo_location:
        if ob.geo_location.lat:
            props['geo_location.lat'] = unicode(ob.geo_location.lat)
        if ob.geo_location.lon:
            props['geo_location.lon'] = unicode(ob.geo_location.lon)
        if ob.geo_location.address:
            props['geo_location.address'] = ob.geo_location.address
    if not props['sortorder']:
        props['sortorder'] = '200'

    p_id = addNyPointer(pointer_parent, ob.getId(),
                        contributor=ob.contributor, **props)
    pointer = pointer_parent._getOb(p_id, None)
    if pointer:
        if ob.approved:
            pointer.approveThis(1, ob.contributor)
        else:
            pointer.approveThis(0, None)
        return pointer
コード例 #10
0
ファイル: testPageLoad.py プロジェクト: eaudeweb/naaya
 def afterSetUp(self):
     portal = self.app.portal
     addNyFolder(portal, 'test_folder')
     addNyPointer(portal.test_folder, id='test_pointer', title='Test pointer')
コード例 #11
0
 def add_object(self, parent, **kwargs):
     from naaya.content.pointer.pointer_item import addNyPointer
     return addNyPointer(parent, **kwargs)
コード例 #12
0
 def add_object(self, parent):
     ob = parent[addNyPointer(parent, title='My pointer')]
     ob.approveThis()
     return ob
コード例 #13
0
ファイル: test_common.py プロジェクト: eaudeweb/trunk-eggs
 def add_object(self, parent):
     ob = parent[addNyPointer(parent, title='My pointer')]
     ob.approveThis()
     return ob