Merge lp:~developer-ubuntu-com-dev/developer-ubuntu-com/get-gadget-snaps into lp:developer-ubuntu-com
- get-gadget-snaps
- Merge into stable
Proposed by David Callé
Status: | Merged |
---|---|
Approved by: | David Callé |
Approved revision: | 230 |
Merged at revision: | 222 |
Proposed branch: | lp:~developer-ubuntu-com-dev/developer-ubuntu-com/get-gadget-snaps |
Merge into: | lp:developer-ubuntu-com |
Diff against target: | 245 lines (+89/-22) 8 files modified developer_portal/migrations/0002_update_rawhtml_data_type.py (+19/-0) store_data/cms_plugins.py (+10/-2) store_data/management/store/api.py (+6/-9) store_data/migrations/0003_make_iconurl_optional.py (+19/-0) store_data/models.py (+1/-1) store_data/static/img/official.svg (+10/-0) templates/gadget_snap_list.html (+15/-8) templates/gadget_snap_shortlist.html (+9/-2) |
To merge this branch: | bzr merge lp:~developer-ubuntu-com-dev/developer-ubuntu-com/get-gadget-snaps |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Needs Fixing | ||
Review via email: |
Commit message
Description of the change
Add gadget type snaps from the snap store to the existing oem type snaps list.
To post a comment you must log in.
- 222. By David Callé
-
Give the possibility for the icon_url to be null, make migrations
Revision history for this message

Daniel Holbach (dholbach) wrote : | # |
Apart from that: great work so far. The presentation is something which would be good to change too.
review: Needs Fixing
- 223. By Daniel Holbach
-
rename migrations to be more descriptive
- 224. By Daniel Holbach
-
order by release
- 225. By Daniel Holbach
-
show which release a snap is available for
- 226. By Daniel Holbach
-
show which release a snap is available for (on short gadget snap list)
- 227. By Daniel Holbach
-
indicate if snap is officially supported
Revision history for this message

