new file mode 100644
@@ -0,0 +1,27 @@
+# Patchwork - automated patch tracking system
+# Copyright (C) 2014 Intel Corporation
+#
+# This file is part of the Patchwork package.
+#
+# Patchwork is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Patchwork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Patchwork; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from patchwork.models import Project
+from rest_framework import serializers
+
+class ProjectSerializer(serializers.HyperlinkedModelSerializer):
+ class Meta:
+ model = Project
+ fields = ('name', 'linkname', 'listemail', 'web_url', 'scm_url',
+ 'webscm_url')
new file mode 100644
@@ -0,0 +1,36 @@
+# Patchwork - automated patch tracking system
+# Copyright (C) 2014 Intel Corporation
+#
+# This file is part of the Patchwork package.
+#
+# Patchwork is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Patchwork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Patchwork; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from patchwork.models import Project
+from rest_framework import viewsets
+from rest_framework.response import Response
+from patchwork.serializers import ProjectSerializer
+
+class ProjectViewSet(viewsets.ViewSet):
+ model = Project
+
+ def list(self, request):
+ queryset = Project.objects.all()
+ serializer = ProjectSerializer(queryset, many=True)
+ return Response(serializer.data)
+
+ def retrieve(self, request, pk=None):
+ queryset = Project.objects.get(name=pk)
+ serializer = ProjectSerializer(queryset)
+ return Response(serializer.data)
@@ -21,12 +21,24 @@ from django.conf.urls import patterns, url, include
from django.conf import settings
from django.contrib import admin
from django.contrib.auth import views as auth_views
+from rest_framework_nested import routers
+import patchwork.views.api as api
+
+# API
+
+# /projects/$project/
+project_router = routers.SimpleRouter()
+project_router.register('projects', api.ProjectViewSet)
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
+ # API
+ (r'^api/1.0/', include(project_router.urls)),
+
+ # Example:
(r'^$', 'patchwork.views.projects'),
(r'^project/(?P<project_id>[^/]+)/list/$', 'patchwork.views.patch.list'),
(r'^project/(?P<project_id>[^/]+)/$', 'patchwork.views.project.project'),
We'll expose Series and Patches as sub-urls of projects. So they are a good object to start with. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com> --- apps/patchwork/serializers.py | 27 +++++++++++++++++++++++++++ apps/patchwork/views/api.py | 36 ++++++++++++++++++++++++++++++++++++ patchwork/urls.py | 12 ++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 apps/patchwork/serializers.py create mode 100644 apps/patchwork/views/api.py