rename eventlog to ratings_moderation_log; drop obsolete EventLog model (#8043)

This commit is contained in:
Andrew Williamson 2018-04-16 14:48:35 +08:00 коммит произвёл GitHub
Родитель 2155b26c7a
Коммит cb58bd7287
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 41 добавлений и 87 удалений

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

@ -170,8 +170,8 @@ class ActivityLogManager(ManagerBase):
def admin_events(self):
return self.filter(action__in=constants.activity.LOG_ADMINS)
def reviewer_events(self):
return self.filter(action__in=constants.activity.LOG_REVIEWERS)
def moderation_events(self):
return self.filter(action__in=constants.activity.LOG_RATING_MODERATION)
def review_queue(self):
qs = self._by_type()

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

@ -7,7 +7,7 @@ import olympia.core.logger
from olympia.constants import permissions # noqa
from olympia.constants.activity import ( # noqa
LOG, LOG_BY_ID, LOG_ADMINS, LOG_REVIEWER_REVIEW_ACTION,
LOG_REVIEWERS, LOG_HIDE_DEVELOPER, LOG_KEEP, LOG_REVIEW_QUEUE,
LOG_RATING_MODERATION, LOG_HIDE_DEVELOPER, LOG_KEEP, LOG_REVIEW_QUEUE,
LOG_REVIEW_QUEUE_DEVELOPER, LOG_REVIEW_EMAIL_USER)
from olympia.constants.applications import * # noqa
from olympia.constants.base import * # noqa

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

@ -613,7 +613,7 @@ LOG_BY_ID = dict((l.id, l) for l in LOGS)
LOG = namedtuple('LogTuple', [l.__name__ for l in LOGS])(*[l for l in LOGS])
LOG_ADMINS = [l.id for l in LOGS if hasattr(l, 'admin_event')]
LOG_KEEP = [l.id for l in LOGS if hasattr(l, 'keep')]
LOG_REVIEWERS = [l.id for l in LOGS if hasattr(l, 'reviewer_event')]
LOG_RATING_MODERATION = [l.id for l in LOGS if hasattr(l, 'reviewer_event')]
LOG_REVIEW_QUEUE = [l.id for l in LOGS if hasattr(l, 'review_queue')]
LOG_REVIEWER_REVIEW_ACTION = [
l.id for l in LOGS if hasattr(l, 'reviewer_review_action')]

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

@ -0,0 +1 @@
DROP TABLE IF EXISTS `eventlog`;

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

@ -2,7 +2,7 @@ from django.contrib import admin
from olympia.translations.templatetags.jinja_helpers import truncate
from .models import CannedResponse, EventLog, ReviewerScore
from .models import CannedResponse, ReviewerScore
class CannedResponseAdmin(admin.ModelAdmin):
@ -14,21 +14,6 @@ class CannedResponseAdmin(admin.ModelAdmin):
list_filter = ('type',)
class EventLogAdmin(admin.ModelAdmin):
list_display = ('created', 'type', 'action', 'field', 'user',
'changed_id', 'added', 'removed', 'notes')
list_filter = ('type', 'action')
readonly_fields = list_display
date_hierarchy = 'created'
raw_id_fields = ('user',)
def has_add_permission(self, request):
return False
def has_delete_permission(self, request, obj=None):
return False
class ReviewerScoreAdmin(admin.ModelAdmin):
list_display = ('user', 'score', 'note_key', 'note', 'created')
raw_id_fields = ('user', 'addon')
@ -41,5 +26,4 @@ class ReviewerScoreAdmin(admin.ModelAdmin):
admin.site.register(CannedResponse, CannedResponseAdmin)
admin.site.register(EventLog, EventLogAdmin)
admin.site.register(ReviewerScore, ReviewerScoreAdmin)

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

@ -39,7 +39,7 @@ ACTION_DICT = dict(approved=amo.LOG.APPROVE_RATING,
deleted=amo.LOG.DELETE_RATING)
class EventLogForm(happyforms.Form):
class RatingModerationLogForm(happyforms.Form):
start = forms.DateField(required=False,
label=_(u'View entries between'))
end = forms.DateField(required=False,

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

@ -16,8 +16,6 @@ import olympia.core.logger
from olympia import amo
from olympia.abuse.models import AbuseReport
from olympia.access import acl
from olympia.access.models import Group
from olympia.activity.models import ActivityLog
from olympia.addons.models import Addon, Persona
from olympia.amo.models import ManagerBase, ModelBase, skip_cache
from olympia.amo.templatetags.jinja_helpers import absolutify
@ -93,35 +91,6 @@ class CannedResponse(ModelBase):
return unicode(self.name)
class EventLog(models.Model):
type = models.CharField(max_length=60)
action = models.CharField(max_length=120)
field = models.CharField(max_length=60, blank=True)
user = models.ForeignKey(UserProfile)
changed_id = models.IntegerField()
added = models.CharField(max_length=765, blank=True)
removed = models.CharField(max_length=765, blank=True)
notes = models.TextField(blank=True)
created = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = u'eventlog'
@staticmethod
def new_reviewers():
action = amo.LOG.GROUP_USER_ADDED
groups = Group.objects.filter(name__startswith='Reviewers: ')
items = (ActivityLog.objects.for_groups(groups)
.filter(action=action.id)
.order_by('-created')[:5])
# We re-filter the results to make sure to display only users that are
# still part of the reviewers groups we've looked at.
return [{'user': i.arguments[1], 'created': i.created}
for i in items if i.arguments[1].groups.filter(
name__startswith='Reviewers: ').exists()]
def get_flags(addon, version):
"""Return a list of tuples (indicating which flags should be displayed for
a particular add-on."""

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

@ -5,7 +5,7 @@
<div class="listing results">
<div class="results-inner controls">
<form action="{{ url('reviewers.eventlog') }}" data-no-csrf>
<form action="{{ url('reviewers.ratings_moderation_log') }}" data-no-csrf>
<p class="date_range">
{{ form.start.label_tag() }}
{{ form.start }}
@ -36,7 +36,7 @@
{{ item.to_string('reviewer') }}
{% if item.details %}
<a class="more-details"
href="{{ url('reviewers.eventlog.detail', item.id) }}">
href="{{ url('reviewers.ratings_moderation_log.detail', item.id) }}">
{{ _('More details.') }}
</a>
{% endif %}
@ -57,4 +57,3 @@
{% endif %}
</div>
{% endblock %}

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

@ -75,14 +75,14 @@ class ReviewerTest(TestCase):
return Rating.objects.create(user=u, addon=a, title='foo', body='bar')
class TestEventLog(ReviewerTest):
class TestRatingsModerationLog(ReviewerTest):
def setUp(self):
super(TestEventLog, self).setUp()
super(TestRatingsModerationLog, self).setUp()
user = user_factory()
self.grant_permission(user, 'Ratings:Moderate')
self.client.login(email=user.email)
self.url = reverse('reviewers.eventlog')
self.url = reverse('reviewers.ratings_moderation_log')
core.set_user(user)
def test_log(self):
@ -126,12 +126,12 @@ class TestEventLog(ReviewerTest):
assert response.status_code == 200
assert '"no-results"' in response.content
def test_event_log_detail(self):
def test_moderation_log_detail(self):
review = self.make_review()
ActivityLog.create(amo.LOG.APPROVE_RATING, review, review.addon)
id_ = ActivityLog.objects.reviewer_events()[0].id
id_ = ActivityLog.objects.moderation_events()[0].id
response = self.client.get(
reverse('reviewers.eventlog.detail', args=[id_]))
reverse('reviewers.ratings_moderation_log.detail', args=[id_]))
assert response.status_code == 200
@ -546,7 +546,7 @@ class TestDashboard(TestCase):
reverse('reviewers.themes.deleted'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Themes/Guidelines',
reverse('reviewers.queue_moderated'),
reverse('reviewers.eventlog'),
reverse('reviewers.ratings_moderation_log'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Guide/Moderation',
reverse('reviewers.unlisted_queue_all'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Guide',
@ -594,7 +594,7 @@ class TestDashboard(TestCase):
reverse('reviewers.themes.deleted'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Themes/Guidelines',
reverse('reviewers.queue_moderated'),
reverse('reviewers.eventlog'),
reverse('reviewers.ratings_moderation_log'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Guide/Moderation',
reverse('reviewers.unlisted_queue_all'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Guide',
@ -777,7 +777,7 @@ class TestDashboard(TestCase):
assert len(doc('.dashboard h3')) == 1
expected_links = [
reverse('reviewers.queue_moderated'),
reverse('reviewers.eventlog'),
reverse('reviewers.ratings_moderation_log'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Guide/Moderation',
]
links = [link.attrib['href'] for link in doc('.dashboard a')]
@ -914,7 +914,7 @@ class TestDashboard(TestCase):
reverse('reviewers.reviewlog'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Guide',
reverse('reviewers.queue_moderated'),
reverse('reviewers.eventlog'),
reverse('reviewers.ratings_moderation_log'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Guide/Moderation',
]
links = [link.attrib['href'] for link in doc('.dashboard a')]
@ -1640,9 +1640,10 @@ class TestModeratedQueue(QueueTest):
assert response.status_code == 200
assert pq(response.content)('#reviews-flagged .no-results').length == 1
response = self.client.get(reverse('reviewers.eventlog'))
response = self.client.get(reverse('reviewers.ratings_moderation_log'))
assert pq(response.content)('table .more-details').attr('href') == (
reverse('reviewers.eventlog.detail', args=[logs[0].id]))
reverse('reviewers.ratings_moderation_log.detail',
args=[logs[0].id]))
# Make sure it was actually deleted.
assert Rating.objects.filter(addon=1865).count() == 1

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

@ -29,9 +29,10 @@ urlpatterns = (
name='reviewers.unlisted_queue'),
url(r'^unlisted_queue/all$', views.unlisted_list,
name='reviewers.unlisted_queue_all'),
url(r'^logs$', views.eventlog, name='reviewers.eventlog'),
url(r'^log/(\d+)$', views.eventlog_detail,
name='reviewers.eventlog.detail'),
url(r'^moderationlog$', views.ratings_moderation_log,
name='reviewers.ratings_moderation_log'),
url(r'^moderationlog/(\d+)$', views.ratings_moderation_log_detail,
name='reviewers.ratings_moderation_log.detail'),
url(r'^reviewlog$', views.reviewlog, name='reviewers.reviewlog'),
url(r'^queue_version_notes/%s?$' % ADDON_ID, views.queue_version_notes,
name='reviewers.queue_version_notes'),

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

@ -37,8 +37,8 @@ from olympia.constants.reviewers import REVIEWS_PER_PAGE, REVIEWS_PER_PAGE_MAX
from olympia.devhub import tasks as devhub_tasks
from olympia.ratings.models import Rating, RatingFlag
from olympia.reviewers.forms import (
AllAddonSearchForm, EventLogForm, MOTDForm, QueueSearchForm,
RatingFlagFormSet, ReviewForm, ReviewLogForm, WhiteboardForm)
AllAddonSearchForm, MOTDForm, QueueSearchForm, RatingFlagFormSet,
RatingModerationLogForm, ReviewForm, ReviewLogForm, WhiteboardForm)
from olympia.reviewers.models import (
AutoApprovalSummary, PerformanceGraph,
RereviewQueueTheme, ReviewerScore, ReviewerSubscription,
@ -84,28 +84,28 @@ def context(request, **kw):
@ratings_moderator_required
def eventlog(request):
form = EventLogForm(request.GET)
eventlog = ActivityLog.objects.reviewer_events()
def ratings_moderation_log(request):
form = RatingModerationLogForm(request.GET)
mod_log = ActivityLog.objects.moderation_events()
if form.is_valid():
if form.cleaned_data['start']:
eventlog = eventlog.filter(created__gte=form.cleaned_data['start'])
mod_log = mod_log.filter(created__gte=form.cleaned_data['start'])
if form.cleaned_data['end']:
eventlog = eventlog.filter(created__lt=form.cleaned_data['end'])
mod_log = mod_log.filter(created__lt=form.cleaned_data['end'])
if form.cleaned_data['filter']:
eventlog = eventlog.filter(action=form.cleaned_data['filter'].id)
mod_log = mod_log.filter(action=form.cleaned_data['filter'].id)
pager = amo.utils.paginate(request, eventlog, 50)
pager = amo.utils.paginate(request, mod_log, 50)
data = context(request, form=form, pager=pager)
return render(request, 'reviewers/eventlog.html', data)
return render(request, 'reviewers/moderationlog.html', data)
@ratings_moderator_required
def eventlog_detail(request, id):
log = get_object_or_404(ActivityLog.objects.reviewer_events(), pk=id)
def ratings_moderation_log_detail(request, id):
log = get_object_or_404(ActivityLog.objects.moderation_events(), pk=id)
review = None
# I really cannot express the depth of the insanity incarnate in
@ -128,10 +128,10 @@ def eventlog_detail(request, id):
ReviewerScore.award_moderation_points(
log.user, review.addon, review.id, undo=True)
review.undelete()
return redirect('reviewers.eventlog.detail', id)
return redirect('reviewers.ratings_moderation_log.detail', id)
data = context(request, log=log, can_undelete=can_undelete)
return render(request, 'reviewers/eventlog_detail.html', data)
return render(request, 'reviewers/moderationlog_detail.html', data)
@any_reviewer_or_moderator_required
@ -273,7 +273,7 @@ def dashboard(request):
reverse('reviewers.queue_moderated')
), (
ugettext('Moderated Review Log'),
reverse('reviewers.eventlog')
reverse('reviewers.ratings_moderation_log')
), (
ugettext('Moderation Guide'),
'https://wiki.mozilla.org/Add-ons/Reviewers/Guide/Moderation'

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

@ -31,7 +31,6 @@ def admin_site_links():
'tools': [
('Manage elasticsearch', reverse('zadmin.elastic')),
('Purge data from memcache', reverse('zadmin.memcache')),
('View event log', reverse('admin:reviewers_eventlog_changelist')),
('View addon log',
reverse('admin:activity_activitylog_changelist')),
],