Merge lp:~cjohnston/ubuntu-ci-services-itself/ts-people into lp:ubuntu-ci-services-itself

Proposed by Chris Johnston
Status: Merged
Approved by: Chris Johnston
Approved revision: 20
Merged at revision: 18
Proposed branch: lp:~cjohnston/ubuntu-ci-services-itself/ts-people
Merge into: lp:ubuntu-ci-services-itself
Prerequisite: lp:~cjohnston/ubuntu-ci-services-itself/ticket-system
Diff against target: 289 lines (+217/-2)
9 files modified
ticket_system/people/__init__.py (+15/-0)
ticket_system/people/admin.py (+26/-0)
ticket_system/people/api.py (+30/-0)
ticket_system/people/migrations/0001_initial.py (+36/-0)
ticket_system/people/models.py (+29/-0)
ticket_system/people/tests.py (+72/-0)
ticket_system/setup.py (+4/-0)
ticket_system/ticket_system/settings.py (+0/-2)
ticket_system/ticket_system/urls.py (+5/-0)
To merge this branch: bzr merge lp:~cjohnston/ubuntu-ci-services-itself/ts-people
Reviewer Review Type Date Requested Status
Andy Doan (community) Approve
Chris Johnston (community) Needs Resubmitting
Review via email: mp+198297@code.launchpad.net

Commit message

Add people app to ticket-system with read api

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

157 + email = models.EmailField(max_length=200)

Can you document why that's a shorter length than the name field?

Since this is a "get-only" api, should we add a unit-test to confirm that or will this become a read-write very soon?

Revision history for this message
Chris Johnston (cjohnston) wrote :

It will become read-write soon.

review: Needs Resubmitting
Revision history for this message
Andy Doan (doanac) wrote :

LGTM

