Ejemplo n.º 1
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')
     
     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, [])
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
 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()
Ejemplo n.º 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)
Ejemplo n.º 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, [])
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
 def afterSetUp(self):
     portal = self.app.portal
     addNyFolder(portal, 'test_folder')
     addNyPointer(portal.test_folder, id='test_pointer', title='Test pointer')
Ejemplo n.º 11
0
 def add_object(self, parent, **kwargs):
     from naaya.content.pointer.pointer_item import addNyPointer
     return addNyPointer(parent, **kwargs)
Ejemplo n.º 12
0
 def add_object(self, parent):
     ob = parent[addNyPointer(parent, title='My pointer')]
     ob.approveThis()
     return ob
Ejemplo n.º 13
0
 def add_object(self, parent):
     ob = parent[addNyPointer(parent, title='My pointer')]
     ob.approveThis()
     return ob