sprinkle more logging around (bug 754023)

This commit is contained in:
Andy McKay 2012-05-31 12:04:31 -07:00
Родитель d42bb17c5e
Коммит d820e6283b
3 изменённых файлов: 33 добавлений и 2 удалений

Просмотреть файл

@ -414,6 +414,26 @@ class REFUND_INSTANT(_LOG):
format = _(u'Instant refund granted for {addon}.')
class USER_EDITED(_LOG):
id = 60
format = _(u'Account updated.')
class PREAPPROVAL_ADDED(_LOG):
id = 62
format = _(u'Pre approval added.')
class PREAPPROVAL_REMOVED(_LOG):
id = 63
format = _(u'Pre-approval removed.')
class CURRENCY_UPDATED(_LOG):
id = 64
format = _('Account currency changed')
class CUSTOM_TEXT(_LOG):
id = 98
format = '{0}'

Просмотреть файл

@ -84,7 +84,8 @@ class TestAccountSettings(amo.tests.TestCase):
r = self.client.post(self.url, self.data, follow=True)
self.assertRedirects(r, self.url)
doc = pq(r.content)
eq_((ActivityLog.objects.filter(action=amo.LOG.USER_EDITED.id)
.count()), 1)
# Check that the values got updated appropriately.
user = self.get_user()
for field, expected in self.extra_data.iteritems():
@ -274,6 +275,8 @@ class TestPreapproval(amo.tests.TestCase):
eq_(self.client.post(self.currency_url,
{'currency': 'USD'}).status_code, 302)
eq_(self.user.get_preapproval().currency, 'USD')
eq_((ActivityLog.objects.filter(action=amo.LOG.CURRENCY_UPDATED.id)
.count()), 1)
def test_extra_currency(self):
price = Price.objects.create(price='1')
@ -339,6 +342,8 @@ class TestPreapproval(amo.tests.TestCase):
# Check that re-loading doesn't error.
res = self.client.post(self.get_url('complete'))
eq_(res.status_code, 200)
eq_((ActivityLog.objects.filter(action=amo.LOG.PREAPPROVAL_ADDED.id)
.count()), 1)
def test_preapproval_cancel(self):
PreApprovalUser.objects.create(user=self.user, paypal_key='xyz')
@ -371,6 +376,8 @@ class TestPreapproval(amo.tests.TestCase):
eq_(self.user.preapprovaluser.paypal_key, '')
eq_(pq(res.content)('#preapproval').attr('action'),
reverse('account.payment.preapproval'))
eq_((ActivityLog.objects.filter(action=amo.LOG.PREAPPROVAL_REMOVED.id)
.count()), 1)
class TestProfileLinks(amo.tests.TestCase):

Просмотреть файл

@ -56,7 +56,7 @@ def payment(request, status=None):
if 'setup-preapproval' in request.session:
paypal_log.info(u'Preapproval key created for user: %s, %s.' %
(request.amo_user.pk, data['key'][:5]))
amo.log(amo.LOG.PREAPPROVAL_ADDED)
pre.update(paypal_key=data.get('key'),
paypal_expiry=data.get('expiry'))
@ -82,6 +82,7 @@ def payment(request, status=None):
# The user has an pre approval key set and chooses to remove it
if pre.paypal_key:
pre.update(paypal_key='')
amo.log(amo.LOG.PREAPPROVAL_REMOVED)
messages.success(request,
_('Your payment pre-approval has been disabled.'))
paypal_log.info(u'Preapproval key removed for user: %s'
@ -102,6 +103,7 @@ def currency(request, do_redirect=True):
pre.update(currency=currency.cleaned_data['currency'])
if do_redirect:
messages.success(request, _('Currency saved.'))
amo.log(amo.LOG.CURRENCY_UPDATED)
return redirect(reverse('account.payment'))
else:
return jingo.render(request, 'account/payment.html',
@ -216,6 +218,7 @@ def account_settings(request):
if form.is_valid():
form.save()
messages.success(request, _('Profile Updated'))
amo.log(amo.LOG.USER_EDITED)
return redirect('account.settings')
else:
messages.form_errors(request)
@ -257,6 +260,7 @@ def delete_photo(request):
delete_photo_task.delay(request.amo_user.picture_path)
log.debug(u'User (%s) deleted photo' % request.amo_user)
messages.success(request, _('Photo Deleted'))
amo.log(amo.LOG.ACCOUNT_UPDATED)
return http.HttpResponse()