review: Approve
Revision history for this message
Chris Johnston (cjohnston) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'ticket_system/people'
=== added file 'ticket_system/people/__init__.py'
--- ticket_system/people/__init__.py 1970-01-01 00:00:00 +0000
+++ ticket_system/people/__init__.py 2013-12-09 18:58:11 +0000
@@ -0,0 +1,15 @@
1# Houston
2# Ubuntu Continuous Integration Engine
3# Copyright 2013 Canonical Ltd.
4
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3, as
7# published by the Free Software Foundation.
8
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU Affero General Public License for more details.
13
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
016
=== added file 'ticket_system/people/admin.py'
--- ticket_system/people/admin.py 1970-01-01 00:00:00 +0000
+++ ticket_system/people/admin.py 2013-12-09 18:58:11 +0000
@@ -0,0 +1,26 @@
1# Houston
2# Ubuntu Continuous Integration Engine
3# Copyright 2013 Canonical Ltd.
4
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3, as
7# published by the Free Software Foundation.
8
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU Affero General Public License for more details.
13
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from django.contrib import admin
18from people.models import Person
19
20
21class PersonAdmin(admin.ModelAdmin):
22 list_filter = ['is_team']
23 search_fields = ['name', 'email']
24 list_display = ('name', 'email', 'is_team')
25
26admin.site.register(Person, PersonAdmin)
027
=== added file 'ticket_system/people/api.py'
--- ticket_system/people/api.py 1970-01-01 00:00:00 +0000
+++ ticket_system/people/api.py 2013-12-09 18:58:11 +0000
@@ -0,0 +1,30 @@
1# Houston
2# Ubuntu Continuous Integration Engine
3# Copyright 2013 Canonical Ltd.
4
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3, as
7# published by the Free Software Foundation.
8
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU Affero General Public License for more details.
13
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from tastypie.resources import ModelResource
18from tastypie.constants import ALL
19from people.models import Person
20
21
22class PersonResource(ModelResource):
23 class Meta:
24 queryset = Person.objects.all()
25 allowed_methods = ['get']
26 filtering = {
27 "name": ('exact', 'startswith'),
28 "email": ('exact', 'startswith'),
29 "is_team": ALL,
30 }
031
=== added directory 'ticket_system/people/migrations'
=== added file 'ticket_system/people/migrations/0001_initial.py'
--- ticket_system/people/migrations/0001_initial.py 1970-01-01 00:00:00 +0000
+++ ticket_system/people/migrations/0001_initial.py 2013-12-09 18:58:11 +0000
@@ -0,0 +1,36 @@
1# -*- coding: utf-8 -*-
2import datetime
3from south.db import db
4from south.v2 import SchemaMigration
5from django.db import models
6
7
8class Migration(SchemaMigration):
9
10 def forwards(self, orm):
11 # Adding model 'Person'
12 db.create_table('person', (
13 (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
14 ('name', self.gf('django.db.models.fields.CharField')(max_length=4096)),
15 ('email', self.gf('django.db.models.fields.EmailField')(max_length=4096)),
16 ('is_team', self.gf('django.db.models.fields.BooleanField')(default=False)),
17 ))
18 db.send_create_signal(u'people', ['Person'])
19
20
21 def backwards(self, orm):
22 # Deleting model 'Person'
23 db.delete_table('person')
24
25
26 models = {
27 u'people.person': {
28 'Meta': {'object_name': 'Person', 'db_table': "'person'"},
29 'email': ('django.db.models.fields.EmailField', [], {'max_length': '4096'}),
30 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
31 'is_team': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
32 'name': ('django.db.models.fields.CharField', [], {'max_length': '4096'})
33 }
34 }
35
36 complete_apps = ['people']
0\ No newline at end of file37\ No newline at end of file
138
=== added file 'ticket_system/people/migrations/__init__.py'
=== added file 'ticket_system/people/models.py'
--- ticket_system/people/models.py 1970-01-01 00:00:00 +0000
+++ ticket_system/people/models.py 2013-12-09 18:58:11 +0000
@@ -0,0 +1,29 @@
1# Houston
2# Ubuntu Continuous Integration Engine
3# Copyright 2013 Canonical Ltd.
4
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3, as
7# published by the Free Software Foundation.
8
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU Affero General Public License for more details.
13
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from django.db import models
18
19
20class Person(models.Model):
21 class Meta:
22 db_table = 'person'
23
24 name = models.CharField(max_length=4096)
25 email = models.EmailField(max_length=4096)
26 is_team = models.BooleanField(default=False)
27
28 def __unicode__(self):
29 return self.name
030
=== added file 'ticket_system/people/tests.py'
--- ticket_system/people/tests.py 1970-01-01 00:00:00 +0000
+++ ticket_system/people/tests.py 2013-12-09 18:58:11 +0000
@@ -0,0 +1,72 @@
1# Houston
2# Ubuntu Continuous Integration Engine
3# Copyright 2013 Canonical Ltd.
4
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3, as
7# published by the Free Software Foundation.
8
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU Affero General Public License for more details.
13
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from django.test import TestCase
18from tastypie.test import ResourceTestCase
19from people.models import Person
20
21
22def create_person(name="Chris Johnston",
23 email="chris.johnston@canonical.com", is_team=False):
24 person = Person()
25 person.name = name
26 person.email = email
27 person.is_team = is_team
28 person.save()
29 return person
30
31
32class PersonModelTest(TestCase):
33
34 def test_creating_a_person(self):
35 person = create_person()
36 people_in_database = Person.objects.all()
37 self.assertEquals(len(people_in_database), 1)
38 only_person_in_database = people_in_database[0]
39 self.assertEquals(only_person_in_database, person)
40
41 self.assertEquals(only_person_in_database.name, "Chris Johnston")
42 self.assertEquals(only_person_in_database.email,
43 "chris.johnston@canonical.com")
44
45
46class PersonResourceTest(ResourceTestCase):
47
48 def setUp(self):
49 super(PersonResourceTest, self).setUp()
50 create_person()
51 self.person_1 = Person.objects.get(name='Chris Johnston')
52 self.detail_url = '/api/v1/person/{0}/'.format(self.person_1.pk)
53
54 def test_get_person_list_json(self):
55 resp = self.api_client.get('/api/v1/person/', format='json')
56 self.assertValidJSONResponse(resp)
57 self.assertEqual(len(self.deserialize(resp)['objects']), 1)
58 self.assertEqual(self.deserialize(resp)['objects'][0], {
59 u'email': u'chris.johnston@canonical.com',
60 u'id': self.person_1.pk,
61 u'is_team': False,
62 u'name': u'Chris Johnston',
63 u'resource_uri': u'/api/v1/person/{0}/'.format(self.person_1.pk)
64 })
65
66 def test_get_person_detail_json(self):
67 resp = self.api_client.get(self.detail_url)
68 self.assertValidJSONResponse(resp)
69
70 self.assertKeys(self.deserialize(resp),
71 ['email', 'id', 'is_team', 'name', 'resource_uri'])
72 self.assertEqual(self.deserialize(resp)['name'], 'Chris Johnston')
073
=== modified file 'ticket_system/setup.py'
--- ticket_system/setup.py 2013-12-09 18:58:11 +0000
+++ ticket_system/setup.py 2013-12-09 18:58:11 +0000
@@ -14,6 +14,10 @@
14# You should have received a copy of the GNU Affero General Public License14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17
18# TODO make this probe from changelog or bzr
19__version__ = '0.1'
20
17import os21import os
18import sys22import sys
1923
2024
=== modified file 'ticket_system/ticket_system/settings.py'
--- ticket_system/ticket_system/settings.py 2013-12-09 18:58:11 +0000
+++ ticket_system/ticket_system/settings.py 2013-12-09 18:58:11 +0000
@@ -140,8 +140,6 @@
140140
141LOCAL_APPS = (141LOCAL_APPS = (
142 'people',142 'people',
143 'project',
144 'ticket',
145)143)
146144
147INSTALLED_APPS = LOCAL_APPS + INSTALLED_APPS145INSTALLED_APPS = LOCAL_APPS + INSTALLED_APPS
148146
=== modified file 'ticket_system/ticket_system/urls.py'
--- ticket_system/ticket_system/urls.py 2013-12-09 18:58:11 +0000
+++ ticket_system/ticket_system/urls.py 2013-12-09 18:58:11 +0000
@@ -15,10 +15,15 @@
1515
16from django.conf.urls import patterns, include, url16from django.conf.urls import patterns, include, url
17from django.contrib import admin17from django.contrib import admin
18from tastypie.api import Api
19from people.api import PersonResource
1820
19admin.autodiscover()21admin.autodiscover()
22v1_api = Api(api_name='v1')
23v1_api.register(PersonResource())
2024
21urlpatterns = patterns(25urlpatterns = patterns(
22 '',26 '',
27 (r'^api/', include(v1_api.urls)),
23 url(r'^admin/', include(admin.site.urls)),28 url(r'^admin/', include(admin.site.urls)),
24)29)

Subscribers

People subscribed via source and target branches