Show files reviewed in Item History (bug 655256)
This commit is contained in:
Родитель
52b13ed3b2
Коммит
a23db9e97f
|
@ -222,7 +222,7 @@ class ReviewHelper:
|
|||
self.actions = self.get_actions()
|
||||
|
||||
def set_data(self, data):
|
||||
self.handler.data = data
|
||||
self.handler.set_data(data)
|
||||
|
||||
def get_review_type(self, request, addon, version):
|
||||
if self.addon.status in NOMINATED_STATUSES:
|
||||
|
@ -333,6 +333,7 @@ class ReviewBase:
|
|||
self.addon = addon
|
||||
self.version = version
|
||||
self.review_type = review_type
|
||||
self.files = None
|
||||
|
||||
def set_addon(self, **kw):
|
||||
"""Alters addon and sets reviewed timestamp on version."""
|
||||
|
@ -354,10 +355,13 @@ class ReviewBase:
|
|||
file.save()
|
||||
|
||||
def log_action(self, action):
|
||||
details = {'comments': self.data['comments'],
|
||||
'reviewtype': self.review_type}
|
||||
if self.files:
|
||||
details['files'] = [f.id for f in self.files]
|
||||
|
||||
amo.log(action, self.addon, self.version, user=self.user.get_profile(),
|
||||
created=datetime.now(),
|
||||
details={'comments': self.data['comments'],
|
||||
'reviewtype': self.review_type})
|
||||
created=datetime.now(), details=details)
|
||||
|
||||
def notify_email(self, template, subject):
|
||||
"""Notify the authors that their addon has been reviewed."""
|
||||
|
@ -407,6 +411,10 @@ class ReviewBase:
|
|||
|
||||
class ReviewAddon(ReviewBase):
|
||||
|
||||
def set_data(self, data):
|
||||
self.data = data
|
||||
self.files = self.version.files.all()
|
||||
|
||||
def process_public(self):
|
||||
"""Set an addon to public."""
|
||||
if self.review_type == 'preliminary':
|
||||
|
@ -472,6 +480,10 @@ class ReviewAddon(ReviewBase):
|
|||
|
||||
class ReviewFiles(ReviewBase):
|
||||
|
||||
def set_data(self, data):
|
||||
self.data = data
|
||||
self.files = data.get('addon_files', None)
|
||||
|
||||
def process_public(self):
|
||||
"""Set an addons files to public."""
|
||||
if self.review_type == 'preliminary':
|
||||
|
|
|
@ -17,6 +17,22 @@
|
|||
<div class="history_comment">
|
||||
{{ record.details.comments|nl2br }}
|
||||
</div>
|
||||
{% if record.details.files %}
|
||||
<ul>
|
||||
{% for file_id in record.details.files %}
|
||||
{% if file_id in files: %}
|
||||
{% set file = files[file_id] %}
|
||||
<li>
|
||||
<strong>{{ file.platform }}</strong>
|
||||
[<a href="{{ file.get_url_path(addon.app, 'editor') }}" class="install"
|
||||
data-type="{{ amo.ADDON_SLUGS[addon.type] }}">{{ file.filename }}</a>]
|
||||
</li>
|
||||
{% else %}
|
||||
<li><em>{{ _('File deleted') }}</em></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -1237,6 +1237,21 @@ class TestReview(ReviewBase):
|
|||
|
||||
eq_(validation.find('a').length, 3)
|
||||
|
||||
def test_files_in_item_history(self):
|
||||
data = {'action': 'public', 'operating_systems': 'win',
|
||||
'applications': 'something', 'comments': 'something',
|
||||
'addon_files': [self.version.files.all()[0].pk]}
|
||||
|
||||
self.client.post(self.url, data)
|
||||
|
||||
r = self.client.get(self.url)
|
||||
doc = pq(r.content)
|
||||
|
||||
eq_(doc('#review-files tbody tr').length, 1)
|
||||
li = doc('#review-files .history_comment').parent().find('li')
|
||||
eq_(li.length, 1)
|
||||
eq_(li.find('strong').text(), "All Platforms")
|
||||
|
||||
def test_no_items(self):
|
||||
response = self.client.get(self.url)
|
||||
eq_(pq(response.content).find('#file-history').next().text(),
|
||||
|
|
|
@ -26,7 +26,7 @@ from editors.models import (EditorSubscription, ViewPendingQueue,
|
|||
EventLog, CannedResponse, PerformanceGraph)
|
||||
from editors.helpers import (ViewPendingQueueTable, ViewFullReviewQueueTable,
|
||||
ViewPreliminaryQueueTable)
|
||||
from files.models import Approval
|
||||
from files.models import Approval, File
|
||||
from reviews.forms import ReviewFlagFormSet
|
||||
from reviews.models import Review, ReviewFlag
|
||||
from users.models import UserProfile
|
||||
|
@ -119,6 +119,18 @@ def _editor_progress():
|
|||
return (progress, percentage)
|
||||
|
||||
|
||||
def _get_history(addon):
|
||||
files = []
|
||||
history = (ActivityLog.objects.for_addons(addon).order_by('created')
|
||||
.filter(action__in=amo.LOG_REVIEW_QUEUE))
|
||||
|
||||
for h in history:
|
||||
if 'files' in h.details:
|
||||
files.extend(h.details['files'])
|
||||
|
||||
return history, File.objects.in_bulk(files)
|
||||
|
||||
|
||||
@editor_required
|
||||
def performance(request, user_id=False):
|
||||
user = request.amo_user
|
||||
|
@ -429,15 +441,15 @@ def review(request, version_id):
|
|||
# We only allow the user to check/uncheck files for "pending"
|
||||
allow_unchecking_files = form.helper.review_type == "pending"
|
||||
|
||||
history, files = _get_history(addon)
|
||||
|
||||
ctx = context(version=version, addon=addon,
|
||||
flags=Review.objects.filter(addon=addon, flag=True),
|
||||
form=form, paging=paging, canned=canned, is_admin=is_admin,
|
||||
status_types=amo.STATUS_CHOICES, show_diff=show_diff,
|
||||
allow_unchecking_files=allow_unchecking_files,
|
||||
actions=actions, actions_minimal=actions_minimal,
|
||||
history=ActivityLog.objects.for_addons(addon)
|
||||
.order_by('created')
|
||||
.filter(action__in=amo.LOG_REVIEW_QUEUE))
|
||||
history=history, files=files)
|
||||
|
||||
return jingo.render(request, 'editors/review.html', ctx)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче