From 4e6df8ba441ea55c3a3da739b73c2fbc78f50b2d Mon Sep 17 00:00:00 2001 From: David Moreau Simard Date: Thu, 8 Mar 2018 18:16:16 -0500 Subject: [PATCH] Add missing views and URLs to cover the entire model Change-Id: I96ba3d8174ef9f81d80a560105fdd1f11a34817d --- api/urls.py | 21 +++++++++++++++++++++ api/views.py | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/api/urls.py b/api/urls.py index c6ca7ca..0455b4b 100644 --- a/api/urls.py +++ b/api/urls.py @@ -1,3 +1,20 @@ +# Copyright (c) 2018 Red Hat, Inc. +# +# This file is part of ARA Records Ansible. +# +# ARA 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 3 of the License, or +# (at your option) any later version. +# +# ARA 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 ARA. If not, see . + from django.conf.urls import url, include from rest_framework.routers import DefaultRouter @@ -5,6 +22,10 @@ from api import views router = DefaultRouter() router.register(r'playbooks', views.PlaybookViewSet, base_name='playbooks') +router.register(r'plays', views.PlayViewSet, base_name='plays') +router.register(r'tasks', views.TaskViewSet, base_name='tasks') +router.register(r'hosts', views.HostViewSet, base_name='hosts') +router.register(r'results', views.ResultViewSet, base_name='results') router.register(r'records', views.RecordViewSet, base_name='records') router.register(r'files', views.FileViewSet, base_name='files') diff --git a/api/views.py b/api/views.py index 04243e2..2bff5b5 100644 --- a/api/views.py +++ b/api/views.py @@ -1,3 +1,20 @@ +# Copyright (c) 2018 Red Hat, Inc. +# +# This file is part of ARA Records Ansible. +# +# ARA 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 3 of the License, or +# (at your option) any later version. +# +# ARA 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 ARA. If not, see . + from api import models, serializers from rest_framework import viewsets @@ -8,11 +25,31 @@ class PlaybookViewSet(viewsets.ModelViewSet): serializer_class = serializers.PlaybookSerializer -class FileViewSet(viewsets.ModelViewSet): - queryset = models.File.objects.all() - serializer_class = serializers.FileSerializer +class PlayViewSet(viewsets.ModelViewSet): + queryset = models.Play.objects.all() + serializer_class = serializers.PlaySerializer + + +class TaskViewSet(viewsets.ModelViewSet): + queryset = models.Task.objects.all() + serializer_class = serializers.TaskSerializer + + +class HostViewSet(viewsets.ModelViewSet): + queryset = models.Host.objects.all() + serializer_class = serializers.HostSerializer + + +class ResultViewSet(viewsets.ModelViewSet): + queryset = models.Result.objects.all() + serializer_class = serializers.ResultSerializer class RecordViewSet(viewsets.ModelViewSet): queryset = models.Record.objects.all() serializer_class = serializers.RecordSerializer + + +class FileViewSet(viewsets.ModelViewSet): + queryset = models.File.objects.all() + serializer_class = serializers.FileSerializer