[extensions-web] Guard against a new extension with no old version in the review page
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Guard against a new extension with no old version in the review page
- Date: Wed, 16 Nov 2011 21:44:34 +0000 (UTC)
commit 85426446788c9e9839c5f387ed1cdb7b2ece087a
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Nov 15 17:45:59 2011 -0500
Guard against a new extension with no old version in the review page
sweettooth/review/templates/review/review.html | 2 ++
sweettooth/review/views.py | 10 ++++++++++
2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/sweettooth/review/templates/review/review.html b/sweettooth/review/templates/review/review.html
index e2b298e..56d3ce3 100644
--- a/sweettooth/review/templates/review/review.html
+++ b/sweettooth/review/templates/review/review.html
@@ -31,9 +31,11 @@
<div id="files" data-pk="{{ version.pk }}">
</div>
+{% if previous_versions %}
<h2 class="expanded"> Diff Against Previous Version </h2>
<div id="diff" data-pk="{{ version.pk }}">
</div>
+{% endif %}
<h2 class="expanded"> Previous Versions </h2>
<div id="previous_versions">
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index 15567e3..7a88544 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -86,6 +86,10 @@ def get_zipfiles(version):
extension = version.extension
new_zipfile = version.get_zipfile('r')
+
+ if extension.latest_version is None:
+ return None, new_zipfile
+
old_zipfile = extension.latest_version.get_zipfile('r')
return old_zipfile, new_zipfile
@@ -124,6 +128,12 @@ def ajax_get_file_list_view(request, obj):
old_zipfile, new_zipfile = get_zipfiles(version)
new_filelist = set(new_zipfile.namelist())
+
+ if old_zipfile is None:
+ return dict(both=[],
+ added=sorted(new_zipfile.namelist()),
+ deleted=[])
+
old_filelist = set(old_zipfile.namelist())
both = new_filelist & old_filelist
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]