Merge lp:~victor-oc/ubuntu-api-website/trunk into lp:ubuntu-api-website

Proposed by Victor Choueiri on 2012-09-22
Status: Merged
Approved by: John Vrbanac on 2012-10-19
Approved revision: no longer in the source branch.
Merged at revision: 88
Proposed branch: lp:~victor-oc/ubuntu-api-website/trunk
Merge into: lp:ubuntu-api-website
Diff against target: 389 lines (+306/-7)
11 files modified
DEVELOPMENT (+6/-2)
distro/models.py (+23/-1)
distro/urls.py (+8/-0)
distro/views.py (+29/-1)
distro_data.json (+161/-0)
lang/models.py (+9/-1)
support/models.py (+22/-1)
templates/distro.html (+16/-0)
templates/index.html (+15/-0)
templates/release.html (+15/-0)
urls.py (+2/-1)
To merge this branch: bzr merge lp:~victor-oc/ubuntu-api-website/trunk
Reviewer Review Type Date Requested Status
John Vrbanac 2012-09-22 Approve on 2012-10-19
Review via email: mp+125833@code.launchpad.net

Description of the change

Created the models for distro/language/support apps.

Created views for distro and ditrorelease.

Added distro_data.json with some initial distro models that can be loaded [included instructions in DEVELOPMENT]

To post a comment you must log in.
85. By Michael Hall on 2012-09-22

Add juju charm, use juju deploy --repository=./charms/ local:precise/ubuntu-api-website

John Vrbanac (john.vrbanac) wrote :

Victor,
I checked out a fresh version of your branch and followed the modified instructions. When I attempted to use the site it gives me the following trace:

http://paste.ubuntu.com/1264963/

review: Needs Fixing
86. By John Vrbanac on 2012-10-07

Adding docbook to html xsl transform on the class view

87. By John Vrbanac on 2012-10-07

Forgot to remove pdb import on last commit

Victor Choueiri (victor-oc) wrote :

Thanks John,

I've just added a simple implementation for the view/template that will sort this [was just returning None earlier] - The call shouldn't be failing anymore, although the page will be empty since none of the PlatformItem objects have actually been created.

John Vrbanac (john.vrbanac) wrote :

Victor,
I finally got around to checking out your changes last night. Thanks for fixing that stacktrace! Quick question, with this change, how does a person access the actual api references now? I didn't see the links under a given distro version.

Thanks for your contribution!

Victor Choueiri (victor-oc) wrote :

John,

Thanks for spending time on this.

Unfortunately there was no way to access the full listing: following the wireframes over at https://wiki.ubuntu.com/DeveloperNetwork there is no page which contains all api namespace listings. To resolve this now I've added an include in urls.py to point to the api views via /all [http://localhost:8000/all] - Once the rest of the site is completed this shouldn't be required any more.

