Diff link round 4 (bug 648054 and 647257)

This commit is contained in:
Gregory Koberger 2011-04-14 17:10:20 -07:00
Родитель e57f5591a2
Коммит f04614279b
3 изменённых файлов: 18 добавлений и 12 удалений

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

@ -98,9 +98,9 @@
<a href="{{ url('devhub.file_validation', addon.slug, file.id) }}">{{ _('Validation Results') }}</a>
&middot;
<a href="{{ remora_url('/files/browse/%d/1' % file.id) }}">{{ _('View Contents') }}</a>
{% if has_public_files and addon.type != amo.ADDON_SEARCH %}
{% if has_files and addon.type != amo.ADDON_SEARCH %}
&middot;
<a href="{{ remora_url('/files/diff/%d/' % file.id) }}">{{ _('Compare With Public Version') }}</a>
<a href="{{ remora_url('/files/diff/%d/' % file.id) }}">{{ _('Compare With Previous Version') }}</a>
{% endif %}
</li>
{% endfor %}

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

@ -1024,9 +1024,8 @@ class TestReview(ReviewBase):
validation = pq(response.content).find('#validation').next()
eq_(validation.find('a').eq(1).text(), "Validation Results")
eq_(validation.find('a').eq(2).text(), "View Contents")
eq_(validation.find('a').eq(3).text(), "Compare With Public Version")
eq_(validation.find('a').length, 4)
eq_(validation.find('a').length, 3)
def test_public_search(self):
s = amo.STATUS_PUBLIC
@ -1128,17 +1127,22 @@ class TestReview(ReviewBase):
def test_compare_link(self):
version = Version.objects.create(addon=self.addon, version='0.2')
version.created = datetime.today() + timedelta(days=1)
version.save()
url = reverse('editors.review', args=[version.pk])
File.objects.create(version=version, status=amo.STATUS_PUBLIC)
self.addon.update(_current_version=version)
eq_(self.addon.current_version, version)
r = self.client.get(self.url)
r = self.client.get(url)
doc = pq(r.content)
assert r.context['has_public_files']
eq_(doc('.files a:last-child').text(), 'Compare With Public Version')
assert r.context['has_files']
eq_(doc('.files a:last-child').text(), 'Compare With Previous Version')
# Note: remora url will be to the old version, the diff viewer figures
# out the version to compare too.
eq_(doc('.files a:last-child').attr('href'),
remora_url('/files/diff/%d/' % self.version.files.all()[0].pk))
remora_url('/files/diff/%d/' % version.files.all()[0].pk))
class TestReviewPreliminary(ReviewBase):

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

@ -259,8 +259,11 @@ def review(request, version_id):
is_admin = acl.action_allowed(request, 'Admin', 'EditAnyAddon')
actions = form.helper.actions.items()
has_public_files = (current.files.filter(status__in=amo.LISTED_STATUSES)
.exists()) if current else False
has_files = (addon.versions.exclude(id=version.id)
.filter(files__isnull=False,
created__lt=version.created)
.order_by('created').exists())
# The actions we should show a minimal form from.
actions_minimal = [k for (k, a) in actions if not a.get('minimal')]
@ -270,8 +273,7 @@ def review(request, version_id):
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,
has_public_files=has_public_files,
status_types=amo.STATUS_CHOICES, has_files=has_files,
allow_unchecking_files=allow_unchecking_files,
actions=actions, actions_minimal=actions_minimal,
history=ActivityLog.objects.for_addons(addon)