Merge lp:~elachuni/ubuntu-webcatalog/import-backports-no-ajax into lp:ubuntu-webcatalog

Proposed by Anthony Lenton on 2012-04-20
Status: Merged
Approved by: Anthony Lenton on 2012-04-20
Approved revision: 113
Merged at revision: 113
Proposed branch: lp:~elachuni/ubuntu-webcatalog/import-backports-no-ajax
Merge into: lp:ubuntu-webcatalog
Diff against target: 251 lines (+18/-98) 6 files modified
To merge this branch: bzr merge lp:~elachuni/ubuntu-webcatalog/import-backports-no-ajax
Reviewer Review Type Date Requested Status
Natalia Bidart 2012-04-20 Approve on 2012-04-20
Review via email: mp+102902@code.launchpad.net

Commit Message

Import bckports together with app-install-data, and removed vary_on_header decorators

Description of the Change

This branch implements two fixes for the current staging deploy:
 - Removed the use of vary_on_headers
 - Added backports to the list of imported repos.

To post a comment you must log in.
Natalia Bidart (nataliabidart) wrote :

Looks goods!

review: Approve

Preview Diff

1=== modified file 'src/webcatalog/management/commands/import_app_install_data.py'
2--- src/webcatalog/management/commands/import_app_install_data.py 2012-04-20 06:41:56 +0000
3+++ src/webcatalog/management/commands/import_app_install_data.py 2012-04-20 17:03:19 +0000
4@@ -55,6 +55,7 @@
5 sources = """
6 deb http://archive.ubuntu.com/ubuntu {distroseries} main universe
7 deb http://archive.ubuntu.com/ubuntu {distroseries}-updates main universe
8+deb http://archive.ubuntu.com/ubuntu {distroseries}-backports main universe
9 deb http://archive.canonical.com/ubuntu {distroseries} partner
10 deb http://extras.ubuntu.com/ubuntu {distroseries} main
11 """
12
13=== removed file 'src/webcatalog/templates/webcatalog/recommended_apps.html'
14--- src/webcatalog/templates/webcatalog/recommended_apps.html 2012-04-19 21:13:41 +0000
15+++ src/webcatalog/templates/webcatalog/recommended_apps.html 1970-01-01 00:00:00 +0000
16@@ -1,39 +0,0 @@
17-{% extends "webcatalog/base.html" %}
18-{% load i18n %}
19-{% load webcatalog %}
20-
21-{% block head_extra %}
22- <link rel="stylesheet" type="text/css" href="{% url wc-combo %}?light/css/reset.css&light/css/styles.css&css/webcatalog.css&light/css/forms.css&css/carousel.css"/>
23- <script src="{% url wc-combo %}?yui/3.4.0/build/yui/yui-min.js&js/carousel.js"></script>
24-{% endblock %}
25-
26-{% block title %}Recommended apps for {{ application.name }}{% endblock %}
27-{% block header %}Recommended apps for {{ application.name }}{% endblock %}
28-
29-{% block content %}
30- {% include "webcatalog/breadcrumbs_snippet.html" %}
31- <div id="sc-mockup">
32- <div class="header">
33- {% rating_summary application.ratings_average 'large' application.ratings_total %}
34- <img class="icon64" src="{{ application.icon_url_or_default }}"/>
35- <h2>{{ application.name }}</h2>
36- <p>{{ application.comment }}</p>
37- </div>
38- </div>
39-<div class="featured-widget">
40- {% include "webcatalog/recommended_apps_widget.html" %}
41-</div>
42-<script type="text/javascript">
43-YUI({combine: true, comboBase: '{% url wc-combo %}?', root: 'yui/3.4.0/build/'}).use('uwc-carousel', function(Y) {
44- var caro = new Y.uwc.Carousel({
45- nodeContainer: ".featured-widget .carousel",
46- controlsContainer: ".featured-widget .carousel-controls",
47- containerHeight: 200,
48- containerWidth: 912,
49- autoPlay: false
50- });
51- Y.all('.slide').removeClass('disabled');
52-});
53-</script>
54-{% endblock %}
55-
56
57=== modified file 'src/webcatalog/tests/test_commands.py'
58--- src/webcatalog/tests/test_commands.py 2012-04-19 21:20:32 +0000
59+++ src/webcatalog/tests/test_commands.py 2012-04-20 17:03:19 +0000
60@@ -341,6 +341,7 @@
61 self.assertEqual("""
62 deb http://archive.ubuntu.com/ubuntu natty main universe
63 deb http://archive.ubuntu.com/ubuntu natty-updates main universe
64+deb http://archive.ubuntu.com/ubuntu natty-backports main universe
65 deb http://archive.canonical.com/ubuntu natty partner
66 deb http://extras.ubuntu.com/ubuntu natty main
67 """,
68
69=== modified file 'src/webcatalog/tests/test_views.py'
70--- src/webcatalog/tests/test_views.py 2012-04-20 14:38:41 +0000
71+++ src/webcatalog/tests/test_views.py 2012-04-20 17:03:19 +0000
72@@ -958,16 +958,15 @@
73 self.assertContains(response, 'review_summary1')
74 self.assertContains(response, 'review_summary2')
75
76- def test_renders_reviews_only_for_json_request(self):
77+ def test_renders_reviews_only_for_ajax_request(self):
78 app = self.factory.make_application()
79 self.mock_get_reviews.return_value = [
80 self.make_review_details(summary='review_summary1'),
81 self.make_review_details(summary='review_summary2'),
82 ]
83
84- response = self.client.get(reverse('wc-package-reviews',
85- args=[app.distroseries.code_name, app.package_name]),
86- HTTP_X_REQUESTED_WITH='XMLHttpRequest')
87+ response = self.client.get(reverse('wc-package-reviews-ajax',
88+ args=[app.distroseries.code_name, app.package_name]))
89
90 self.assertTemplateNotUsed(
91 response, 'webcatalog/application_review_list.html')
92@@ -1015,25 +1014,12 @@
93 self.assertEqual(1, mock_urlopen.call_count)
94
95 @patch('webcatalog.utilities.WebServices.get_screenshots_for_package')
96- def test_renders_screenshots(self, mock_get_screenshots):
97+ def test_renders_json(self, mock_get_screenshots):
98 mock_get_screenshots.return_value = self.expected
99
100 response = self.client.get(reverse('wc-package-screenshots',
101 args=[self.app.package_name]))
102
103- self.assertTemplateUsed(
104- response, 'webcatalog/application_screenshots.html')
105- for url in self.expected:
106- self.assertContains(response, url)
107-
108- @patch('webcatalog.utilities.WebServices.get_screenshots_for_package')
109- def test_renders_json_for_json_request(self, mock_get_screenshots):
110- mock_get_screenshots.return_value = self.expected
111-
112- response = self.client.get(reverse('wc-package-screenshots',
113- args=[self.app.package_name]),
114- HTTP_X_REQUESTED_WITH='XMLHttpRequest')
115-
116 self.assertTemplateNotUsed(
117 response, 'webcatalog/application_review_list.html')
118 self.assertEqual('application/json', response['content-type'])
119@@ -1089,37 +1075,18 @@
120
121 self.assertEqual(404, response.status_code)
122
123- def test_renders_recommendations(self):
124- app = self.factory.make_application(package_name='firefox')
125- pkgnames = ['nautilus-gksu', 'tribaltrouble2', 'acm']
126- for pkgname in pkgnames:
127- self.factory.make_application(package_name=pkgname)
128+ def test_renders_widget_only(self):
129+ self.factory.make_application(package_name='firefox')
130
131 response = self.client.get(
132 reverse('wc-package-recommends', args=['firefox']))
133
134- self.assertEqual(200, response.status_code)
135- self.assertTemplateUsed(
136- response, 'webcatalog/recommended_apps.html')
137- # Only recommendations for apps that exist in the database are
138- # included.
139- self.assertContains(response, '<div class="top-rated-stars">', 3)
140-
141- def test_renders_widget_only_for_json_requests(self):
142- app = self.factory.make_application(package_name='firefox')
143-
144- response = self.client.get(
145- reverse('wc-package-recommends', args=['firefox']),
146- HTTP_X_REQUESTED_WITH='XMLHttpRequest')
147-
148- self.assertTemplateNotUsed(
149- response, 'webcatalog/recommended_apps.html')
150 self.assertTemplateUsed(
151 response, 'webcatalog/recommended_apps_widget.html')
152
153 def test_handles_multiple_versions_of_app(self):
154 # Same app in two distroseries.
155- app = self.factory.make_application(package_name='firefox')
156+ self.factory.make_application(package_name='firefox')
157 app2 = self.factory.make_application(package_name='firefox')
158
159 response = self.client.get(
160@@ -1128,6 +1095,7 @@
161
162 self.assertEqual(app2, response.context['application'])
163
164+
165 class ComboViewTestCase(TestCase):
166 """Tests for ComboView."""
167
168
169=== modified file 'src/webcatalog/urls.py'
170--- src/webcatalog/urls.py 2012-04-19 21:55:17 +0000
171+++ src/webcatalog/urls.py 2012-04-20 17:03:19 +0000
172@@ -46,6 +46,9 @@
173 url(r'^applications/(?P<distro>[-.+\w]+)/(?P<package_name>[-.+:\w]+)/'
174 r'reviews/$',
175 'application_reviews', name="wc-package-reviews"),
176+ url(r'^applications/(?P<distro>[-.+\w]+)/(?P<package_name>[-.+:\w]+)/'
177+ r'reviews-ajax/$', 'application_reviews', kwargs={'ajax': True},
178+ name="wc-package-reviews-ajax"),
179 url(r'^recommends/(?P<package_name>[-.+:\w]+)/$',
180 'application_recommends', name="wc-package-recommends"),
181 url(r'^search/$', 'search', name="wc-search"),
182
183=== modified file 'src/webcatalog/views.py'
184--- src/webcatalog/views.py 2012-04-20 14:39:25 +0000
185+++ src/webcatalog/views.py 2012-04-20 17:03:19 +0000
186@@ -42,7 +42,6 @@
187 )
188 from django.template import RequestContext
189 from django.utils.translation import ugettext as _
190-from django.views.decorators.vary import vary_on_headers
191
192 from webcatalog.forms import EmailDownloadLinkForm
193 from webcatalog.models import (
194@@ -194,8 +193,7 @@
195 request, atts))
196
197
198-@vary_on_headers('X_REQUESTED_WITH')
199-def application_reviews(request, package_name, distro, page=1):
200+def application_reviews(request, package_name, distro, ajax=False, page=1):
201 app = get_object_or_404(Application, package_name=package_name,
202 distroseries__code_name=distro)
203 # XXX michaeln 2011-09-15 bug=851662 Better review language options.
204@@ -203,7 +201,7 @@
205 distroseries=distro, page=page)
206
207 context = dict(application=app, reviews=reviews)
208- if request.is_ajax():
209+ if ajax:
210 template = 'webcatalog/application_review_list_snippet.html'
211 else:
212 context['distroseries'] = distro
213@@ -213,7 +211,6 @@
214 return render_to_response(template, RequestContext(request, context))
215
216
217-@vary_on_headers('X_REQUESTED_WITH')
218 def application_recommends(request, package_name):
219 app = Application.objects.find_best_or_404(package_name=package_name)
220
221@@ -231,27 +228,16 @@
222 break
223
224 context = dict(application=app, recommended_apps=recommended_apps)
225- if request.is_ajax():
226- template = "webcatalog/recommended_apps_widget.html"
227- else:
228- template = "webcatalog/recommended_apps.html"
229- context['breadcrumbs'] = app.crumbs()
230+ template = "webcatalog/recommended_apps_widget.html"
231 return render_to_response(template, RequestContext(request, context))
232
233
234-@vary_on_headers('X_REQUESTED_WITH')
235 def application_screenshots(request, package_name):
236 app = get_object_or_404(Application, package_name=package_name,
237 is_latest=True)
238 screenshots = WebServices().get_screenshots_for_package(package_name)
239- if request.is_ajax():
240- return HttpResponse(json.dumps(screenshots),
241- mimetype='application/json')
242- else:
243- context = dict(application=app, screenshots=screenshots,
244- breadcrumbs=app.crumbs())
245- return render_to_response('webcatalog/application_screenshots.html',
246- RequestContext(request, context))
247+ return HttpResponse(json.dumps(screenshots),
248+ mimetype='application/json')
249
250
251 def combo_view(request):

Subscribers

People subscribed via source and target branches