当前位置: 首页>>代码示例>>Python>>正文


Python activity.add_activity函数代码示例

本文整理汇总了Python中superdesk.activity.add_activity函数的典型用法代码示例。如果您正苦于以下问题:Python add_activity函数的具体用法?Python add_activity怎么用?Python add_activity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了add_activity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_updated

 def on_updated(self, updates, original):
     push_notification(self.datasource, updated=1)
     updated = copy(original)
     updated.update(updates)
     if updated.get('task') and updated['task'].get('desk'):
         add_activity(ACTIVITY_UPDATE, 'updated task {{ subject }} for item {{ type }}',
                      item=updated, subject=get_subject(updated))
开发者ID:plaindocs,项目名称:superdesk-server,代码行数:7,代码来源:tasks.py

示例2: on_create

    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()
开发者ID:PythonCharmers,项目名称:superdesk-server,代码行数:33,代码来源:archive_media.py

示例3: on_created

    def on_created(self, docs):
        packages = [doc for doc in docs if doc[ITEM_TYPE] == CONTENT_TYPE.COMPOSITE]
        if packages:
            self.packageService.on_created(packages)

        profiles = set()
        for doc in docs:
            subject = get_subject(doc)
            if subject:
                msg = 'added new {{ type }} item about "{{ subject }}"'
            else:
                msg = 'added new {{ type }} item with empty header/title'
            add_activity(ACTIVITY_CREATE, msg,
                         self.datasource, item=doc, type=doc[ITEM_TYPE], subject=subject)

            if doc.get('profile'):
                profiles.add(doc['profile'])

            self.cropService.update_media_references(doc, {})
            if doc[ITEM_OPERATION] == ITEM_FETCH:
                app.on_archive_item_updated({'task': doc.get('task')}, doc, ITEM_FETCH)
            else:
                app.on_archive_item_updated({'task': doc.get('task')}, doc, ITEM_CREATE)

        get_resource_service('content_types').set_used(profiles)
        push_content_notification(docs)
开发者ID:jerome-poisson,项目名称:superdesk-core,代码行数:26,代码来源:archive.py

示例4: on_replaced

 def on_replaced(self, document, original):
     get_component(ItemAutosave).clear(original['_id'])
     add_activity(ACTIVITY_UPDATE, 'replaced item {{ type }} about {{ subject }}',
                  self.datasource, item=original,
                  type=original['type'], subject=get_subject(original))
     push_content_notification([document, original])
     self.cropService.update_media_references(document, original)
开发者ID:jerome-poisson,项目名称:superdesk-core,代码行数:7,代码来源:archive.py

示例5: on_create

    def on_create(self, docs):
        """Create corresponding item on file upload."""

        for doc in docs:
            if 'media' not in doc or doc['media'] is None:
                abort(400, description="No media found")

            file, content_type, metadata = self.get_file_from_document(doc)
            inserted = [doc['media']]
            file_type = content_type.split('/')[0]

            self._set_metadata(doc)

            try:
                doc[ITEM_TYPE] = self.type_av.get(file_type)
                rendition_spec = get_renditions_spec()
                renditions = generate_renditions(file, doc['media'], inserted, file_type,
                                                 content_type, rendition_spec, url_for_media)
                doc['renditions'] = renditions
                doc['mimetype'] = content_type
                set_filemeta(doc, metadata)

                add_activity('upload', 'uploaded media {{ name }}',
                             'archive', item=doc,
                             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)
开发者ID:hlmnrmr,项目名称:superdesk-core,代码行数:31,代码来源:archive_media.py

示例6: on_updated

    def on_updated(self, updates, original):
        updated = copy(original)
        updated.update(updates)
        if self._stage_changed(updates, original):
            insert_into_versions(doc=updated)
        new_task = updates.get("task", {})
        old_task = original.get("task", {})
        if new_task.get("stage") != old_task.get("stage"):
            push_notification(
                "task:stage",
                new_stage=str(new_task.get("stage", "")),
                old_stage=str(old_task.get("stage", "")),
                new_desk=str(new_task.get("desk", "")),
                old_desk=str(old_task.get("desk", "")),
            )
        else:
            push_notification(self.datasource, updated=1)

        if is_assigned_to_a_desk(updated):
            if self.__is_content_assigned_to_new_desk(original, updates) and not self._stage_changed(updates, original):
                insert_into_versions(doc=updated)
            add_activity(
                ACTIVITY_UPDATE,
                "updated task {{ subject }} for item {{ type }}",
                self.datasource,
                item=updated,
                subject=get_subject(updated),
                type=updated["type"],
            )
开发者ID:verifiedpixel,项目名称:superdesk,代码行数:29,代码来源:tasks.py

