[Toaster] [PATCH 06/10] toaster: Add backend API for deleting a build

Michael Wood michael.g.wood at intel.com
Thu Sep 22 09:55:50 PDT 2016


Signed-off-by: Michael Wood <michael.g.wood at intel.com>
---
 bitbake/lib/toaster/toastergui/api.py  | 30 ++++++++++++++++++++++++++++++
 bitbake/lib/toaster/toastergui/urls.py |  4 ++++
 2 files changed, 34 insertions(+)

diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py
index 856918b..149abf7 100644
--- a/bitbake/lib/toaster/toastergui/api.py
+++ b/bitbake/lib/toaster/toastergui/api.py
@@ -832,3 +832,33 @@ class XhrProject(View):
             "error": "ok",
             "gotoUrl": reverse("all-projects", args=[])
         })
+
+
+class XhrBuild(View):
+    """ Delete a build object
+
+    Entry point: /xhr_build/<build_id>
+    """
+    def delete(self, request, *args, **kwargs):
+        """
+          Delete build data
+
+          Args:
+              build_id = build_id
+
+          Returns:
+              {"error": "ok"}
+            or
+              {"error": <error message>}
+        """
+        try:
+            build = Build.objects.get(pk=kwargs['build_id'])
+            project = build.project
+            build.delete()
+        except Build.DoesNotExist:
+            return error_response("Build %s does not exist" %
+                                  kwargs['build_id'])
+        return JsonResponse({
+            "error": "ok",
+            "gotoUrl": reverse("projectbuilds", args=(project.pk,))
+        })
diff --git a/bitbake/lib/toaster/toastergui/urls.py b/bitbake/lib/toaster/toastergui/urls.py
index 0002a5a..ece9ac1 100644
--- a/bitbake/lib/toaster/toastergui/urls.py
+++ b/bitbake/lib/toaster/toastergui/urls.py
@@ -225,6 +225,10 @@ urlpatterns = patterns('toastergui.views',
             api.XhrProject.as_view(),
             name='xhr_project'),
 
+        url(r'xhr_build/(?P<build_id>\d+)$',
+            api.XhrBuild.as_view(),
+            name='xhr_build'),
+
         url(r'^mostrecentbuilds$', widgets.MostRecentBuildsView.as_view(),
             name='most_recent_builds'),
 
-- 
2.7.4



More information about the toaster mailing list