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.py131
1 files changed, 3 insertions, 128 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 365a1e88ff..2efb0fd56c 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1361,136 +1361,11 @@ if True:
1361 1361
1362 raise Exception("Invalid HTTP method for this page") 1362 raise Exception("Invalid HTTP method for this page")
1363 1363
1364
1365
1366 # Shows the edit project page 1364 # Shows the edit project page
1367 @_template_renderer('project.html')
1368 def project(request, pid): 1365 def project(request, pid):
1369 prj = Project.objects.get(id = pid) 1366 project = Project.objects.get(pk=pid)
1370 1367 context = {"project": project}
1371 try: 1368 return render(request, "project.html", context)
1372 puser = User.objects.get(id = prj.user_id)
1373 except User.DoesNotExist:
1374 puser = None
1375
1376 # execute POST requests
1377 if request.method == "POST":
1378 # add layers
1379 if 'layerAdd' in request.POST and len(request.POST['layerAdd']) > 0:
1380 for lc in Layer_Version.objects.filter(pk__in=[i for i in request.POST['layerAdd'].split(",") if len(i) > 0]):
1381 ProjectLayer.objects.get_or_create(project = prj, layercommit = lc)
1382
1383 # remove layers
1384 if 'layerDel' in request.POST and len(request.POST['layerDel']) > 0:
1385 for t in request.POST['layerDel'].strip().split(" "):
1386 pt = ProjectLayer.objects.filter(project = prj, layercommit_id = int(t)).delete()
1387
1388 if 'projectName' in request.POST:
1389 prj.name = request.POST['projectName']
1390 prj.save();
1391
1392 if 'projectVersion' in request.POST:
1393 # If the release is the current project then return now
1394 if prj.release.pk == int(request.POST.get('projectVersion',-1)):
1395 return {}
1396
1397 prj.release = Release.objects.get(pk = request.POST['projectVersion'])
1398 # we need to change the bitbake version
1399 prj.bitbake_version = prj.release.bitbake_version
1400 prj.save()
1401 # we need to change the layers
1402 for project in prj.projectlayer_set.all():
1403 # find and add a similarly-named layer on the new branch
1404 try:
1405 layer_versions = prj.get_all_compatible_layer_versions()
1406 layer_versions = layer_versions.filter(layer__name = project.layercommit.layer.name)
1407 ProjectLayer.objects.get_or_create(project = prj, layercommit = layer_versions.first())
1408 except IndexError:
1409 pass
1410 finally:
1411 # get rid of the old entry
1412 project.delete()
1413
1414 if 'machineName' in request.POST:
1415 machinevar = prj.projectvariable_set.get(name="MACHINE")
1416 machinevar.value=request.POST['machineName']
1417 machinevar.save()
1418
1419
1420 # we use implicit knowledge of the current user's project to filter layer information, e.g.
1421 pid = prj.id
1422
1423 from collections import Counter
1424
1425 freqtargets = Counter(Target.objects.filter(
1426 Q(build__project=prj),
1427 ~Q(build__outcome=Build.IN_PROGRESS)
1428 ).order_by("target").values_list("target", flat=True))
1429
1430 freqtargets = freqtargets.most_common(5)
1431
1432 # We now have the targets in order of frequency but if there are two
1433 # with the same frequency then we need to make sure those are in
1434 # alphabetical order without losing the frequency ordering
1435
1436 tmp = []
1437 switch = None
1438 for i, freqtartget in enumerate(freqtargets):
1439 target, count = freqtartget
1440 try:
1441 target_next, count_next = freqtargets[i+1]
1442 if count == count_next and target > target_next:
1443 switch = target
1444 continue
1445 except IndexError:
1446 pass
1447
1448 tmp.append(target)
1449
1450 if switch:
1451 tmp.append(switch)
1452 switch = None
1453
1454 freqtargets = tmp
1455
1456 layers = [{"id": x.layercommit.pk, "orderid": x.pk, "name" : x.layercommit.layer.name,
1457 "vcs_url": x.layercommit.layer.vcs_url, "local_source_dir": x.layercommit.layer.local_source_dir, "vcs_reference" : x.layercommit.get_vcs_reference(),
1458 "url": x.layercommit.layer.layer_index_url, "layerdetailurl": x.layercommit.get_detailspage_url(prj.pk),
1459 "branch" : {"name" : x.layercommit.get_vcs_reference(),
1460 "layersource" : x.layercommit.layer_source }
1461 } for x in prj.projectlayer_set.all().order_by("id")]
1462
1463 context = {
1464 "project" : prj,
1465 "lvs_nos" : Layer_Version.objects.all().count(),
1466 "completedbuilds": Build.objects.exclude(outcome = Build.IN_PROGRESS).filter(project_id = pid),
1467 "prj" : {"name": prj.name, },
1468 "buildrequests" : prj.build_set.filter(outcome=Build.IN_PROGRESS),
1469 "builds" : Build.get_recent(prj),
1470 "layers" : layers,
1471 "targets" : [{"target" : x.target, "task" : x.task, "pk": x.pk} for x in prj.projecttarget_set.all()],
1472 "variables": [(x.name, x.value) for x in prj.projectvariable_set.all()],
1473 "freqtargets": freqtargets,
1474 "releases": [{"id": x.pk, "name": x.name, "description":x.description} for x in Release.objects.all()],
1475 "project_html": 1,
1476 "recipesTypeAheadUrl": reverse('xhr_recipestypeahead', args=(prj.pk,)),
1477 "projectBuildsUrl": reverse('projectbuilds', args=(prj.pk,)),
1478 }
1479
1480 if prj.release is not None:
1481 context['release'] = { "id": prj.release.pk, "name": prj.release.name, "description": prj.release.description}
1482
1483
1484 try:
1485 context["machine"] = {"name": prj.projectvariable_set.get(name="MACHINE").value}
1486 except ProjectVariable.DoesNotExist:
1487 context["machine"] = None
1488 try:
1489 context["distro"] = prj.projectvariable_set.get(name="DISTRO").value
1490 except ProjectVariable.DoesNotExist:
1491 context["distro"] = "-- not set yet"
1492
1493 return context
1494 1369
1495 def jsunittests(request): 1370 def jsunittests(request):
1496 """ Provides a page for the js unit tests """ 1371 """ Provides a page for the js unit tests """