View to provide the custom recipe download feature. The recipe is
generated on-demand to make sure that it is the most current version of
the Custom recipe.

Signed-off-by: Michael Wood <[email protected]>
---
 bitbake/lib/toaster/toastergui/urls.py  |  3 +++
 bitbake/lib/toaster/toastergui/views.py | 15 ++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/bitbake/lib/toaster/toastergui/urls.py 
b/bitbake/lib/toaster/toastergui/urls.py
index a1adbb7..50acb1b 100644
--- a/bitbake/lib/toaster/toastergui/urls.py
+++ b/bitbake/lib/toaster/toastergui/urls.py
@@ -134,6 +134,9 @@ urlpatterns = patterns('toastergui.views',
             'customrecipe',
             name="customrecipe"),
 
+        url(r'^project/(?P<pid>\d+)/customrecipe/(?P<recipe_id>\d+)/download$',
+            'customrecipe_download',
+            name="customrecipedownload"),
 
 
         # typeahead api end points
diff --git a/bitbake/lib/toaster/toastergui/views.py 
b/bitbake/lib/toaster/toastergui/views.py
index 45fb055..c10b19f 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -27,7 +27,7 @@ import operator,re
 
 from django.db.models import F, Q, Sum, Count, Max
 from django.db import IntegrityError, Error
-from django.shortcuts import render, redirect
+from django.shortcuts import render, redirect, get_object_or_404
 from orm.models import Build, Target, Task, Layer, Layer_Version, Recipe, 
LogMessage, Variable
 from orm.models import Task_Dependency, Recipe_Dependency, Package, 
Package_File, Package_Dependency
 from orm.models import Target_Installed_Package, Target_File, 
Target_Image_File, BuildArtifact
@@ -2749,6 +2749,19 @@ if True:
         else:
             return {"error": "Method %s is not supported" % request.method}
 
+    def customrecipe_download(request, pid, recipe_id):
+        recipe = get_object_or_404(CustomImageRecipe, pk=recipe_id)
+
+        file_data = recipe.generate_recipe_file_contents()
+
+        response = HttpResponse(file_data, content_type='text/plain')
+        response['Content-Disposition'] = \
+                'attachment; filename="%s_%s.bb"' % (recipe.name,
+                                                     recipe.version)
+
+        return response
+
+
     @xhr_response
     def xhr_customrecipe_packages(request, recipe_id, package_id):
         """
-- 
2.1.4

-- 
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Reply via email to