示例7: __send_notification

    def __send_notification(self, updates, user):
        user_id = user['_id']

        if 'is_enabled' in updates and not updates['is_enabled']:
            push_notification('user_disabled', updated=1, user_id=str(user_id))
        elif 'is_active' in updates and not updates['is_active']:
            push_notification('user_inactivated', updated=1, user_id=str(user_id))
        elif 'role' in updates:
            push_notification('user_role_changed', updated=1, user_id=str(user_id))
        elif 'privileges' in updates:
            added, removed, modified = compare_preferences(user.get('privileges', {}), updates['privileges'])
            if len(removed) > 0 or (1, 0) in modified.values():
                push_notification('user_privileges_revoked', updated=1, user_id=str(user_id))
            if len(added) > 0:
                add_activity(ACTIVITY_UPDATE,
                             'user {{user}} is granted new privileges: Please re-login.',
                             self.datasource,
                             notify=[user_id],
                             user=user.get('display_name', user.get('username')))
        elif 'user_type' in updates:
            if not is_admin(updates):
                push_notification('user_type_changed', updated=1, user_id=str(user_id))
            else:
                add_activity(ACTIVITY_UPDATE,
                             'user {{user}} is updated to administrator: Please re-login.',
                             self.datasource,
                             notify=[user_id],
                             user=user.get('display_name', user.get('username')))
        else:
            push_notification('user', updated=1, user_id=str(user_id))
开发者ID:mscam,项目名称:superdesk-core,代码行数:30,代码来源:services.py

示例8: on_replaced

 def on_replaced(self, document, original):
     get_component(ItemAutosave).clear(original['_id'])
     add_activity(ACTIVITY_UPDATE, 'replaced item {{ type }} about {{ subject }}',
                  self.datasource, item=original,
                  type=original['type'], subject=get_subject(original))
     user = get_user()
     push_notification('item:replaced', item=str(original['_id']), user=str(user.get('_id')))
开发者ID:jey07ro,项目名称:superdesk,代码行数:7,代码来源:archive.py

示例9: notify_mentioned_users

def notify_mentioned_users(docs, origin):
    for doc in docs:
        mentioned_users = doc.get('mentioned_users', {}).values()
        add_activity('notify', '', type='comment', item=doc,
                     comment=doc.get('text'), comment_id=str(doc.get('_id')),
                     notify=mentioned_users)
        send_email_to_mentioned_users(doc, mentioned_users, origin)
开发者ID:auliakausar,项目名称:superdesk-server,代码行数:7,代码来源:user_mentions.py

示例10: on_created

 def on_created(self, docs):
     push_notification(self.datasource, created=1)
     for doc in docs:
         insert_into_versions(doc['_id'])
         if self.__is_assigned_to_a_desk(doc):
             add_activity(ACTIVITY_CREATE, 'added new task {{ subject }} of type {{ type }}', item=doc,
                          subject=get_subject(doc), type=doc['type'])
开发者ID:vied12,项目名称:superdesk-server,代码行数:7,代码来源:tasks.py

示例11: on_updated

    def on_updated(self, updates, original):
        get_component(ItemAutosave).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))
开发者ID:rolpro,项目名称:superdesk-server,代码行数:7,代码来源:archive.py

示例12: notify_the_owner

def notify_the_owner(doc, origin):
    if not get_user():
        logger.info('there is no logged in user so no membership is allowed')
    else:
        blog = get_resource_service('blogs').find_one(req=None, _id=doc.get('blog'))
        owner = blog.get('original_creator')
        add_activity('notify', 'one user requested liveblog membership', resource=None, item=doc, notify=str(owner))
        send_email_to_owner(doc, owner, origin)
开发者ID:4D4M-W34V3R,项目名称:liveblog,代码行数:8,代码来源:request_membership.py

示例13: notify_mentioned_users

def notify_mentioned_users(docs, origin):
    for doc in docs:
        mentioned_users = doc.get('mentioned_users', {}).values()
        item = superdesk.get_resource_service('archive').find_one(req=None, _id=doc['item'])
        add_activity('notify', '', type='comment', item=item,
                     comment=doc.get('text'), comment_id=str(doc.get('_id')),
                     notify=mentioned_users)
        send_email_to_mentioned_users(doc, mentioned_users, origin)
开发者ID:vied12,项目名称:superdesk-server,代码行数:8,代码来源:user_mentions.py

示例14: notify_mentioned_desks

def notify_mentioned_desks(docs):
    for doc in docs:
        mentioned_desks = doc.get('mentioned_desks', {}).values()
        if len(mentioned_desks) > 0:
            item = superdesk.get_resource_service('archive').find_one(req=None, _id=doc['item'])
            add_activity('desk:mention', '', resource=None, type='comment', item=item,
                         comment=doc.get('text'), comment_id=str(doc.get('_id')),
                         notify_desks=mentioned_desks)
开发者ID:nistormihai,项目名称:superdesk-core,代码行数:8,代码来源:user_mentions.py

示例15: on_deleted

 def on_deleted(self, doc):
     if doc['type'] == 'composite':
         self.packageService.on_deleted(doc)
     add_activity(ACTIVITY_DELETE, 'removed item {{ type }} about {{ subject }}',
                  self.datasource, item=doc,
                  type=doc['type'], subject=get_subject(doc))
     user = get_user()
     push_notification('item:deleted', item=str(doc['_id']), user=str(user.get('_id')))
开发者ID:jey07ro,项目名称:superdesk,代码行数:8,代码来源:archive.py


注:本文中的superdesk.activity.add_activity函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。