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

Proposed by Victor Choueiri
Status: Merged
Approved by: John Vrbanac
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 Approve
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

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

Revision history for this message
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

Adding docbook to html xsl transform on the class view

87. By John Vrbanac

Forgot to remove pdb import on last commit

Revision history for this message
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.

Revision history for this message
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!

Revision history for this message
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

Revision history for this message
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

Accepting Victor's merge request.

Revision history for this message
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
=== modified file 'DEVELOPMENT'
--- DEVELOPMENT 2012-10-07 04:53:33 +0000
+++ DEVELOPMENT 2012-10-19 13:46:19 +0000
@@ -32,11 +32,15 @@
3232
33 python manage.py import-girs 33 python manage.py import-girs
3434
356. Run the Django test server356. Load the initial distro data
36
37 python manage.py loaddata distro_data.json
38
397. Run the Django test server
3640
37 python manage.py runserver41 python manage.py runserver
3842
397. View the site438. View the site
4044
41 Open your browser to http://localhost:8000/api/45 Open your browser to http://localhost:8000/api/
4246
4347
=== modified file 'distro/models.py'
--- distro/models.py 2012-09-20 02:08:20 +0000
+++ distro/models.py 2012-10-19 13:46:19 +0000
@@ -1,3 +1,25 @@
1from django.db import models1from django.db import models
22
3# Create your models here.3CF_MAX_LENGTH = 500
4
5class Distro(models.Model):
6 name = models.CharField(max_length=CF_MAX_LENGTH)
7 website = models.URLField(max_length=CF_MAX_LENGTH)
8 description = models.TextField(blank=True)
9
10class DistroRelease(models.Model):
11 distro = models.ForeignKey(Distro)
12 version = models.CharField(max_length=CF_MAX_LENGTH)
13 codename = models.CharField(max_length=CF_MAX_LENGTH)
14 release_date = models.DateField()
15 expiration_date = models.DateField()
16
17class PlatformSection(models.Model):
18 section_name = models.CharField(max_length=CF_MAX_LENGTH)
19 section_description = models.TextField(blank=True)
20
21class PlatformItem(models.Model):
22 distro_release = models.ForeignKey(DistroRelease)
23 library_release = models.ForeignKey('api.Namespace')
24 section = models.ForeignKey(PlatformSection)
25 packages = models.TextField(blank=True)
426
=== added file 'distro/urls.py'
--- distro/urls.py 1970-01-01 00:00:00 +0000
+++ distro/urls.py 2012-10-19 13:46:19 +0000
@@ -0,0 +1,8 @@
1# vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4
2from django.conf.urls.defaults import patterns, include, url
3
4urlpatterns = patterns('',
5 url("^$", "distro.views.index"),
6 url("^(?P<distro_name>[\w]+)/$", "distro.views.distroview"),
7 url("^(?P<distro_name>[\w]+)/(?P<release_version>[\w\\.]+)$", "distro.views.releaseview")
8 )
09
=== modified file 'distro/views.py'
--- distro/views.py 2012-09-20 02:08:20 +0000
+++ distro/views.py 2012-10-19 13:46:19 +0000
@@ -1,1 +1,29 @@
1# Create your views here.1import datetime
2import distro.models as models
3from django.shortcuts import render_to_response, get_object_or_404
4from django.template import Context
5
6def index(request):
7 distros = models.Distro.objects.all()
8 ctx = Context({'distros': distros})
9 return render_to_response ('index.html', ctx)
10
11def distroview(request, distro_name):
12 distro = get_object_or_404(models.Distro, name=distro_name)
13 releases = models.DistroRelease.objects.filter(distro=distro, expiration_date__gt=datetime.date.today()).order_by('-release_date')
14 ctx = Context({
15 'distro': distro,
16 'releases': releases
17 })
18 return render_to_response ('distro.html', ctx)
19
20def releaseview(request, distro_name, release_version):
21 distro_release = get_object_or_404(models.DistroRelease, distro__name=distro_name, version=release_version)
22 platform_items = models.PlatformItem.objects.filter(distro_release=distro_release)
23
24 ctx = Context({
25 'distro': distro_release.distro,
26 'release': distro_release,
27 'platform_items': platform_items
28 })
29 return render_to_response ('release.html', ctx)
230
=== added file 'distro_data.json'
--- distro_data.json 1970-01-01 00:00:00 +0000
+++ distro_data.json 2012-10-19 13:46:19 +0000
@@ -0,0 +1,161 @@
1[
2 {
3 "pk": 1,
4 "model": "distro.distro",
5 "fields": {
6 "website": "http://www.ubuntu.com",
7 "name": "Ubuntu",
8 "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."
9 }
10 },
11 {
12 "pk": 2,
13 "model": "distro.distro",
14 "fields": {
15 "website": "http://www.edubuntu.org",
16 "name": "Edubuntu",
17 "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."
18 }
19 },
20 {
21 "pk": 3,
22 "model": "distro.distro",
23 "fields": {
24 "website": "http://www.kubuntu.org",
25 "name": "Kubuntu",
26 "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."
27 }
28 },
29 {
30 "pk": 1,
31 "model": "distro.distrorelease",
32 "fields": {
33 "expiration_date": "2017-04-26",
34 "codename": "Precise Pengolin",
35 "version": "12.04",
36 "release_date": "2012-04-26",
37 "distro": 1
38 }
39 },
40 {
41 "pk": 2,
42 "model": "distro.distrorelease",
43 "fields": {
44 "expiration_date": "2013-04-01",
45 "codename": "Oneiric Ocelot",
46 "version": "11.10",
47 "release_date": "2011-10-13",
48 "distro": 1
49 }
50 },
51 {
52 "pk": 3,
53 "model": "distro.distrorelease",
54 "fields": {
55 "expiration_date": "2012-10-01",
56 "codename": "Natty Narwhal",
57 "version": "11.04",
58 "release_date": "2011-04-28",
59 "distro": 1
60 }
61 },
62 {
63 "pk": 4,
64 "model": "distro.distrorelease",
65 "fields": {
66 "expiration_date": "2012-04-10",
67 "codename": "Maverick Meerkat",
68 "version": "10.10",
69 "release_date": "2010-10-10",
70 "distro": 1
71 }
72 },
73 {
74 "pk": 5,
75 "model": "distro.distrorelease",
76 "fields": {
77 "expiration_date": "2013-04-01",
78 "codename": "Lucid Lynx",
79 "version": "10.04",
80 "release_date": "2010-04-29",
81 "distro": 1
82 }
83 },
84 {
85 "pk": 6,
86 "model": "distro.distrorelease",
87 "fields": {
88 "expiration_date": "2011-04-30",
89 "codename": "Karmic Koala",
90 "version": "9.10",
91 "release_date": "2009-10-29",
92 "distro": 1
93 }
94 },
95 {
96 "pk": 7,
97 "model": "distro.distrorelease",
98 "fields": {
99 "expiration_date": "2011-04-28",
100 "codename": "Karmic Koala",
101 "version": "9.10",
102 "release_date": "2009-10-29",
103 "distro": 3
104 }
105 },
106 {
107 "pk": 8,
108 "model": "distro.distrorelease",
109 "fields": {
110 "expiration_date": "2013-04-01",
111 "codename": "Lucid Lynx",
112 "version": "10.04",
113 "release_date": "2010-04-29",
114 "distro": 3
115 }
116 },
117 {
118 "pk": 9,
119 "model": "distro.distrorelease",
120 "fields": {
121 "expiration_date": "2012-04-01",
122 "codename": "Maverick Meerkat",
123 "version": "10.10",
124 "release_date": "2010-10-10",
125 "distro": 3
126 }
127 },
128 {
129 "pk": 10,
130 "model": "distro.distrorelease",
131 "fields": {
132 "expiration_date": "2012-10-01",
133 "codename": "Natty Narwhal",
134 "version": "11.04",
135 "release_date": "2011-04-28",
136 "distro": 3
137 }
138 },
139 {
140 "pk": 11,
141 "model": "distro.distrorelease",
142 "fields": {
143 "expiration_date": "2013-04-01",
144 "codename": "Oneiric Ocelot",
145 "version": "11.10",
146 "release_date": "2011-10-13",
147 "distro": 3
148 }
149 },
150 {
151 "pk": 12,
152 "model": "distro.distrorelease",
153 "fields": {
154 "expiration_date": "2017-04-01",
155 "codename": "Precise Pangolin",
156 "version": "12.04",
157 "release_date": "2012-04-26",
158 "distro": 3
159 }
160 }
161]
0\ No newline at end of file162\ No newline at end of file
1163
=== modified file 'lang/models.py'
--- lang/models.py 2012-09-20 02:08:20 +0000
+++ lang/models.py 2012-10-19 13:46:19 +0000
@@ -1,3 +1,11 @@
1from django.db import models1from django.db import models
22
3# Create your models here.3CF_MAX_LENGTH = 500
4
5class ProgrammingLang(models.Model):
6 language_name = models.CharField(max_length=CF_MAX_LENGTH)
7 translator = models.URLField(max_length=CF_MAX_LENGTH)
8
9class LanguageNamespace(models.Model):
10 language = models.ForeignKey(ProgrammingLang)
11 namespace = models.ForeignKey('api.Namespace')
412
=== modified file 'support/models.py'
--- support/models.py 2012-09-20 02:08:20 +0000
+++ support/models.py 2012-10-19 13:46:19 +0000
@@ -1,3 +1,24 @@
1from django.db import models1from django.db import models
22
3# Create your models here.3CF_MAX_LENGTH = 500
4
5class RelatedQuestion(models.Model):
6 node = models.ForeignKey('api.Node')
7 question_text = models.CharField(max_length=CF_MAX_LENGTH)
8 question_url = models.URLField(max_length=CF_MAX_LENGTH)
9
10class RelatedTutorial(models.Model):
11 node = models.ForeignKey('api.Node')
12 tutorial_name = models.CharField(max_length=CF_MAX_LENGTH)
13 tutorial_url = models.URLField(max_length=CF_MAX_LENGTH)
14
15class RelatedSnippets(models.Model):
16 node = models.ForeignKey('api.Node')
17 snippet_name = models.CharField(max_length=CF_MAX_LENGTH)
18 snippet_code = models.TextField()
19
20class RelatedImage(models.Model):
21 node = models.ForeignKey('api.Node')
22 image_name = models.CharField(max_length=CF_MAX_LENGTH)
23 image_caption = models.CharField(max_length=CF_MAX_LENGTH)
24 image_url = models.URLField(max_length=CF_MAX_LENGTH)
425
=== added file 'templates/distro.html'
--- templates/distro.html 1970-01-01 00:00:00 +0000
+++ templates/distro.html 2012-10-19 13:46:19 +0000
@@ -0,0 +1,16 @@
1{% extends "base.html" %}
2
3{% block title %}Distro Overview {% endblock %}
4
5{% block content %}
6
7<h2>{{ distro.name }}</h2><a href="{{ distro.website }}">{{ distro.website }}</a>
8<p>{{ distro.description }}</p>
9
10<ul>
11 {% for release in releases %}
12 <li><a href="{% url distro.views.releaseview distro.name release.version %}">{{ release.version }} ({{ release.codename }})</a></li>
13 {% endfor %}
14</ul>
15
16{% endblock %}
017
=== added file 'templates/index.html'
--- templates/index.html 1970-01-01 00:00:00 +0000
+++ templates/index.html 2012-10-19 13:46:19 +0000
@@ -0,0 +1,15 @@
1{% extends "base.html" %}
2
3{% block title %}API Index {% endblock %}
4
5{% block content %}
6
7<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>
8
9<ul>
10 {% for distro in distros %}
11 <li><a href="{% url distro.views.distroview distro.name %}">{{ distro.name }}</a></li>
12 {% endfor %}
13</ul>
14
15{% endblock %}
016
=== added file 'templates/release.html'
--- templates/release.html 1970-01-01 00:00:00 +0000
+++ templates/release.html 2012-10-19 13:46:19 +0000
@@ -0,0 +1,15 @@
1{% extends "base.html" %}
2
3{% block title %}Release Overview {% endblock %}
4
5{% block content %}
6
7<h2>{{ distro.name }} {{ release.version }}</h2>
8
9<ul>
10 {% for platform_item in platform_items %}
11 {{ platform_item }}
12 {% endfor %}
13</ul>
14
15{% endblock %}
016
=== modified file 'urls.py'
--- urls.py 2012-02-23 02:07:50 +0000
+++ urls.py 2012-10-19 13:46:19 +0000
@@ -9,7 +9,8 @@
9 # Examples:9 # Examples:
10 # url(r'^$', 'gnome_developer_network.views.home', name='home'),10 # url(r'^$', 'gnome_developer_network.views.home', name='home'),
11 # url(r'^gnome_developer_network/', include('gnome_developer_network.foo.urls')),11 # url(r'^gnome_developer_network/', include('gnome_developer_network.foo.urls')),
12 url(r'^api/', include('api.urls')),12 url(r'^api/', include('distro.urls')),
13 url(r'^all/', include('api.urls')),
1314
14 # Uncomment the admin/doc line below to enable admin documentation:15 # Uncomment the admin/doc line below to enable admin documentation:
15 # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),16 # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

Subscribers

People subscribed via source and target branches