Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
bug 625830, log to AddonLog as well
Browse files Browse the repository at this point in the history
  • Loading branch information
davedash committed Jan 14, 2011
1 parent 600122b commit bf7b983
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions apps/amo/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,17 @@ class CHANGE_LICENSE:
id = 37
format = _(u'{addon} is now licensed under {0.name}.')


class CHANGE_POLICY:
id = 38
format = _(u'{addon} policy changed.')


class CHANGE_ICON:
id = 39
format = _(u'{addon} icon changed.')


class CUSTOM_TEXT:
id = 98
format = '{0}'
Expand Down Expand Up @@ -295,6 +298,11 @@ def log(action, *args, **kw):
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):
Expand Down
10 changes: 9 additions & 1 deletion apps/devhub/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import amo
from addons.models import Addon, AddonUser
from bandwagon.models import Collection
from devhub.models import ActivityLog
from devhub.models import ActivityLog, AddonLog
from tags.models import Tag
from files.models import File
from reviews.models import Review
Expand Down Expand Up @@ -52,6 +52,14 @@ def test_pseudo_objects(self):
a.arguments = [(Addon, 3615)]
eq_(a.arguments[0], Addon.objects.get(pk=3615))

def test_addon_logging_pseudo(self):
"""
If we are given (Addon, 3615) it should log in the AddonLog as well.
"""
a = Addon.objects.get()
amo.log(amo.LOG.CREATE_ADDON, (Addon, a.id))
eq_(AddonLog.objects.count(), 1)

def test_fancy_rendering(self):
"""HTML for Review, and Collection."""
a = ActivityLog.objects.create(action=amo.LOG.ADD_REVIEW.id)
Expand Down

0 comments on commit bf7b983

Please sign in to comment.