Daniel Holbach (dholbach) wrote : | # |
David: I made a couple of changes which reflect what we talked about earlier (official support, indicate which release is supported). Now we just need to make it look pretty. :-)
- 228. By Daniel Holbach
-
add icon for official support
- 229. By David Callé
-
Support logo
- 230. By Daniel Holbach
-
fix sorting to make davidc3 happy
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'developer_portal/migrations/0002_update_rawhtml_data_type.py' |
2 | --- developer_portal/migrations/0002_update_rawhtml_data_type.py 1970-01-01 00:00:00 +0000 |
3 | +++ developer_portal/migrations/0002_update_rawhtml_data_type.py 2016-05-16 22:29:20 +0000 |
4 | @@ -0,0 +1,19 @@ |
5 | +# -*- coding: utf-8 -*- |
6 | +from __future__ import unicode_literals |
7 | + |
8 | +from django.db import migrations, models |
9 | + |
10 | + |
11 | +class Migration(migrations.Migration): |
12 | + |
13 | + dependencies = [ |
14 | + ('developer_portal', '0001_initial'), |
15 | + ] |
16 | + |
17 | + operations = [ |
18 | + migrations.AlterField( |
19 | + model_name='rawhtml', |
20 | + name='cmsplugin_ptr', |
21 | + field=models.OneToOneField(parent_link=True, related_name='developer_portal_rawhtml', primary_key=True, serialize=False, to='cms.CMSPlugin'), |
22 | + ), |
23 | + ] |
24 | |
25 | === modified file 'store_data/cms_plugins.py' |
26 | --- store_data/cms_plugins.py 2016-03-29 08:29:43 +0000 |
27 | +++ store_data/cms_plugins.py 2016-05-16 22:29:20 +0000 |
28 | @@ -5,6 +5,14 @@ |
29 | from .models import GadgetSnap |
30 | |
31 | |
32 | +def get_gadget_snaps(): |
33 | + snaps = [a for a in GadgetSnap.objects.exclude( |
34 | + release__name='rolling-core').order_by('-release')] |
35 | + snaps += [a for a in GadgetSnap.objects.filter( |
36 | + release__name='rolling-core')] |
37 | + return snaps |
38 | + |
39 | + |
40 | class GadgetSnapListPluginLarge(CMSPluginBase): |
41 | # Keeping the name short to be able to differentiate them |
42 | # in the editor dropdown |
43 | @@ -14,7 +22,7 @@ |
44 | |
45 | def render(self, context, instance, placeholder): |
46 | context.update({ |
47 | - 'gadget_snap_list': GadgetSnap.objects.all(), |
48 | + 'gadget_snap_list': get_gadget_snaps(), |
49 | }) |
50 | return context |
51 | |
52 | @@ -30,7 +38,7 @@ |
53 | |
54 | def render(self, context, instance, placeholder): |
55 | context.update({ |
56 | - 'gadget_snap_list': GadgetSnap.objects.all(), |
57 | + 'gadget_snap_list': get_gadget_snaps(), |
58 | }) |
59 | return context |
60 | |
61 | |
62 | === modified file 'store_data/management/store/api.py' |
63 | --- store_data/management/store/api.py 2015-07-02 12:34:31 +0000 |
64 | +++ store_data/management/store/api.py 2016-05-16 22:29:20 +0000 |
65 | @@ -14,22 +14,18 @@ |
66 | |
67 | |
68 | class GadgetSnapData(object): |
69 | - data = {} |
70 | + data = [] |
71 | |
72 | - def get_data(self): |
73 | - params = urlencode({'q': 'content:oem'}) |
74 | + def get_data(self, snap_type): |
75 | + params = urlencode({'q': 'content:%s' % snap_type}) |
76 | url = PACKAGE_API + "?%s" % params |
77 | req = Request(url) |
78 | - req.add_header('X-Ubuntu-Frameworks', 'ubuntu-core-15.04-dev1') |
79 | - # XXX: This is supposed to work, but doesn't. |
80 | - # req.add_header('X-Ubuntu-Release', |
81 | - # '[15.04-core|rolling-core|rolling-personal]') |
82 | req.add_header('Accept', 'application/hal+json') |
83 | f = urlopen(req) |
84 | s = f.read().decode('utf-8') |
85 | f.close() |
86 | packages = json.loads(s) |
87 | - self.data = packages['_embedded']['clickindex:package'] |
88 | + self.data += packages['_embedded']['clickindex:package'] |
89 | |
90 | def get_additional_snap_data(self): |
91 | for entry in self.data: |
92 | @@ -48,5 +44,6 @@ |
93 | entry['description'] = data['description'] |
94 | |
95 | def __init__(self): |
96 | - self.get_data() |
97 | + for snap_type in ['oem', 'gadget']: |
98 | + self.get_data(snap_type) |
99 | self.get_additional_snap_data() |
100 | |
101 | === added file 'store_data/migrations/0003_make_iconurl_optional.py' |
102 | --- store_data/migrations/0003_make_iconurl_optional.py 1970-01-01 00:00:00 +0000 |
103 | +++ store_data/migrations/0003_make_iconurl_optional.py 2016-05-16 22:29:20 +0000 |
104 | @@ -0,0 +1,19 @@ |
105 | +# -*- coding: utf-8 -*- |
106 | +from __future__ import unicode_literals |
107 | + |
108 | +from django.db import migrations, models |
109 | + |
110 | + |
111 | +class Migration(migrations.Migration): |
112 | + |
113 | + dependencies = [ |
114 | + ('store_data', '0002_make_screenshot_optional'), |
115 | + ] |
116 | + |
117 | + operations = [ |
118 | + migrations.AlterField( |
119 | + model_name='gadgetsnap', |
120 | + name='icon_url', |
121 | + field=models.URLField(null=True, blank=True), |
122 | + ), |
123 | + ] |
124 | |
125 | === modified file 'store_data/models.py' |
126 | --- store_data/models.py 2016-03-29 08:30:26 +0000 |
127 | +++ store_data/models.py 2016-05-16 22:29:20 +0000 |
128 | @@ -23,7 +23,7 @@ |
129 | |
130 | |
131 | class GadgetSnap(models.Model): |
132 | - icon_url = models.URLField(blank=True) |
133 | + icon_url = models.URLField(blank=True, null=True) |
134 | release = models.ManyToManyField(Release) |
135 | name = models.CharField(max_length=100) |
136 | title = models.CharField(max_length=250, blank=True, null=True) |
137 | |
138 | === added file 'store_data/static/img/official.svg' |
139 | --- store_data/static/img/official.svg 1970-01-01 00:00:00 +0000 |
140 | +++ store_data/static/img/official.svg 2016-05-16 22:29:20 +0000 |
141 | @@ -0,0 +1,10 @@ |
142 | +<?xml version="1.0" encoding="UTF-8"?> |
143 | +<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> |
144 | +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> |
145 | +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="180.284px" height="180.284px" viewBox="11.274 82.408 180.284 180.284" enable-background="new 11.274 82.408 180.284 180.284" xml:space="preserve"> |
146 | +<g> |
147 | + <path fill="#DD4814" d="M120.732,210.424c-31.26,0-56.691-25.433-56.691-56.691c0-31.261,25.432-56.692,56.691-56.692 c31.259,0,56.692,25.432,56.692,56.692C177.425,184.991,151.991,210.424,120.732,210.424"/> |
148 | + <path fill="#DD4814" d="M57.083,157.812c1.299,20.461,12.287,38.332,28.418,49.062l0.002-0.004l-39.398,22.748l10.384-38.738 l-38.732-10.358l39.332-22.709H57.083z"/> |
149 | + <path fill="#DD4814" d="M92.378,210.855c8.546,4.258,18.174,6.655,28.354,6.655c10.173,0,19.8-2.396,28.343-6.651l-0.002-0.004 v45.634l-28.355-28.362l-28.337,28.362v-45.638L92.378,210.855z"/> |
150 | +</g> |
151 | +</svg> |
152 | \ No newline at end of file |
153 | |
154 | === modified file 'templates/gadget_snap_list.html' |
155 | --- templates/gadget_snap_list.html 2015-12-08 10:25:29 +0000 |
156 | +++ templates/gadget_snap_list.html 2016-05-16 22:29:20 +0000 |
157 | @@ -2,6 +2,10 @@ |
158 | |
159 | <div class="no-border"> |
160 | {% for snap in gadget_snap_list %} |
161 | + {% ifchanged snap.release.all|first %} |
162 | + <h4>Available on release: {{ snap.release.all|first }}</h4> |
163 | + {% endifchanged %} |
164 | + |
165 | {% if gadget_snap_list|index:snap|divisibleby:1 %} |
166 | <div class="left twelve-col last-col box"> |
167 | {% else %} |
168 | @@ -12,7 +16,7 @@ |
169 | <img src="{{ snap.icon_url }}"/> |
170 | </div> |
171 | {% else %} |
172 | - {% with 0|randint:10|string as rand %} |
173 | + {% with 0|randint:10|string as rand %} |
174 | {% with "img/boards/noboard-"|add:rand|add:".png" as noboard %} |
175 | <div class="two-col no-margin-bottom"> |
176 | <img src="{% static noboard %}"/> |
177 | @@ -20,10 +24,11 @@ |
178 | {% endwith %} |
179 | {% endwith %} |
180 | {% endif %} |
181 | - <div class="ten-col last-col no-margin-bottom"> |
182 | + <div class="eight-col"> |
183 | + |
184 | <h3> |
185 | {% with snap_name=snap.title|default_if_none:snap.name %} |
186 | - {{ snap_name|style_snap_name }} |
187 | + {{ snap_name|style_snap_name }} {% if snap.publisher == "Canonical" %}<img src="{% static "img/official.svg" %}" title="Officially supported" alt="Officially supported" style="width:5%;"/> {% endif %} |
188 | {% endwith %} |
189 | </h3> |
190 | {% if snap.description|length > 180 %} |
191 | @@ -31,11 +36,13 @@ |
192 | {% else %} |
193 | <p>{% autoescape off %}{{ snap.description|html_links }}{% endautoescape %}</p> |
194 | {% endif %} |
195 | - <ul class="list-ubuntu"> |
196 | - <li> |
197 | - <a href="https://developer.ubuntu.com/en/snappy/start/">{% trans "Install Snappy on this device" %}</a> |
198 | - </li> |
199 | - </ul> |
200 | + |
201 | + </div> |
202 | + |
203 | + |
204 | + <div class="ten-col no-margin-bottom"> |
205 | + |
206 | + |
207 | </div> |
208 | </div> |
209 | {% endfor %} |
210 | |
211 | === modified file 'templates/gadget_snap_shortlist.html' |
212 | --- templates/gadget_snap_shortlist.html 2015-11-10 14:13:42 +0000 |
213 | +++ templates/gadget_snap_shortlist.html 2016-05-16 22:29:20 +0000 |
214 | @@ -2,6 +2,10 @@ |
215 | |
216 | <div class="equal-height no-border"> |
217 | {% for snap in gadget_snap_list|slice:"6" %} |
218 | + {% ifchanged snap.release.all|first %} |
219 | + <h2>Available on release: {{ snap.release.all|first }}</h2> |
220 | + {% endifchanged %} |
221 | + |
222 | {% if gadget_snap_list|index:snap|divisibleby:6 %} |
223 | <div class="two-col last-col box"> |
224 | {% else %} |
225 | @@ -12,7 +16,7 @@ |
226 | <img src="{{ snap.icon_url }}"/> |
227 | </div> |
228 | {% else %} |
229 | - {% with 0|randint:10|string as rand %} |
230 | + {% with 0|randint:10|string as rand %} |
231 | {% with "img/boards/noboard-"|add:rand|add:".png" as noboard %} |
232 | <div class="two-col"> |
233 | <img src="{% static noboard %}"/> |
234 | @@ -23,7 +27,10 @@ |
235 | <div class="two-col no-margin-bottom"> |
236 | <h4> |
237 | {% with snap_name=snap.title|default_if_none:snap.name %} |
238 | - {{ snap_name|style_snap_name }} |
239 | + {{ snap_name|style_snap_name }} |
240 | + {% if snap.publisher == "Canonical" %} |
241 | + (officially supported) |
242 | + {% endif %} |
243 | {% endwith %} |
244 | </h4> |
245 | </div> |
Can you rename the migration scripts (both) to something more descriptive?