summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py110
1 files changed, 41 insertions, 69 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 678e356e0d..91c4fa2543 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2210,6 +2210,45 @@ if toastermain.settings.MANAGED:
2210 except User.DoesNotExist: 2210 except User.DoesNotExist:
2211 puser = None 2211 puser = None
2212 2212
2213 # execute POST requests
2214 if request.method == "POST":
2215 # add layers
2216 if 'layerAdd' in request.POST:
2217 for lc in Layer_Version.objects.filter(pk__in=request.POST['layerAdd'].split(",")):
2218 ProjectLayer.objects.get_or_create(project = prj, layercommit = lc)
2219
2220 # remove layers
2221 if 'layerDel' in request.POST:
2222 for t in request.POST['layerDel'].strip().split(" "):
2223 pt = ProjectLayer.objects.filter(project = prj, layercommit_id = int(t)).delete()
2224
2225 if 'projectName' in request.POST:
2226 prj.name = request.POST['projectName']
2227 prj.save();
2228
2229 if 'projectVersion' in request.POST:
2230 prj.release = Release.objects.get(pk = request.POST['projectVersion'])
2231 # we need to change the bitbake version
2232 prj.bitbake_version = prj.release.bitbake_version
2233 prj.save()
2234 # we need to change the layers
2235 for i in prj.projectlayer_set.all():
2236 # find and add a similarly-named layer on the new branch
2237 try:
2238 lv = prj.compatible_layerversions(layer_name = i.layercommit.layer.name)[0]
2239 ProjectLayer.objects.get_or_create(project = prj, layercommit = lv)
2240 except IndexError:
2241 pass
2242 finally:
2243 # get rid of the old entry
2244 i.delete()
2245
2246 if 'machineName' in request.POST:
2247 machinevar = prj.projectvariable_set.get(name="MACHINE")
2248 machinevar.value=request.POST['machineName']
2249 machinevar.save()
2250
2251
2213 # we use implicit knowledge of the current user's project to filter layer information, e.g. 2252 # we use implicit knowledge of the current user's project to filter layer information, e.g.
2214 pid = prj.id 2253 pid = prj.id
2215 2254
@@ -2241,10 +2280,12 @@ if toastermain.settings.MANAGED:
2241 "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name if x.layercommit.up_branch != None else None}}, 2280 "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name if x.layercommit.up_branch != None else None}},
2242 prj.projectlayer_set.all().order_by("id")), 2281 prj.projectlayer_set.all().order_by("id")),
2243 "targets" : map(lambda x: {"target" : x.target, "task" : x.task, "pk": x.pk}, prj.projecttarget_set.all()), 2282 "targets" : map(lambda x: {"target" : x.target, "task" : x.task, "pk": x.pk}, prj.projecttarget_set.all()),
2283 "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()),
2244 "freqtargets": freqtargets[:5], 2284 "freqtargets": freqtargets[:5],
2245 "releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()), 2285 "releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()),
2246 "project_html": 1, 2286 "project_html": 1,
2247 } 2287 }
2288
2248 try: 2289 try:
2249 context["machine"] = {"name": prj.projectvariable_set.get(name="MACHINE").value} 2290 context["machine"] = {"name": prj.projectvariable_set.get(name="MACHINE").value}
2250 except ProjectVariable.DoesNotExist: 2291 except ProjectVariable.DoesNotExist:
@@ -2300,66 +2341,6 @@ if toastermain.settings.MANAGED:
2300 except Exception as e: 2341 except Exception as e:
2301 return HttpResponse(jsonfilter({"error":str(e) + "\n" + traceback.format_exc()}), content_type = "application/json") 2342 return HttpResponse(jsonfilter({"error":str(e) + "\n" + traceback.format_exc()}), content_type = "application/json")
2302 2343
2303 # This is a wraper for xhr_projectedit which allows for a project id
2304 # which only becomes known client side
2305 def xhr_projectinfo(request):
2306 if request.POST.has_key("project_id") == False:
2307 raise BadParameterException("invalid project id")
2308
2309 return xhr_projectedit(request, request.POST['project_id'])
2310
2311 def xhr_projectedit(request, pid):
2312 try:
2313 prj = Project.objects.get(id = pid)
2314 # add layers
2315 if 'layerAdd' in request.POST:
2316 for lc in Layer_Version.objects.filter(pk__in=request.POST['layerAdd'].split(",")):
2317 ProjectLayer.objects.get_or_create(project = prj, layercommit = lc)
2318
2319 # remove layers
2320 if 'layerDel' in request.POST:
2321 for t in request.POST['layerDel'].strip().split(" "):
2322 pt = ProjectLayer.objects.filter(project = prj, layercommit_id = int(t)).delete()
2323
2324 if 'projectName' in request.POST:
2325 prj.name = request.POST['projectName']
2326 prj.save();
2327
2328 if 'projectVersion' in request.POST:
2329 prj.release = Release.objects.get(pk = request.POST['projectVersion'])
2330 # we need to change the bitbake version
2331 prj.bitbake_version = prj.release.bitbake_version
2332 prj.save()
2333 # we need to change the layers
2334 for i in prj.projectlayer_set.all():
2335 # find and add a similarly-named layer on the new branch
2336 try:
2337 lv = prj.compatible_layerversions(layer_name = i.layercommit.layer.name)[0]
2338 ProjectLayer.objects.get_or_create(project = prj, layercommit = lv)
2339 except IndexError:
2340 pass
2341 finally:
2342 # get rid of the old entry
2343 i.delete()
2344
2345 if 'machineName' in request.POST:
2346 machinevar = prj.projectvariable_set.get(name="MACHINE")
2347 machinevar.value=request.POST['machineName']
2348 machinevar.save()
2349
2350 # return all project settings
2351 return HttpResponse(jsonfilter( {
2352 "error": "ok",
2353 "layers" : map(lambda x: {"id": x.layercommit.pk, "orderid" : x.pk, "name" : x.layercommit.layer.name, "giturl" : x.layercommit.layer.vcs_url, "url": x.layercommit.layer.layer_index_url, "layerdetailurl": reverse("layerdetails", args=(prj.id, x.layercommit.pk,)), "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name}}, prj.projectlayer_set.all().select_related("layer").order_by("id")),
2354 "builds" : _project_recent_build_list(prj),
2355 "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()),
2356 "machine": {"name": prj.projectvariable_set.get(name="MACHINE").value},
2357 "prj": {"name": prj.name, "release": { "id": prj.release.pk, "name": prj.release.name, "desc": prj.release.description}},
2358 }), content_type = "application/json")
2359
2360 except Exception as e:
2361 return HttpResponse(jsonfilter({"error":str(e) + "\n" + traceback.format_exc()}), content_type = "application/json")
2362
2363 2344
2364 from django.views.decorators.csrf import csrf_exempt 2345 from django.views.decorators.csrf import csrf_exempt
2365 @csrf_exempt 2346 @csrf_exempt
@@ -2929,7 +2910,6 @@ if toastermain.settings.MANAGED:
2929 p.id = p.pk 2910 p.id = p.pk
2930 p.xhrProjectDataTypeaheadUrl = reverse('xhr_datatypeahead', args=(p.id,)) 2911 p.xhrProjectDataTypeaheadUrl = reverse('xhr_datatypeahead', args=(p.id,))
2931 p.projectPageUrl = reverse('project', args=(p.id,)) 2912 p.projectPageUrl = reverse('project', args=(p.id,))
2932 p.xhrProjectEditUrl = reverse('xhr_projectedit', args=(p.id,))
2933 p.projectBuildUrl = reverse('xhr_projectbuild', args=(p.id,)) 2913 p.projectBuildUrl = reverse('xhr_projectbuild', args=(p.id,))
2934 2914
2935 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) 2915 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
@@ -3234,14 +3214,6 @@ else:
3234 return {} 3214 return {}
3235 3215
3236 @_template_renderer('landing_not_managed.html') 3216 @_template_renderer('landing_not_managed.html')
3237 def xhr_projectinfo(request):
3238 return {}
3239
3240 @_template_renderer('landing_not_managed.html')
3241 def xhr_projectedit(request, pid):
3242 return {}
3243
3244 @_template_renderer('landing_not_managed.html')
3245 def xhr_datatypeahead(request): 3217 def xhr_datatypeahead(request):
3246 return {} 3218 return {}
3247 3219