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


Python ActivityLog.details方法代码示例

本文整理汇总了Python中devhub.models.ActivityLog.details方法的典型用法代码示例。如果您正苦于以下问题:Python ActivityLog.details方法的具体用法?Python ActivityLog.details怎么用?Python ActivityLog.details使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在devhub.models.ActivityLog的用法示例。


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

示例1: log

# 需要导入模块: from devhub.models import ActivityLog [as 别名]
# 或者: from devhub.models.ActivityLog import details [as 别名]
def log(action, *args, **kw):
    """
    e.g. amo.log(amo.LOG.CREATE_ADDON, []),
         amo.log(amo.LOG.ADD_FILE_TO_VERSION, file, version)
    """
    from addons.models import Addon
    from amo import get_user, logger_log
    from devhub.models import (ActivityLog, AddonLog, AppLog, UserLog,
                               CommentLog, VersionLog)
    from mkt.webapps.models import Webapp
    from users.models import UserProfile
    from versions.models import Version

    user = kw.get('user', get_user())

    if not user:
        logger_log.warning('Activity log called with no user: %s' % action.id)
        return

    al = ActivityLog(user=user, action=action.id)
    al.arguments = args
    if 'details' in kw:
        al.details = kw['details']
    al.save()

    if 'details' in kw and 'comments' in al.details:
        CommentLog(comments=al.details['comments'], activity_log=al).save()

    # TODO(davedash): post-remora this may not be necessary.
    if 'created' in kw:
        al.created = kw['created']
        # Double save necessary since django resets the created date on save.
        al.save()

    for arg in args:
        if isinstance(arg, tuple):
            if arg[0] == Webapp:
                AppLog(addon_id=arg[1], activity_log=al).save()
            elif arg[0] == Addon:
                AddonLog(addon_id=arg[1], activity_log=al).save()
            elif arg[0] == Version:
                VersionLog(version_id=arg[1], activity_log=al).save()
            elif arg[0] == UserProfile:
                UserLog(user_id=arg[1], activity_log=al).save()

        # Webapp first since Webapp subclasses Addon.
        if isinstance(arg, Webapp):
            AppLog(addon=arg, activity_log=al).save()
        elif isinstance(arg, Addon):
            AddonLog(addon=arg, activity_log=al).save()
        elif isinstance(arg, Version):
            VersionLog(version=arg, activity_log=al).save()
        elif isinstance(arg, UserProfile):
            # Index by any user who is mentioned as an argument.
            UserLog(activity_log=al, user=arg).save()

    # Index by every user
    UserLog(activity_log=al, user=user).save()
    return al
开发者ID:akashsinha,项目名称:zamboni,代码行数:61,代码来源:log.py

示例2: log

# 需要导入模块: from devhub.models import ActivityLog [as 别名]
# 或者: from devhub.models.ActivityLog import details [as 别名]
def log(action, *args, **kw):
    """
    e.g. amo.log(amo.LOG.CREATE_ADDON, []),
         amo.log(amo.LOG.ADD_FILE_TO_VERSION, file, version)
    """
    from access.models import Group
    from addons.models import Addon
    from amo import get_user, logger_log
    from devhub.models import ActivityLog, AddonLog, CommentLog, GroupLog, UserLog, VersionLog
    from users.models import UserProfile
    from versions.models import Version

    user = kw.get("user", get_user())

    if not user:
        logger_log.warning("Activity log called with no user: %s" % action.id)
        return

    al = ActivityLog(user=user, action=action.id)
    al.arguments = args
    if "details" in kw:
        al.details = kw["details"]
    al.save()

    if "details" in kw and "comments" in al.details:
        CommentLog(comments=al.details["comments"], activity_log=al).save()

    # TODO(davedash): post-remora this may not be necessary.
    if "created" in kw:
        al.created = kw["created"]
        # Double save necessary since django resets the created date on save.
        al.save()

    for arg in args:
        if isinstance(arg, tuple):
            if arg[0] == Addon:
                AddonLog(addon_id=arg[1], activity_log=al).save()
            elif arg[0] == Version:
                VersionLog(version_id=arg[1], activity_log=al).save()
            elif arg[0] == UserProfile:
                UserLog(user_id=arg[1], activity_log=al).save()
            elif arg[0] == Group:
                GroupLog(group_id=arg[1], activity_log=al).save()
        elif isinstance(arg, Addon):
            AddonLog(addon=arg, activity_log=al).save()
        elif isinstance(arg, Version):
            VersionLog(version=arg, activity_log=al).save()
        elif isinstance(arg, UserProfile):
            # Index by any user who is mentioned as an argument.
            UserLog(activity_log=al, user=arg).save()
        elif isinstance(arg, Group):
            GroupLog(group=arg, activity_log=al).save()

    # Index by every user
    UserLog(activity_log=al, user=user).save()
    return al
