예제 #1
0
    def start(self, context, request, appstruct, **kw):
        artists, new_artists = extract_artists(
            appstruct.pop('artists', []), request)
        directors, new_directors = extract_artists(
            appstruct.pop('directors', []),
            request, is_directors=True)
        appstruct.pop('artists_ids')
        appstruct.pop('directors_ids')
        if appstruct.get('picture', None) is not None and \
            OBJECT_DATA in appstruct['picture']:
            appstruct['picture'] = appstruct['picture'][OBJECT_DATA]
            if not getattr(appstruct['picture'], '__name__', None):
                appstruct['picture'].__name__ = 'picture'

        context.set_metadata(appstruct)
        context.set_data(appstruct)
        context.setproperty('artists', artists)
        context.setproperty('directors', directors)
        context.modified_at = datetime.datetime.now(tz=pytz.UTC)
        context.reindex()
        objects = [context]
        objects.extend(new_artists)
        objects.extend(new_directors)
        request.registry.notify(ActivityExecuted(self, objects, get_current()))
        return {}
예제 #2
0
    def start(self, context, request, appstruct, **kw):
        user = get_current()
        artists, new_artists = extract_artists(
            appstruct.pop('artists', []), request)
        directors, new_directors = extract_artists(
            appstruct.pop('directors', []),
            request, is_directors=True)
        appstruct.pop('artists_ids')
        appstruct.pop('directors_ids')
        if appstruct.get('picture', None) is not None and \
            OBJECT_DATA in appstruct['picture']:
            appstruct['picture'] = appstruct['picture'][OBJECT_DATA]
            if not getattr(appstruct['picture'], '__name__', None):
                appstruct['picture'].__name__ = 'picture'

        context.set_metadata(appstruct)
        context.set_data(appstruct)
        context.setproperty('artists', artists)
        context.setproperty('directors', directors)
        context.modified_at = datetime.datetime.now(tz=pytz.UTC)
        if 'published' in context.state:
            not_published_artists = [a for a in context.artists
                                     if 'published' not in a.state]
            not_published_artists.extend(
                [a for a in context.directors
                 if 'published' not in a.state])
            for artist in not_published_artists:
                publish_artist(artist, request, user)

        context.reindex()
        new_objects = new_artists
        new_objects.extend(new_directors)
        new_objects.append(context)
        request.registry.notify(ActivityExecuted(self, new_objects, user))
        return {}
예제 #3
0
    def start(self, context, request, appstruct, **kw):
        artists, new_artists = extract_artists(appstruct.pop('artists', []),
                                               request)
        directors, new_directors = extract_artists(appstruct.pop(
            'directors', []),
                                                   request,
                                                   is_directors=True)
        appstruct.pop('artists_ids')
        appstruct.pop('directors_ids')
        if appstruct.get('picture', None) is not None and \
            OBJECT_DATA in appstruct['picture']:
            appstruct['picture'] = appstruct['picture'][OBJECT_DATA]
            if not getattr(appstruct['picture'], '__name__', None):
                appstruct['picture'].__name__ = 'picture'

        context.set_metadata(appstruct)
        context.set_data(appstruct)
        context.setproperty('artists', artists)
        context.setproperty('directors', directors)
        context.modified_at = datetime.datetime.now(tz=pytz.UTC)
        context.reindex()
        objects = [context]
        objects.extend(new_artists)
        objects.extend(new_directors)
        request.registry.notify(ActivityExecuted(self, objects, get_current()))
        return {}
예제 #4
0
 def start(self, context, request, appstruct, **kw):
     artists, new_artists = extract_artists(
         appstruct.get('artists', []), request)
     context.setproperty('artists', artists)
     submit_artists(context.artists)
     context.modified_at = datetime.datetime.now(tz=pytz.UTC)
     context.set_metadata(appstruct)
     context.reindex()
     objects = [context]
     objects.extend(new_artists)
     request.registry.notify(ActivityExecuted(self, objects, get_current()))
     return {}
예제 #5
0
 def start(self, context, request, appstruct, **kw):
     artists, new_artists = extract_artists(appstruct.get('artists', []),
                                            request)
     context.setproperty('artists', artists)
     submit_artists(context.artists)
     context.modified_at = datetime.datetime.now(tz=pytz.UTC)
     context.set_metadata(appstruct)
     context.reindex()
     objects = [context]
     objects.extend(new_artists)
     request.registry.notify(ActivityExecuted(self, objects, get_current()))
     return {}
