Beispiel #1
0
def cinema_reviews_factory(entity,
                           state,
                           root,
                           sites=None,
                           access_control=None):
    """The cinema review factory. Add a cinema review to the 'root'.
       'entity' is a dict contains data,
       'state' the state of the added cinema review,
       'sites' site ids by service,
       'access_control' site ids if not sites"""

    access_control = get_access_control(entity, sites, access_control)
    if access_control:
        if 'tree' in entity and ROOT_TREE not in entity['tree']:
            entity['tree'] = {ROOT_TREE: entity['tree']}

        obj = create_object('cinema_review', entity)
        obj.state.append(state)
        obj.access_control = PersistentList(access_control)
        root.addtoproperty('reviews', obj)
        if state == 'published':
            tree = getattr(obj, '_tree', None)
            if tree:
                sites = [_get_obj(s) for s in access_control]
                root.merge_tree(tree)
                for site in [s for s in sites if s]:
                    site.merge_tree(tree)

            for artist in obj.artists:
                publish_artist(artist)

            for director in obj.directors:
                publish_artist(director)

        obj.reindex()
Beispiel #2
0
def smartfolder_factory(entity, state, root, sites=None, access_control=None):
    """The smartfolder factory. Add a smartfolder to the 'root'.
       'entity' is a dict contains data,
       'state' the state of the added cultural event,
       'sites' site ids by service,
       'access_control' site ids if not sites"""
    access_control = get_access_control(entity, sites, access_control)
    obj = create_object('smartfolder', entity)
    if obj:
        folder_filters_md = [
            f.get('metada_filter') for f in obj.filters
            if 'metada_filter' in f and 'tree' in f['metada_filter']
        ]
        for filter_ in folder_filters_md:
            if ROOT_TREE not in filter_['tree']:
                filter_['tree'] = {ROOT_TREE: filter_['tree']}

        obj.state = PersistentList([state])
        root.addtoproperty('smart_folders', obj)
        obj.access_control = PersistentList(access_control)
        for subfolder in obj.all_sub_folders():
            subfolder.state = PersistentList([state])

        if state == 'published':
            sites = [_get_obj(s) for s in access_control]
            for filter_ in folder_filters_md:
                tree = filter_.get('tree')
                root.merge_tree(tree)
                for site in [s for s in sites if s]:
                    site.merge_tree(tree)

        obj.reindex()
def smartfolder_factory(entity, state, root,
                        sites=None, access_control=None):
    """The smartfolder factory. Add a smartfolder to the 'root'.
       'entity' is a dict contains data,
       'state' the state of the added cultural event,
       'sites' site ids by service,
       'access_control' site ids if not sites"""
    access_control = get_access_control(entity, sites, access_control)
    obj = create_object('smartfolder', entity)
    if obj:
        folder_filters_md = [f.get('metada_filter')
                             for f in obj.filters
                             if 'metada_filter' in f and
                             'tree' in f['metada_filter']]
        for filter_ in folder_filters_md:
            if ROOT_TREE not in filter_['tree']:
                filter_['tree'] = {ROOT_TREE: filter_['tree']}

        obj.state = PersistentList([state])
        root.addtoproperty('smart_folders', obj)
        obj.access_control = PersistentList(access_control)
        for subfolder in obj.all_sub_folders():
            subfolder.state = PersistentList([state])

        if state == 'published':
            sites = [_get_obj(s) for s in access_control]
            for filter_ in folder_filters_md:
                tree = filter_.get('tree')
                root.merge_tree(tree)
                for site in [s for s in sites if s]:
                    site.merge_tree(tree)

        obj.reindex()
def cinema_reviews_factory(entity, state, root,
                           sites=None, access_control=None):
    """The cinema review factory. Add a cinema review to the 'root'.
       'entity' is a dict contains data,
       'state' the state of the added cinema review,
       'sites' site ids by service,
       'access_control' site ids if not sites"""

    access_control = get_access_control(entity, sites, access_control)
    if access_control:
        if 'tree' in entity and ROOT_TREE not in entity['tree']:
            entity['tree'] = {ROOT_TREE: entity['tree']}

        obj = create_object('cinema_review', entity)
        obj.state.append(state)
        obj.access_control = PersistentList(access_control)
        root.addtoproperty('reviews', obj)
        if state == 'published':
            tree = getattr(obj, '_tree', None)
            if tree:
                sites = [_get_obj(s) for s in access_control]
                root.merge_tree(tree)
                for site in [s for s in sites if s]:
                    site.merge_tree(tree)

            for artist in obj.artists:
                publish_artist(artist)

            for director in obj.directors:
                publish_artist(director)

        obj.reindex()
Beispiel #5
0
 def test_create_object(self):
     args = {
         'dates': 'Le 7 juin 2017 de 12h10 à 13h30',
         'description': 'test desc',
         'price': '15',
         'title': 'schedule1',
         'venue': {
             'addresses': [{
                 'city': 'Lille'
             }],
             'capacity': '13',
             'description': 'My venue',
             'title': 'MyVenue'
         }
     }
     result = data_manager.create_object('schedule', args)
     self.assertTrue(isinstance(result, Schedule))
     self.assertEqual(result.dates, args['dates'])
     self.assertEqual(result.description, args['description'])
     self.assertEqual(result.price, args['price'])
     self.assertEqual(result.title, args['title'])
     self.assertTrue(isinstance(result.venue, Venue))
     self.assertEqual(result.venue.title, args['venue']['title'])
     self.assertEqual(result.venue.description,
                      args['venue']['description'])
     self.assertEqual(result.venue.capacity, args['venue']['capacity'])
     self.assertEqual(result.venue.addresses, args['venue']['addresses'])
Beispiel #6
0
def artists_factory(entity, state, root, sites=None, access_control=None):
    """The artist factory. Add a artist to the 'root'.
       'entity' is a dict contains data,
       'state' the state of the added cultural event,
       'sites' site ids by service,
       'access_control' site ids if not sites"""

    obj = create_object('artist', entity)
    new_objs = merge_artists([obj])
    if new_objs and obj in new_objs:
        obj.state = PersistentList([state])
        root.addtoproperty('artists', obj)
        obj.reindex()
def artists_factory(entity, state, root,
                    sites=None, access_control=None):
    """The artist factory. Add a artist to the 'root'.
       'entity' is a dict contains data,
       'state' the state of the added cultural event,
       'sites' site ids by service,
       'access_control' site ids if not sites"""

    obj = create_object('artist', entity)
    new_objs = merge_artists([obj])
    if new_objs and obj in new_objs:
        obj.state = PersistentList([state])
        root.addtoproperty('artists', obj)
        obj.reindex()