开发者ID:rakeshchandra1,项目名称:olympia,代码行数:58,代码来源:log.py

示例3: log

# 需要导入模块: from devhub.models import ActivityLog [as 别名]
# 或者: from devhub.models.ActivityLog import details [as 别名]
def log(action, *args, **kw):
    """
    e.g. amo.log(amo.LOG.CREATE_ADDON, []),
         amo.log(amo.LOG.ADD_FILE_TO_VERSION, file, version)
    """
    from addons.models import Addon
    from amo import get_user, logger_log
    from devhub.models import (ActivityLog, ActivityLogAttachment, AddonLog,
                               AppLog, CommentLog, UserLog, VersionLog)
    from mkt.webapps.models import Webapp
    from users.models import UserProfile
    from versions.models import Version

    user = kw.get('user', get_user())

    if not user:
        logger_log.warning('Activity log called with no user: %s' % action.id)
        return

    al = ActivityLog(user=user, action=action.id)
    al.arguments = args
    if 'details' in kw:
        al.details = kw['details']
    al.save()

    if 'details' in kw and 'comments' in al.details:
        CommentLog(comments=al.details['comments'], activity_log=al).save()

    # TODO(davedash): post-remora this may not be necessary.
    if 'created' in kw:
        al.created = kw['created']
        # Double save necessary since django resets the created date on save.
        al.save()

    if 'attachments' in kw:
        formset = kw['attachments']
        storage = get_storage_class()()
        for form in formset:
            data = form.cleaned_data
            if 'attachment' in data:
                attachment = data['attachment']
                storage.save('%s/%s' % (settings.REVIEWER_ATTACHMENTS_PATH,
                                        attachment.name), attachment)
                ActivityLogAttachment(activity_log=al,
                                      description=data['description'],
                                      mimetype=attachment.content_type,
                                      filepath=attachment.name).save()

    for arg in args:
        if isinstance(arg, tuple):
            if arg[0] == Webapp:
                AppLog(addon_id=arg[1], activity_log=al).save()
            elif arg[0] == Addon:
                AddonLog(addon_id=arg[1], activity_log=al).save()
            elif arg[0] == Version:
                VersionLog(version_id=arg[1], activity_log=al).save()
            elif arg[0] == UserProfile:
                UserLog(user_id=arg[1], activity_log=al).save()

        # Webapp first since Webapp subclasses Addon.
        if isinstance(arg, Webapp):
            AppLog(addon=arg, activity_log=al).save()
        elif isinstance(arg, Addon):
            AddonLog(addon=arg, activity_log=al).save()
        elif isinstance(arg, Version):
            VersionLog(version=arg, activity_log=al).save()
        elif isinstance(arg, UserProfile):
            # Index by any user who is mentioned as an argument.
            UserLog(activity_log=al, user=arg).save()

    # Index by every user
    UserLog(activity_log=al, user=user).save()
    return al
开发者ID:MaxDumont,项目名称:zamboni,代码行数:75,代码来源:log.py


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