Add more detail to review moderation log entries (bug 523390)

This commit is contained in:
Gregory Koberger 2011-05-19 13:53:17 -07:00
Родитель 10fc97b289
Коммит 7d424845b6
3 изменённых файлов: 30 добавлений и 4 удалений

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

@ -333,7 +333,7 @@ class DELETE_REVIEW(_LOG):
id = 41
action_class = 'review'
format = _(u'Review {0} for {addon} deleted.')
editor_format = _(u'{user} deleted review {0}.')
editor_format = _(u'{user} deleted {0} for {addon}.')
keep = True
editor_event = True

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

@ -252,11 +252,29 @@ class TestHome(EditorTest):
def test_deleted_review(self):
review = self.make_review()
amo.log(amo.LOG.DELETE_REVIEW, review.id, review.addon)
amo.log(amo.LOG.DELETE_REVIEW, review.id, review.addon,
details=dict(addon_name='test', addon_id=review.addon.pk,
is_flagged=True))
r = self.client.get(reverse('editors.home'))
doc = pq(r.content)
eq_(doc('.row').eq(0).text().strip().split('.')[0],
'editor deleted review %d' % review.id)
'editor deleted %d for yermom ' % review.id)
al_id = ActivityLog.objects.all()[0].id
url = reverse('editors.eventlog.detail', args=[al_id])
doc = pq(self.client.get(url).content)
dts = doc('dt')
dds = doc('dd')
eq_(dts.eq(0).text(), "is_flagged")
eq_(dds.eq(0).text(), "True")
eq_(dts.eq(1).text(), "addon_id")
eq_(dds.eq(1).text(), str(review.addon.pk))
eq_(dts.eq(2).text(), "addon_name")
eq_(dds.eq(2).text(), "test")
def test_stats_total(self):
self.approve_reviews()

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

@ -43,6 +43,8 @@ class BaseReviewFlagFormSet(BaseModelFormSet):
if form.cleaned_data:
action = int(form.cleaned_data['action'])
is_flagged = (form.instance.reviewflag_set.count() > 0)
if action != reviews.REVIEW_MODERATE_SKIP: # Delete flags.
for flag in form.instance.reviewflag_set.all():
flag.delete()
@ -52,9 +54,15 @@ class BaseReviewFlagFormSet(BaseModelFormSet):
review_addon = review.addon
review_id = review.id
review.delete()
addon = review.addon
amo.log(amo.LOG.DELETE_REVIEW, review_addon, review_id,
details=dict(title=unicode(review.title),
body=unicode(review.body)))
body=unicode(review.body),
addon_id=addon.id,
addon_title=unicode(addon.name),
is_flagged=is_flagged))
elif action == reviews.REVIEW_MODERATE_KEEP:
review.editorreview = False
review.save()