當前位置: 首頁>>代碼示例>>Python>>正文


Python models.ActivityLog類代碼示例

本文整理匯總了Python中devhub.models.ActivityLog的典型用法代碼示例。如果您正苦於以下問題:Python ActivityLog類的具體用法?Python ActivityLog怎麽用?Python ActivityLog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ActivityLog類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_json_failboat

 def test_json_failboat(self):
     request = self.request
     a = Addon.objects.get()
     ActivityLog.log(request, amo.LOG['CREATE_ADDON'], a)
     entry = ActivityLog.objects.get()
     entry._arguments = 'failboat?'
     entry.save()
     eq_(entry.arguments, None)
開發者ID:ozten,項目名稱:zamboni,代碼行數:8,代碼來源:test_models.py

示例2: test_pseudo_objects

 def test_pseudo_objects(self):
     """
     If we give an argument of (Addon, 3615) ensure we get
     Addon.objects.get(pk=3615).
     """
     a = ActivityLog()
     a.arguments = [(Addon, 3615)]
     eq_(a.arguments[0], Addon.objects.get(pk=3615))
開發者ID:aspes,項目名稱:zamboni,代碼行數:8,代碼來源:test_models.py

示例3: test_basic

 def test_basic(self):
     request = self.request
     a = Addon.objects.get()
     ActivityLog.log(request, amo.LOG['CREATE_ADDON'], a)
     entries = ActivityLog.objects.for_addon(a)
     eq_(len(entries), 1)
     eq_(entries[0].arguments[0], a)
     eq_(unicode(entries[0]),
         'Joe CamelCase created addon Delicious Bookmarks')
開發者ID:ozten,項目名稱:zamboni,代碼行數:9,代碼來源:test_models.py

示例4: test_user_log_as_argument

 def test_user_log_as_argument(self):
     """
     Tests that a user that has something done to them gets into the user
     log.
     """
     request = self.request
     u = UserProfile(username='Marlboro Manatee')
     u.save()
     ActivityLog.log(request, amo.LOG['ADD_USER_WITH_ROLE'],
             (u, 'developer', Addon.objects.get()))
     entries = ActivityLog.objects.for_user(request.amo_user)
     eq_(len(entries), 1)
     entries = ActivityLog.objects.for_user(u)
     eq_(len(entries), 1)
開發者ID:ozten,項目名稱:zamboni,代碼行數:14,代碼來源:test_models.py

示例5: log

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,代碼行數:59,代碼來源:log.py

示例6: log

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,代碼行數:56,代碼來源:log.py

示例7: log

def log(action, *args, **kw):
    """
    e.g. amo.log(amo.LOG.CREATE_ADDON, []),
         amo.log(amo.LOG.ADD_FILE_TO_VERSION, file, version)
    """
    from devhub.models import ActivityLog, AddonLog, UserLog
    from addons.models import Addon
    from users.models import UserProfile
    from amo import get_user, logger_log

    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
    al.save()
    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] == UserProfile:
                AddonLog(user_id=arg[1], activity_log=al).save()
        if isinstance(arg, Addon):
            AddonLog(addon=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()
開發者ID:exezaid,項目名稱:zamboni,代碼行數:38,代碼來源:log.py

示例8: test_bad_arguments

 def test_bad_arguments(self):
     a = ActivityLog()
     a.arguments = []
     a.action = amo.LOG.ADD_USER_WITH_ROLE.id
     eq_(a.to_string(), 'Something magical happened.')
開發者ID:aspes,項目名稱:zamboni,代碼行數:5,代碼來源:test_models.py

示例9: log

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,代碼行數:73,代碼來源:log.py

示例10: test_user_log

 def test_user_log(self):
     request = self.request
     ActivityLog.log(request, amo.LOG['CUSTOM_TEXT'], 'hi there')
     entries = ActivityLog.objects.for_user(request.amo_user)
     eq_(len(entries), 1)
開發者ID:ozten,項目名稱:zamboni,代碼行數:5,代碼來源:test_models.py

示例11: test_output

 def test_output(self):
     request = self.request
     ActivityLog.log(request, amo.LOG['CUSTOM_TEXT'], 'hi there')
     entry = ActivityLog.objects.get()
     eq_(unicode(entry), 'hi there')
開發者ID:ozten,項目名稱:zamboni,代碼行數:5,代碼來源:test_models.py

示例12: test_no_arguments

 def test_no_arguments(self):
     request = self.request
     ActivityLog.log(request, amo.LOG['CUSTOM_HTML'])
     entry = ActivityLog.objects.get()
     eq_(entry.arguments, [])
開發者ID:ozten,項目名稱:zamboni,代碼行數:5,代碼來源:test_models.py


注:本文中的devhub.models.ActivityLog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。