As for providing links under the distros, that would be what is documented as the Release Page [https://wiki.ubuntu.com/DeveloperNetwork#Release_Page] . The problem here is I don't know the PlatformSection info needed to group PlatformItems. If this information is available somewhere I wouldn't mind doing the data-entry required to generate loadable db data. In fact if the data required is available I could continue developing the views/templates for the rest of the pages, unfortunately without knowing the details I find myself blocked.

Just to clarify: this merge request tries to cover the following Work_Items laid out at https://wiki.ubuntu.com/DeveloperNetwork#Work_Items :
Distro model
DistroRelease model
PlatformSection model
PlatformItem model
ProgrammingLang model
LanguageNamespace model
RelatedQuestion model
RelatedTutorial model
RelatedSnipped model
RelatedImage model
Index view
Distro view

John Vrbanac (john.vrbanac) wrote :

Victor,
Awesome! Yeah, my major concern was preventing access to those api views until everything is hooked up. I'm assuming that we'll eventually need a way of binding specific GIRs to a given Ubuntu release, but until then then the /all link should work fine.

Regarding the PlatformSection info:
Considering that the GIR files don't give us the information we need to create the PlatformSection information on-the-fly, I'm guessing that we'll just have to manually map the namespaces to a given PlatformSection and then anything that isn't mapped gets put into a generic "Other" section.

Thanks again for your hard work! I'll go ahead and merge this over my lunch break today.

review: Approve
88. By John Vrbanac on 2012-10-19

Accepting Victor's merge request.

Michael Hall (mhall119) wrote :

I've added an initial list of PlatformSections for Ubuntu that can be used to pre-populate the database: https://wiki.ubuntu.com/DeveloperNetwork#Release_Page (below the mockup image)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DEVELOPMENT'
2--- DEVELOPMENT 2012-10-07 04:53:33 +0000
3+++ DEVELOPMENT 2012-10-19 13:46:19 +0000
4@@ -32,11 +32,15 @@
5
6 python manage.py import-girs
7
8-6. Run the Django test server
9+6. Load the initial distro data
10+
11+ python manage.py loaddata distro_data.json
12+
13+7. Run the Django test server
14
15 python manage.py runserver
16
17-7. View the site
18+8. View the site
19
20 Open your browser to http://localhost:8000/api/
21
22
23=== modified file 'distro/models.py'
24--- distro/models.py 2012-09-20 02:08:20 +0000
25+++ distro/models.py 2012-10-19 13:46:19 +0000
26@@ -1,3 +1,25 @@
27 from django.db import models
28
29-# Create your models here.
30+CF_MAX_LENGTH = 500
31+
32+class Distro(models.Model):
33+ name = models.CharField(max_length=CF_MAX_LENGTH)
34+ website = models.URLField(max_length=CF_MAX_LENGTH)
35+ description = models.TextField(blank=True)
36+
37+class DistroRelease(models.Model):
38+ distro = models.ForeignKey(Distro)
39+ version = models.CharField(max_length=CF_MAX_LENGTH)
40+ codename = models.CharField(max_length=CF_MAX_LENGTH)
41+ release_date = models.DateField()
42+ expiration_date = models.DateField()
43+
44+class PlatformSection(models.Model):
45+ section_name = models.CharField(max_length=CF_MAX_LENGTH)
46+ section_description = models.TextField(blank=True)
47+
48+class PlatformItem(models.Model):
49+ distro_release = models.ForeignKey(DistroRelease)
50+ library_release = models.ForeignKey('api.Namespace')
51+ section = models.ForeignKey(PlatformSection)
52+ packages = models.TextField(blank=True)
53
54=== added file 'distro/urls.py'
55--- distro/urls.py 1970-01-01 00:00:00 +0000
56+++ distro/urls.py 2012-10-19 13:46:19 +0000
57@@ -0,0 +1,8 @@
58+# vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4
59+from django.conf.urls.defaults import patterns, include, url
60+
61+urlpatterns = patterns('',
62+ url("^$", "distro.views.index"),
63+ url("^(?P<distro_name>[\w]+)/$", "distro.views.distroview"),
64+ url("^(?P<distro_name>[\w]+)/(?P<release_version>[\w\\.]+)$", "distro.views.releaseview")
65+ )
66
67=== modified file 'distro/views.py'
68--- distro/views.py 2012-09-20 02:08:20 +0000
69+++ distro/views.py 2012-10-19 13:46:19 +0000
70@@ -1,1 +1,29 @@
71-# Create your views here.
72+import datetime
73+import distro.models as models
74+from django.shortcuts import render_to_response, get_object_or_404
75+from django.template import Context
76+
77+def index(request):
78+ distros = models.Distro.objects.all()
79+ ctx = Context({'distros': distros})
80+ return render_to_response ('index.html', ctx)
81+
82+def distroview(request, distro_name):
83+ distro = get_object_or_404(models.Distro, name=distro_name)
84+ releases = models.DistroRelease.objects.filter(distro=distro, expiration_date__gt=datetime.date.today()).order_by('-release_date')
85+ ctx = Context({
86+ 'distro': distro,
87+ 'releases': releases
88+ })
89+ return render_to_response ('distro.html', ctx)
90+
91+def releaseview(request, distro_name, release_version):
92+ distro_release = get_object_or_404(models.DistroRelease, distro__name=distro_name, version=release_version)
93+ platform_items = models.PlatformItem.objects.filter(distro_release=distro_release)
94+
95+ ctx = Context({
96+ 'distro': distro_release.distro,
97+ 'release': distro_release,
98+ 'platform_items': platform_items
99+ })
100+ return render_to_response ('release.html', ctx)
101
102=== added file 'distro_data.json'
103--- distro_data.json 1970-01-01 00:00:00 +0000
104+++ distro_data.json 2012-10-19 13:46:19 +0000
105@@ -0,0 +1,161 @@
106+[
107+ {
108+ "pk": 1,
109+ "model": "distro.distro",
110+ "fields": {
111+ "website": "http://www.ubuntu.com",
112+ "name": "Ubuntu",
113+ "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nec nisl id metus tempor imperdiet. Integer hendrerit purus eget risus feugiat auctor. Aenean eget mi tincidunt velit ornare gravida et sed urna. Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam aliquam nibh eget massa tincidunt porttitor. Aenean et ornare turpis."
114+ }
115+ },
116+ {
117+ "pk": 2,
118+ "model": "distro.distro",
119+ "fields": {
120+ "website": "http://www.edubuntu.org",
121+ "name": "Edubuntu",
122+ "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nec nisl id metus tempor imperdiet. Integer hendrerit purus eget risus feugiat auctor. Aenean eget mi tincidunt velit ornare gravida et sed urna. Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam aliquam nibh eget massa tincidunt porttitor. Aenean et ornare turpis."
123+ }
124+ },
125+ {
126+ "pk": 3,
127+ "model": "distro.distro",
128+ "fields": {
129+ "website": "http://www.kubuntu.org",
130+ "name": "Kubuntu",
131+ "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nec nisl id metus tempor imperdiet. Integer hendrerit purus eget risus feugiat auctor. Aenean eget mi tincidunt velit ornare gravida et sed urna. Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam aliquam nibh eget massa tincidunt porttitor. Aenean et ornare turpis."
132+ }
133+ },
134+ {
135+ "pk": 1,
136+ "model": "distro.distrorelease",
137+ "fields": {
138+ "expiration_date": "2017-04-26",
139+ "codename": "Precise Pengolin",
140+ "version": "12.04",
141+ "release_date": "2012-04-26",
142+ "distro": 1
143+ }
144+ },
145+ {
146+ "pk": 2,
147+ "model": "distro.distrorelease",
148+ "fields": {
149+ "expiration_date": "2013-04-01",
150+ "codename": "Oneiric Ocelot",
151+ "version": "11.10",
152+ "release_date": "2011-10-13",
153+ "distro": 1
154+ }
155+ },
156+ {
157+ "pk": 3,
158+ "model": "distro.distrorelease",
159+ "fields": {
160+ "expiration_date": "2012-10-01",
161+ "codename": "Natty Narwhal",
162+ "version": "11.04",
163+ "release_date": "2011-04-28",
164+ "distro": 1
165+ }
166+ },
167+ {
168+ "pk": 4,
169+ "model": "distro.distrorelease",
170+ "fields": {
171+ "expiration_date": "2012-04-10",
172+ "codename": "Maverick Meerkat",
173+ "version": "10.10",
174+ "release_date": "2010-10-10",
175+ "distro": 1
176+ }
177+ },
178+ {
179+ "pk": 5,
180+ "model": "distro.distrorelease",
181+ "fields": {
182+ "expiration_date": "2013-04-01",
183+ "codename": "Lucid Lynx",
184+ "version": "10.04",
185+ "release_date": "2010-04-29",
186+ "distro": 1
187+ }
188+ },
189+ {
190+ "pk": 6,
191+ "model": "distro.distrorelease",
192+ "fields": {
193+ "expiration_date": "2011-04-30",
194+ "codename": "Karmic Koala",
195+ "version": "9.10",
196+ "release_date": "2009-10-29",
197+ "distro": 1
198+ }
199+ },
200+ {
201+ "pk": 7,
202+ "model": "distro.distrorelease",
203+ "fields": {
204+ "expiration_date": "2011-04-28",
205+ "codename": "Karmic Koala",
206+ "version": "9.10",
207+ "release_date": "2009-10-29",
208+ "distro": 3
209+ }
210+ },
211+ {
212+ "pk": 8,
213+ "model": "distro.distrorelease",
214+ "fields": {
215+ "expiration_date": "2013-04-01",
216+ "codename": "Lucid Lynx",
217+ "version": "10.04",
218+ "release_date": "2010-04-29",
219+ "distro": 3
220+ }
221+ },
222+ {
223+ "pk": 9,
224+ "model": "distro.distrorelease",
225+ "fields": {
226+ "expiration_date": "2012-04-01",
227+ "codename": "Maverick Meerkat",
228+ "version": "10.10",
229+ "release_date": "2010-10-10",
230+ "distro": 3
231+ }
232+ },
233+ {
234+ "pk": 10,
235+ "model": "distro.distrorelease",
236+ "fields": {
237+ "expiration_date": "2012-10-01",
238+ "codename": "Natty Narwhal",
239+ "version": "11.04",
240+ "release_date": "2011-04-28",
241+ "distro": 3
242+ }
243+ },
244+ {
245+ "pk": 11,
246+ "model": "distro.distrorelease",
247+ "fields": {
248+ "expiration_date": "2013-04-01",
249+ "codename": "Oneiric Ocelot",
250+ "version": "11.10",
251+ "release_date": "2011-10-13",
252+ "distro": 3
253+ }
254+ },
255+ {
256+ "pk": 12,
257+ "model": "distro.distrorelease",
258+ "fields": {
259+ "expiration_date": "2017-04-01",
260+ "codename": "Precise Pangolin",
261+ "version": "12.04",
262+ "release_date": "2012-04-26",
263+ "distro": 3
264+ }
265+ }
266+]
267\ No newline at end of file
268
269=== modified file 'lang/models.py'
270--- lang/models.py 2012-09-20 02:08:20 +0000
271+++ lang/models.py 2012-10-19 13:46:19 +0000
272@@ -1,3 +1,11 @@
273 from django.db import models
274
275-# Create your models here.
276+CF_MAX_LENGTH = 500
277+
278+class ProgrammingLang(models.Model):
279+ language_name = models.CharField(max_length=CF_MAX_LENGTH)
280+ translator = models.URLField(max_length=CF_MAX_LENGTH)
281+
282+class LanguageNamespace(models.Model):
283+ language = models.ForeignKey(ProgrammingLang)
284+ namespace = models.ForeignKey('api.Namespace')
285
286=== modified file 'support/models.py'
287--- support/models.py 2012-09-20 02:08:20 +0000
288+++ support/models.py 2012-10-19 13:46:19 +0000
289@@ -1,3 +1,24 @@
290 from django.db import models
291
292-# Create your models here.
293+CF_MAX_LENGTH = 500
294+
295+class RelatedQuestion(models.Model):
296+ node = models.ForeignKey('api.Node')
297+ question_text = models.CharField(max_length=CF_MAX_LENGTH)
298+ question_url = models.URLField(max_length=CF_MAX_LENGTH)
299+
300+class RelatedTutorial(models.Model):
301+ node = models.ForeignKey('api.Node')
302+ tutorial_name = models.CharField(max_length=CF_MAX_LENGTH)
303+ tutorial_url = models.URLField(max_length=CF_MAX_LENGTH)
304+
305+class RelatedSnippets(models.Model):
306+ node = models.ForeignKey('api.Node')
307+ snippet_name = models.CharField(max_length=CF_MAX_LENGTH)
308+ snippet_code = models.TextField()
309+
310+class RelatedImage(models.Model):
311+ node = models.ForeignKey('api.Node')
312+ image_name = models.CharField(max_length=CF_MAX_LENGTH)
313+ image_caption = models.CharField(max_length=CF_MAX_LENGTH)
314+ image_url = models.URLField(max_length=CF_MAX_LENGTH)
315
316=== added file 'templates/distro.html'
317--- templates/distro.html 1970-01-01 00:00:00 +0000
318+++ templates/distro.html 2012-10-19 13:46:19 +0000
319@@ -0,0 +1,16 @@
320+{% extends "base.html" %}
321+
322+{% block title %}Distro Overview {% endblock %}
323+
324+{% block content %}
325+
326+<h2>{{ distro.name }}</h2><a href="{{ distro.website }}">{{ distro.website }}</a>
327+<p>{{ distro.description }}</p>
328+
329+<ul>
330+ {% for release in releases %}
331+ <li><a href="{% url distro.views.releaseview distro.name release.version %}">{{ release.version }} ({{ release.codename }})</a></li>
332+ {% endfor %}
333+</ul>
334+
335+{% endblock %}
336
337=== added file 'templates/index.html'
338--- templates/index.html 1970-01-01 00:00:00 +0000
339+++ templates/index.html 2012-10-19 13:46:19 +0000
340@@ -0,0 +1,15 @@
341+{% extends "base.html" %}
342+
343+{% block title %}API Index {% endblock %}
344+
345+{% block content %}
346+
347+<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nec nisl id metus tempor imperdiet. Integer hendrerit purus eget risus feugiat auctor. Aenean eget mi tincidunt velit ornare gravida et sed urna. Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam aliquam nibh eget massa tincidunt porttitor. Aenean et ornare turpis.</p>
348+
349+<ul>
350+ {% for distro in distros %}
351+ <li><a href="{% url distro.views.distroview distro.name %}">{{ distro.name }}</a></li>
352+ {% endfor %}
353+</ul>
354+
355+{% endblock %}
356
357=== added file 'templates/release.html'
358--- templates/release.html 1970-01-01 00:00:00 +0000
359+++ templates/release.html 2012-10-19 13:46:19 +0000
360@@ -0,0 +1,15 @@
361+{% extends "base.html" %}
362+
363+{% block title %}Release Overview {% endblock %}
364+
365+{% block content %}
366+
367+<h2>{{ distro.name }} {{ release.version }}</h2>
368+
369+<ul>
370+ {% for platform_item in platform_items %}
371+ {{ platform_item }}
372+ {% endfor %}
373+</ul>
374+
375+{% endblock %}
376
377=== modified file 'urls.py'
378--- urls.py 2012-02-23 02:07:50 +0000
379+++ urls.py 2012-10-19 13:46:19 +0000
380@@ -9,7 +9,8 @@
381 # Examples:
382 # url(r'^$', 'gnome_developer_network.views.home', name='home'),
383 # url(r'^gnome_developer_network/', include('gnome_developer_network.foo.urls')),
384- url(r'^api/', include('api.urls')),
385+ url(r'^api/', include('distro.urls')),
386+ url(r'^all/', include('api.urls')),
387
388 # Uncomment the admin/doc line below to enable admin documentation:
389 # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

Subscribers

People subscribed via source and target branches