Exemplo n.º 1
0
    def on_updated(self, updates, original):
        get_resource_service('archive_autosave').delete_action({'_id': original['_id']})
        on_update_media_archive()

        if '_version' in updates:
            add_activity('created new version {{ version }} for item {{ type }} about {{ subject }}',
                         version=updates['_version'], subject=get_subject(updates, original))
Exemplo n.º 2
0
 def on_created(self, docs):
     for doc in docs:
         push_notification('item:comment', item=str(doc.get('item')))
         mentioned_users = doc.get('mentioned_users', {}).values()
         add_activity('', type='comment', item=str(doc.get('item')),
                      comment=doc.get('text'), comment_id=str(doc.get('_id')),
                      notify=mentioned_users)
Exemplo n.º 3
0
    def on_create(self, docs):
        ''' Create corresponding item on file upload '''
        for doc in docs:
            file, content_type, metadata = self.get_file_from_document(doc)
            inserted = [doc['media']]
            file_type = content_type.split('/')[0]

            try:
                update_dates_for(doc)
                doc['guid'] = generate_guid(type=GUID_TAG)
                doc.setdefault('_id', doc['guid'])
                doc['type'] = self.type_av.get(file_type)
                doc['version'] = 1
                doc['versioncreated'] = utcnow()
                rendition_spec = config.RENDITIONS['picture']
                renditions = generate_renditions(file, doc['media'], inserted, file_type,
                                                 content_type, rendition_spec, url_for_media)
                doc['renditions'] = renditions
                doc['mimetype'] = content_type
                doc['filemeta'] = metadata
                if not doc.get('_import', None):
                    doc['creator'] = set_user(doc)

                add_activity('uploaded media {{ name }}',
                             name=doc.get('headline', doc.get('mimetype')),
                             renditions=doc.get('renditions'))

            except Exception as io:
                logger.exception(io)
                for file_id in inserted:
                    delete_file_on_error(doc, file_id)
                abort(500)
        on_create_media_archive()
Exemplo n.º 4
0
    def on_updated(self, updates, original):
        c = get_component(ItemAutosave)
        c.clear(original['_id'])
        on_update_media_archive()

        if '_version' in updates:
            add_activity('created new version {{ version }} for item {{ type }} about {{ subject }}',
                         version=updates['_version'], subject=get_subject(updates, original))
Exemplo n.º 5
0
    def on_updated(self, updates, original):
        c = get_component(ItemAutosave)
        c.clear(original['_id'])
        on_update_media_archive()

        if '_version' in updates:
            add_activity(
                'created new version {{ version }} for item {{ type }} about {{ subject }}',
                version=updates['_version'],
                subject=get_subject(updates, original))
Exemplo n.º 6
0
 def on_created(self, docs):
     on_create_media_archive()
     for doc in docs:
         add_activity('added new item {{ type }} about {{ subject }}',
                      type=doc['type'], subject=get_subject(doc))
Exemplo n.º 7
0
 def on_deleted(self, doc):
     on_delete_media_archive()
     add_activity('removed item {{ type }} about {{ subject }}',
                  type=doc['type'], subject=get_subject(doc))
Exemplo n.º 8
0
 def on_deleted(self, doc):
     add_activity('removed user {{user}}', user=doc.get('display_name', doc.get('username')))
Exemplo n.º 9
0
 def on_created(self, docs):
     for doc in docs:
         add_activity('created user {{user}}', user=doc.get('display_name', doc.get('username')))
Exemplo n.º 10
0
 def on_created(self, docs):
     on_create_media_archive()
     for doc in docs:
         add_activity('added new item {{ type }} about {{ subject }}',
                      type=doc['type'],
                      subject=get_subject(doc))
Exemplo n.º 11
0
 def on_deleted(self, doc):
     on_delete_media_archive()
     add_activity('removed item {{ type }} about {{ subject }}',
                  type=doc['type'],
                  subject=get_subject(doc))
Exemplo n.º 12
0
 def on_deleted(self, doc):
     add_activity("removed user {{user}}", user=doc.get("display_name", doc.get("username")))
Exemplo n.º 13
0
 def on_created(self, docs):
     for doc in docs:
         add_activity("created user {{user}}", user=doc.get("display_name", doc.get("username")))
Exemplo n.º 14
0
 def on_deleted(self, doc):
     add_activity('removed user {{user}}', user=doc.get('display_name', doc.get('username')))
Exemplo n.º 15
0
 def on_created(self, docs):
     for doc in docs:
         add_activity('created user {{user}}', user=doc.get('display_name', doc.get('username')))