예제 #6
0
 def start(self, context, request, appstruct, **kw):
     root = getSite()
     user = get_current()
     artists, new_artists = extract_artists(
         appstruct.get('artists', []), request)
     directors, new_directors = extract_artists(
         appstruct.get('directors', []),
         request, is_directors=True)
     newreview = appstruct[OBJECT_DATA]
     root.addtoproperty('reviews', newreview)
     newreview.setproperty('artists', artists)
     newreview.setproperty('directors', directors)
     newreview.state.append('editable')
     grant_roles(user=user, roles=(('Owner', newreview), ))
     newreview.setproperty('author', user)
     newreview.set_metadata(appstruct)
     newreview.reindex()
     new_objects = new_artists
     new_objects.extend(new_directors)
     new_objects.append(newreview)
     request.registry.notify(ActivityExecuted(self, new_objects, user))
     return {'newcontext': newreview}
예제 #7
0
 def start(self, context, request, appstruct, **kw):
     root = getSite()
     user = get_current()
     artists, new_artists = extract_artists(
         appstruct.get('artists', []), request)
     directors, new_directors = extract_artists(
         appstruct.get('directors', []),
         request, is_directors=True)
     newfilmsynopses = appstruct[OBJECT_DATA]
     root.addtoproperty('reviews', newfilmsynopses)
     newfilmsynopses.state.append('draft')
     newfilmsynopses.setproperty('artists', artists)
     newfilmsynopses.setproperty('directors', directors)
     grant_roles(roles=(('Owner', newfilmsynopses), ))
     newfilmsynopses.setproperty('author', user)
     newfilmsynopses.set_metadata(appstruct)
     newfilmsynopses.reindex()
     new_objects = new_artists
     new_objects.extend(new_directors)
     new_objects.append(newfilmsynopses)
     request.registry.notify(ActivityExecuted(self, new_objects, user))
     return {'newcontext': newfilmsynopses}
예제 #8
0
    def start(self, context, request, appstruct, **kw):
        user = get_current()
        artists, new_artists = extract_artists(appstruct.pop('artists', []),
                                               request)
        directors, new_directors = extract_artists(appstruct.pop(
            'directors', []),
                                                   request,
                                                   is_directors=True)
        appstruct.pop('artists_ids')
        appstruct.pop('directors_ids')
        if appstruct.get('picture', None) is not None and \
            OBJECT_DATA in appstruct['picture']:
            appstruct['picture'] = appstruct['picture'][OBJECT_DATA]
            if not getattr(appstruct['picture'], '__name__', None):
                appstruct['picture'].__name__ = 'picture'

        context.set_metadata(appstruct)
        context.set_data(appstruct)
        context.setproperty('artists', artists)
        context.setproperty('directors', directors)
        context.modified_at = datetime.datetime.now(tz=pytz.UTC)
        if 'published' in context.state:
            not_published_artists = [
                a for a in context.artists if 'published' not in a.state
            ]
            not_published_artists.extend(
                [a for a in context.directors if 'published' not in a.state])
            for artist in not_published_artists:
                publish_artist(artist, request, user)

        context.reindex()
        new_objects = new_artists
        new_objects.extend(new_directors)
        new_objects.append(context)
        request.registry.notify(ActivityExecuted(self, new_objects, user))
        return {}
예제 #9
0
 def start(self, context, request, appstruct, **kw):
     root = getSite()
     user = get_current()
     artists, new_artists = extract_artists(appstruct.get('artists', []),
                                            request)
     newreview = appstruct[OBJECT_DATA]
     root.addtoproperty('reviews', newreview)
     newreview.setproperty('artists', artists)
     newreview.state.append('editable')
     grant_roles(user=user, roles=(('Owner', newreview), ))
     newreview.setproperty('author', user)
     newreview.set_metadata(appstruct)
     newreview.reindex()
     new_objects = new_artists
     new_objects.append(newreview)
     request.registry.notify(ActivityExecuted(self, new_objects, user))
     return {'newcontext': newreview}
예제 #10
0
    def start(self, context, request, appstruct, **kw):
        user = get_current()
        artists, new_artists = extract_artists(
            appstruct.get('artists', []), request)
        context.setproperty('artists', artists)
        context.modified_at = datetime.datetime.now(tz=pytz.UTC)
        context.set_metadata(appstruct)
        if 'published' in context.state:
            not_published_artists = [a for a in context.artists
                                     if 'published' not in a.state]
            for artist in not_published_artists:
                publish_artist(artist, request, user)

        context.reindex()
        new_objects = new_artists
        new_objects.append(context)
        request.registry.notify(ActivityExecuted(self, new_objects, user))
        return {}
예제 #11
0
    def start(self, context, request, appstruct, **kw):
        user = get_current()
        artists, new_artists = extract_artists(appstruct.get('artists', []),
                                               request)
        context.setproperty('artists', artists)
        context.modified_at = datetime.datetime.now(tz=pytz.UTC)
        context.set_metadata(appstruct)
        if 'published' in context.state:
            not_published_artists = [
                a for a in context.artists if 'published' not in a.state
            ]
            for artist in not_published_artists:
                publish_artist(artist, request, user)

        context.reindex()
        new_objects = new_artists
        new_objects.append(context)
        request.registry.notify(ActivityExecuted(self, new_objects, user))
        return {}