summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-05-07 18:09:09 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-12 12:14:13 +0100
commit94d38a4e403f9e1930312b94694077a5300d625f (patch)
tree9ffc996e3bf106a513d78e0026395305f9f83678
parenta5193d3c7f1562ea6858c5b992159d79f58f644b (diff)
downloadpoky-94d38a4e403f9e1930312b94694077a5300d625f.tar.gz
bitbake: toasterui: URL refactoring
This is a URL refactoring needed to remove the inadvertent usage of server-side user session in a REST-style API. We move the parameters that were stored in the user session to the URL, making navigation more robust. This refactoring allows a clean (no 500 HTTP return codes) crawl of the website following inside links. (Bitbake rev: cc251da0f211f3ee881ad07478733e2f4c1b7019) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/toastergui/templates/basetable_top_layers.html2
-rw-r--r--bitbake/lib/toaster/toastergui/templates/importlayer.html2
-rw-r--r--bitbake/lib/toaster/toastergui/templates/layerdetails.html8
-rw-r--r--bitbake/lib/toaster/toastergui/templates/layers.html14
-rw-r--r--bitbake/lib/toaster/toastergui/templates/machines.html4
-rw-r--r--bitbake/lib/toaster/toastergui/templates/project.html24
-rw-r--r--bitbake/lib/toaster/toastergui/templates/targets.html6
-rw-r--r--bitbake/lib/toaster/toastergui/urls.py21
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py94
9 files changed, 80 insertions, 95 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/basetable_top_layers.html b/bitbake/lib/toaster/toastergui/templates/basetable_top_layers.html
index bd6e7dd2de..722091b2d3 100644
--- a/bitbake/lib/toaster/toastergui/templates/basetable_top_layers.html
+++ b/bitbake/lib/toaster/toastergui/templates/basetable_top_layers.html
@@ -1,5 +1,5 @@
1{% extends "basetable_top.html" %} 1{% extends "basetable_top.html" %}
2 2
3{%block custombuttons %} 3{%block custombuttons %}
4 <a class="btn" href="{% url 'importlayer' %}" style="margin-right:5px;">Import layer</a> 4 <a class="btn" href="{% url 'importlayer' project.id %}" style="margin-right:5px;">Import layer</a>
5{%endblock%} 5{%endblock%}
diff --git a/bitbake/lib/toaster/toastergui/templates/importlayer.html b/bitbake/lib/toaster/toastergui/templates/importlayer.html
index ed03b2eea7..d73c319307 100644
--- a/bitbake/lib/toaster/toastergui/templates/importlayer.html
+++ b/bitbake/lib/toaster/toastergui/templates/importlayer.html
@@ -14,7 +14,7 @@
14 <script> 14 <script>
15 $(document).ready(function (){ 15 $(document).ready(function (){
16 var ctx = { 16 var ctx = {
17 layerDetailsUrl : "{% url 'base_layerdetails' %}", 17 layerDetailsUrl : "{% url 'base_layerdetails' project.id %}",
18 xhrImportLayerUrl : "{% url 'xhr_importlayer' %}", 18 xhrImportLayerUrl : "{% url 'xhr_importlayer' %}",
19 }; 19 };
20 20
diff --git a/bitbake/lib/toaster/toastergui/templates/layerdetails.html b/bitbake/lib/toaster/toastergui/templates/layerdetails.html
index 4b27d052d0..4d892d56f9 100644
--- a/bitbake/lib/toaster/toastergui/templates/layerdetails.html
+++ b/bitbake/lib/toaster/toastergui/templates/layerdetails.html
@@ -3,7 +3,7 @@
3{% load humanize %} 3{% load humanize %}
4{% load static %} 4{% load static %}
5{% block localbreadcrumb %} 5{% block localbreadcrumb %}
6<li><a href="{% url 'layers' %}">All compatible layers</a></li> 6<li><a href="{% url 'all-layers' project.id %}">All compatible layers</a></li>
7<li> 7<li>
8 {{layerversion.layer.name}} ({{layerversion.get_vcs_reference|truncatechars:13}}) 8 {{layerversion.layer.name}} ({{layerversion.get_vcs_reference|truncatechars:13}})
9</li> 9</li>
@@ -17,7 +17,7 @@
17 $(document).ready(function (){ 17 $(document).ready(function (){
18 var ctx = { 18 var ctx = {
19 projectBuildUrl : "{% url 'xhr_build' %}", 19 projectBuildUrl : "{% url 'xhr_build' %}",
20 layerDetailsUrl : "{% url 'base_layerdetails' %}", 20 layerDetailsUrl : "{% url 'base_layerdetails' project.id %}",
21 xhrUpdateLayerUrl : "{% url 'xhr_updatelayer' %}", 21 xhrUpdateLayerUrl : "{% url 'xhr_updatelayer' %}",
22 numTargets : {{total_targets}}, 22 numTargets : {{total_targets}},
23 numMachines: {{machines|length}}, 23 numMachines: {{machines|length}},
@@ -26,7 +26,7 @@
26 id : {{layerversion.id}}, 26 id : {{layerversion.id}},
27 commit: "{{layerversion.get_vcs_reference}}", 27 commit: "{{layerversion.get_vcs_reference}}",
28 inCurrentPrj : {{layer_in_project}}, 28 inCurrentPrj : {{layer_in_project}},
29 url : "{% url 'layerdetails' layerversion.id %}", 29 url : "{% url 'layerdetails' project.id layerversion.id %}",
30 sourceId: {{layerversion.layer_source_id}}, 30 sourceId: {{layerversion.layer_source_id}},
31 } 31 }
32 }; 32 };
@@ -164,7 +164,7 @@
164 {% for ld in layerversion.dependencies.all %} 164 {% for ld in layerversion.dependencies.all %}
165 <span class="current-value"> 165 <span class="current-value">
166 <li data-layer-id="{{ld.depends_on.id}}"> 166 <li data-layer-id="{{ld.depends_on.id}}">
167 <a data-toggle="tooltip" title="{{ld.depends_on.layer.vcs_url}} | {{ld.depends_on.get_vcs_reference}}" href="{% url 'layerdetails' ld.depends_on.id %}">{{ld.depends_on.layer.name}}</a> 167 <a data-toggle="tooltip" title="{{ld.depends_on.layer.vcs_url}} | {{ld.depends_on.get_vcs_reference}}" href="{% url 'layerdetails' project.id ld.depends_on.id %}">{{ld.depends_on.layer.name}}</a>
168 <span class="icon-trash " data-toggle="tooltip" title="Delete"></span> 168 <span class="icon-trash " data-toggle="tooltip" title="Delete"></span>
169 </li> 169 </li>
170 </span> 170 </span>
diff --git a/bitbake/lib/toaster/toastergui/templates/layers.html b/bitbake/lib/toaster/toastergui/templates/layers.html
index 2367e7c33a..abad007ee4 100644
--- a/bitbake/lib/toaster/toastergui/templates/layers.html
+++ b/bitbake/lib/toaster/toastergui/templates/layers.html
@@ -73,14 +73,14 @@
73{% include "basetable_top_layers.html" %} 73{% include "basetable_top_layers.html" %}
74 {% for o in objects %} 74 {% for o in objects %}
75 <tr class="data"> 75 <tr class="data">
76 <td class="layer"><a href="{% url 'layerdetails' o.id %}">{{o.layer.name}}</a></td> 76 <td class="layer"><a href="{% url 'layerdetails' project.id o.id %}">{{o.layer.name}}</a></td>
77 <td class="description">{% if o.layer.summary %}{{o.layer.summary}}{%endif%}</td> 77 <td class="description">{% if o.layer.summary %}{{o.layer.summary}}{%endif%}</td>
78 <td class="git-repo"><a href="{% url 'layerdetails' o.pk %}"><code>{{o.layer.vcs_url}}</code></a> 78 <td class="git-repo"><a href="{% url 'layerdetails' project.id o.pk %}"><code>{{o.layer.vcs_url}}</code></a>
79 {% if o.get_vcs_link_url %} 79 {% if o.get_vcs_link_url %}
80 <a target="_blank" href="{{ o.get_vcs_link_url }}"><i class="icon-share get-info"></i></a> 80 <a target="_blank" href="{{ o.get_vcs_link_url }}"><i class="icon-share get-info"></i></a>
81 {% endif %} 81 {% endif %}
82 </td> 82 </td>
83 <td class="git-subdir" style="display: table-cell;"><a href="{% url 'layerdetails' o.pk %}"><code>{{o.dirpath}}</code></a> 83 <td class="git-subdir" style="display: table-cell;"><a href="{% url 'layerdetails' project.id o.pk %}"><code>{{o.dirpath}}</code></a>
84 {% if o.dirpath and o.get_vcs_dirpath_link_url %} 84 {% if o.dirpath and o.get_vcs_dirpath_link_url %}
85 <a target="_blank" href="{{ o.get_vcs_dirpath_link_url }}"><i class="icon-share get-info"></i></a> 85 <a target="_blank" href="{{ o.get_vcs_dirpath_link_url }}"><i class="icon-share get-info"></i></a>
86 {% endif %} 86 {% endif %}
@@ -100,10 +100,10 @@
100 {% with ods=o.dependencies.all%} 100 {% with ods=o.dependencies.all%}
101 {% if ods.count %} 101 {% if ods.count %}
102 <a class="btn" 102 <a class="btn"
103 title="<a href='{% url "layerdetails" o.pk %}'>{{o.layer.name}}</a> dependencies" 103 title="<a href='{% url "layerdetails" project.id o.pk %}'>{{o.layer.name}}</a> dependencies"
104 data-content="<ul class='unstyled'> 104 data-content="<ul class='unstyled'>
105 {% for i in ods%} 105 {% for i in ods%}
106 <li><a href='{% url "layerdetails" i.depends_on.pk %}'>{{i.depends_on.layer.name}}</a></li> 106 <li><a href='{% url "layerdetails" project.id i.depends_on.pk %}'>{{i.depends_on.layer.name}}</a></li>
107 {% endfor %} 107 {% endfor %}
108 </ul>"> 108 </ul>">
109 {{ods.count}} 109 {{ods.count}}
@@ -113,11 +113,11 @@
113 </td> 113 </td>
114 {% if project %} 114 {% if project %}
115 <td class="add-del-layers" value="{{o.pk}}"> 115 <td class="add-del-layers" value="{{o.pk}}">
116 <button class="btn btn-danger btn-block layer-exists-{{o.pk}} layerbtn" style="display:none;" data-layer='{ "id": {{o.pk}}, "name": "{{o.layer.name}}", "url": "{%url 'layerdetails' o.pk%}"}' data-directive="remove" > 116 <button class="btn btn-danger btn-block layer-exists-{{o.pk}} layerbtn" style="display:none;" data-layer='{ "id": {{o.pk}}, "name": "{{o.layer.name}}", "url": "{%url 'layerdetails' project.id o.pk%}"}' data-directive="remove" >
117 <i class="icon-trash"></i> 117 <i class="icon-trash"></i>
118 Delete layer 118 Delete layer
119 </button> 119 </button>
120 <button class="btn btn-block layer-add-{{o.pk}} layerbtn" data-layer='{ "id": {{o.pk}}, "name": "{{o.layer.name}}", "url": "{%url 'layerdetails' o.pk%}"}' data-directive="add"> 120 <button class="btn btn-block layer-add-{{o.pk}} layerbtn" data-layer='{ "id": {{o.pk}}, "name": "{{o.layer.name}}", "url": "{%url 'layerdetails' project.id o.pk%}"}' data-directive="add">
121 <i class="icon-plus"></i> 121 <i class="icon-plus"></i>
122 Add layer 122 Add layer
123 </button> 123 </button>
diff --git a/bitbake/lib/toaster/toastergui/templates/machines.html b/bitbake/lib/toaster/toastergui/templates/machines.html
index d116a45f3b..4a0986276f 100644
--- a/bitbake/lib/toaster/toastergui/templates/machines.html
+++ b/bitbake/lib/toaster/toastergui/templates/machines.html
@@ -69,12 +69,12 @@
69 <tr class="data"> 69 <tr class="data">
70 <td class="machine">{{o.name}}</td> 70 <td class="machine">{{o.name}}</td>
71 <td class="description">{{o.description}}</td> 71 <td class="description">{{o.description}}</td>
72 <td class="layer"><a href="{%url "layerdetails" o.layer_version.id %}">{{o.layer_version.layer.name}}</a></td> 72 <td class="layer"><a href="{%url "layerdetails" project.id o.layer_version.id %}">{{o.layer_version.layer.name}}</a></td>
73 <td class="branch">{{o.layer_version.get_vcs_reference}}</td> 73 <td class="branch">{{o.layer_version.get_vcs_reference}}</td>
74 <td class="machinefile"><code>/machine/conf/{{o.name}}.conf</code><a href="{{o.get_vcs_machine_file_link_url}}" target="_blank"><i class="icon-share get-info"></i></a></td> 74 <td class="machinefile"><code>/machine/conf/{{o.name}}.conf</code><a href="{{o.get_vcs_machine_file_link_url}}" target="_blank"><i class="icon-share get-info"></i></a></td>
75 <td class="select-or-add" style="height: 32px;"> 75 <td class="select-or-add" style="height: 32px;">
76 <a href="{% url 'project' project.id %}#/machineselect={{o.name}}" class="btn btn-block layer-exists-{{o.layer_version.id}}" style="margin-top: 5px; display:none">Select machine</a> 76 <a href="{% url 'project' project.id %}#/machineselect={{o.name}}" class="btn btn-block layer-exists-{{o.layer_version.id}}" style="margin-top: 5px; display:none">Select machine</a>
77 <button class="btn btn-block layerbtn layer-add-{{o.layer_version.id}}" data-layer='{ "id": {{o.layer_version.id}}, "name": "{{o.layer_version.layer.name}}", "url": "{%url 'layerdetails' o.layer_version.id %}"}' data-directive="add"> 77 <button class="btn btn-block layerbtn layer-add-{{o.layer_version.id}}" data-layer='{ "id": {{o.layer_version.id}}, "name": "{{o.layer_version.layer.name}}", "url": "{%url 'layerdetails' project.id o.layer_version.id %}"}' data-directive="add">
78 <i class="icon-plus"></i> 78 <i class="icon-plus"></i>
79 Add layer 79 Add layer
80 <i title="" class="icon-question-sign get-help" data-original-title="To enable this machine, you must first add the {{o.layer_version.layer.name}} layer to your project"></i></i> 80 <i title="" class="icon-question-sign get-help" data-original-title="To enable this machine, you must first add the {{o.layer_version.layer.name}} layer to your project"></i></i>
diff --git a/bitbake/lib/toaster/toastergui/templates/project.html b/bitbake/lib/toaster/toastergui/templates/project.html
index 5f8f4d1bc7..85a1b164dd 100644
--- a/bitbake/lib/toaster/toastergui/templates/project.html
+++ b/bitbake/lib/toaster/toastergui/templates/project.html
@@ -24,7 +24,7 @@ vim: expandtab tabstop=2
24 <p>Toaster has no layer information. Without layer information, you cannot run builds. To generate layer information you can:</p> 24 <p>Toaster has no layer information. Without layer information, you cannot run builds. To generate layer information you can:</p>
25 <ul> 25 <ul>
26 <li> <a href="http://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html#layer-source">Configure a layer source</a></li> 26 <li> <a href="http://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html#layer-source">Configure a layer source</a></li>
27 <li> <a href="{% url 'importlayer' %}">Import a layer</a></li> 27 <li> <a href="{% url 'importlayer' project.id %}">Import a layer</a></li>
28 </ul> 28 </ul>
29</div> 29</div>
30 30
@@ -111,7 +111,7 @@ vim: expandtab tabstop=2
111 </div> 111 </div>
112 <i class="icon-question-sign get-help get-help-blue" title="Type the name of one or more recipes you want to build, separated by a space. You can also specify a task by appending a semicolon and a task name to a recipe name, like so: <code>core-image-minimal:do_build</code>"></i> 112 <i class="icon-question-sign get-help get-help-blue" title="Type the name of one or more recipes you want to build, separated by a space. You can also specify a task by appending a semicolon and a task name to a recipe name, like so: <code>core-image-minimal:do_build</code>"></i>
113 <p> 113 <p>
114 <a href="{% url 'all-targets' %}">View all compatible recipes</a> 114 <a href="{% url 'all-targets' project.id %}">View all compatible recipes</a>
115 <i class="icon-question-sign get-help get-help-blue heading-help" title="View all the recipes you can build with the release selected for this project, which is {[project.release.desc]}"></i> 115 <i class="icon-question-sign get-help get-help-blue heading-help" title="View all the recipes you can build with the release selected for this project, which is {[project.release.desc]}"></i>
116 {% if completedbuilds.count %} 116 {% if completedbuilds.count %}
117 | <a href="{% url 'projectbuilds' project.id %}">View all project builds ({{completedbuilds.count}})</a> 117 | <a href="{% url 'projectbuilds' project.id %}">View all project builds ({{completedbuilds.count}})</a>
@@ -278,8 +278,8 @@ vim: expandtab tabstop=2
278 <p> 278 <p>
279 You can: 279 You can:
280 <ul> 280 <ul>
281 <li> <a href="{% url 'layers'%}">View all compatible layers available in Toaster</a> 281 <li> <a href="{% url 'all-layers' project.id %}">View all compatible layers available in Toaster</a>
282 <li> <a href="{% url 'importlayer' %}">Import a layer</a> 282 <li> <a href="{% url 'importlayer' project.id %}">Import a layer</a>
283 <li> <a href="https://www.yoctoproject.org/docs/1.6.1/dev-manual/dev-manual.html#understanding-and-creating-layers" target="_blank">Read about layers in the manual</a> 283 <li> <a href="https://www.yoctoproject.org/docs/1.6.1/dev-manual/dev-manual.html#understanding-and-creating-layers" target="_blank">Read about layers in the manual</a>
284 </ul> 284 </ul>
285 Or type a layer name below. 285 Or type a layer name below.
@@ -293,10 +293,10 @@ vim: expandtab tabstop=2
293 {% csrf_token %} 293 {% csrf_token %}
294 </form> 294 </form>
295 <p> 295 <p>
296 <a href="{% url 'layers' %}">View all compatible layers</a> 296 <a href="{% url 'all-layers' project.id %}">View all compatible layers</a>
297 <i class="icon-question-sign get-help" title="View all the layers you can build with the release selected for this project, which is {[project.release.desc]}"></i> 297 <i class="icon-question-sign get-help" title="View all the layers you can build with the release selected for this project, which is {[project.release.desc]}"></i>
298 | 298 |
299 <a href="{% url 'importlayer' %}">Import layer</a></p> 299 <a href="{% url 'importlayer' project.id %}">Import layer</a></p>
300 <ul class="unstyled configuration-list"> 300 <ul class="unstyled configuration-list">
301 <li ng-repeat="l in layers track by l.id" class="animate-repeat"> 301 <li ng-repeat="l in layers track by l.id" class="animate-repeat">
302 <a href="{[l.layerdetailurl]}" class="layer-info" data-toggle="tooltip" tooltip-placement="right" tooltip="{[l.giturl]} | {[l.branch.name]}">{[l.name]}</a> 302 <a href="{[l.layerdetailurl]}" class="layer-info" data-toggle="tooltip" tooltip-placement="right" tooltip="{[l.giturl]} | {[l.branch.name]}">{[l.name]}</a>
@@ -321,7 +321,7 @@ vim: expandtab tabstop=2
321 {% csrf_token %} 321 {% csrf_token %}
322 </form> 322 </form>
323 <p> 323 <p>
324 <a href="{% url 'all-targets' %}">View all compatible recipes</a> 324 <a href="{% url 'all-targets' project.id %}">View all compatible recipes</a>
325 <i class="icon-question-sign get-help" title="View all the recipes you can build with the release selected for this project, which is {[project.release.desc]}"></i> 325 <i class="icon-question-sign get-help" title="View all the recipes you can build with the release selected for this project, which is {[project.release.desc]}"></i>
326 </p> 326 </p>
327 <div ng-if="frequenttargets.length"> 327 <div ng-if="frequenttargets.length">
@@ -361,7 +361,7 @@ vim: expandtab tabstop=2
361 {% csrf_token %} 361 {% csrf_token %}
362 </form> 362 </form>
363 <p> 363 <p>
364 <a href="{% url 'machines' %}" class="link">View all compatible machines</a> 364 <a href="{% url 'all-machines' project.id %}" class="link">View all compatible machines</a>
365 <i class="icon-question-sign get-help" title="View all the machines you can set with the release selected for this project, which is {[project.release.desc]}"></i> 365 <i class="icon-question-sign get-help" title="View all the machines you can set with the release selected for this project, which is {[project.release.desc]}"></i>
366 </p> 366 </p>
367 </div> 367 </div>
@@ -432,10 +432,10 @@ angular.element(document).ready(function() {
432 scope.urls.xhr_build = "{% url 'xhr_projectbuild' project.id %}"; 432 scope.urls.xhr_build = "{% url 'xhr_projectbuild' project.id %}";
433 scope.urls.xhr_edit = "{% url 'xhr_projectedit' project.id %}"; 433 scope.urls.xhr_edit = "{% url 'xhr_projectedit' project.id %}";
434 scope.urls.xhr_datatypeahead = "{% url 'xhr_datatypeahead' %}"; 434 scope.urls.xhr_datatypeahead = "{% url 'xhr_datatypeahead' %}";
435 scope.urls.layers = "{% url 'layers' %}"; 435 scope.urls.layers = "{% url 'all-layers' project.id %}";
436 scope.urls.targets = "{% url 'all-targets' %}"; 436 scope.urls.targets = "{% url 'all-targets' project.id %}";
437 scope.urls.importlayer = "{% url 'importlayer'%}"; 437 scope.urls.importlayer = "{% url 'importlayer' project.id %}";
438 scope.urls.layer = "{% url 'base_layerdetails' %}"; 438 scope.urls.layer = "{% url 'base_layerdetails' project.id %}";
439 scope.project = {{prj|json}}; 439 scope.project = {{prj|json}};
440 scope.builds = {{builds|json}}; 440 scope.builds = {{builds|json}};
441 scope.layers = {{layers|json}}; 441 scope.layers = {{layers|json}};
diff --git a/bitbake/lib/toaster/toastergui/templates/targets.html b/bitbake/lib/toaster/toastergui/templates/targets.html
index 903e841ae5..dc2cef6882 100644
--- a/bitbake/lib/toaster/toastergui/templates/targets.html
+++ b/bitbake/lib/toaster/toastergui/templates/targets.html
@@ -62,7 +62,7 @@
62 <p>Toaster has no recipe information. To generate recipe information you can:</p> 62 <p>Toaster has no recipe information. To generate recipe information you can:</p>
63 <ul> 63 <ul>
64 <li><a href="http://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html#layer-source">Configure a layer source</a></li> 64 <li><a href="http://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html#layer-source">Configure a layer source</a></li>
65 <li><a href="{% url 'importlayer' %}">Import a layer</a>, then run a build</li> 65 <li><a href="{% url 'importlayer' project.id %}">Import a layer</a>, then run a build</li>
66 </ul> 66 </ul>
67 </div> 67 </div>
68 {% endif %} 68 {% endif %}
@@ -84,7 +84,7 @@
84 </td> 84 </td>
85 <td class="target-section">{{o.section}}</td> 85 <td class="target-section">{{o.section}}</td>
86 <td class="license">{{o.license}}</td> 86 <td class="license">{{o.license}}</td>
87 <td class="layer"><a href="{% url 'layerdetails' o.preffered_layerversion.id%}">{{o.preffered_layerversion.layer.name}}</a></td> 87 <td class="layer"><a href="{% url 'layerdetails' project.id o.preffered_layerversion.id%}">{{o.preffered_layerversion.layer.name}}</a></td>
88 <td class="branch"> 88 <td class="branch">
89 {% if o.preffered_layerversion.up_branch %} 89 {% if o.preffered_layerversion.up_branch %}
90 {{o.preffered_layerversion.up_branch.name}} 90 {{o.preffered_layerversion.up_branch.name}}
@@ -101,7 +101,7 @@
101 <a href="{% url 'project' project.id %}#/targetbuild={{o.name}}" class="btn btn-block layer-exists-{{o.preffered_layerversion.pk}}" style="display:none; margin-top: 5px;" > 101 <a href="{% url 'project' project.id %}#/targetbuild={{o.name}}" class="btn btn-block layer-exists-{{o.preffered_layerversion.pk}}" style="display:none; margin-top: 5px;" >
102 Build recipe 102 Build recipe
103 </a> 103 </a>
104 <button class="btn btn-block layerbtn layer-add-{{o.preffered_layerversion.pk}}" data-layer='{ "id": {{o.preffered_layerversion.pk}}, "name": "{{o.preffered_layerversion.layer.name}}", "url": "{%url 'layerdetails' o.preffered_layerversion.pk%}"}' data-directive="add"> 104 <button class="btn btn-block layerbtn layer-add-{{o.preffered_layerversion.pk}}" data-layer='{ "id": {{o.preffered_layerversion.pk}}, "name": "{{o.preffered_layerversion.layer.name}}", "url": "{%url 'layerdetails' project.id o.preffered_layerversion.pk%}"}' data-directive="add">
105 <i class="icon-plus"></i> 105 <i class="icon-plus"></i>
106 Add layer 106 Add layer
107 <i title="" class="icon-question-sign get-help" data-original-title="To build this target, you must first add the {{o.preffered_layerversion.layer.name}} layer to your project"></i></i> 107 <i title="" class="icon-question-sign get-help" data-original-title="To build this target, you must first add the {{o.preffered_layerversion.layer.name}} layer to your project"></i></i>
diff --git a/bitbake/lib/toaster/toastergui/urls.py b/bitbake/lib/toaster/toastergui/urls.py
index 76357e3b80..52fc0cc0ed 100644
--- a/bitbake/lib/toaster/toastergui/urls.py
+++ b/bitbake/lib/toaster/toastergui/urls.py
@@ -76,20 +76,25 @@ urlpatterns = patterns('toastergui.views',
76 76
77 # project URLs 77 # project URLs
78 url(r'^newproject/$', 'newproject', name='newproject'), 78 url(r'^newproject/$', 'newproject', name='newproject'),
79 url(r'^importlayer/$', 'importlayer', name='importlayer'),
80 79
81 url(r'^layers/$', 'layers', name='layers'),
82 url(r'^layer/(?P<layerid>\d+)/$', 'layerdetails', name='layerdetails'),
83 url(r'^layer/$', lambda x: HttpResponseBadRequest(), name='base_layerdetails'),
84 url(r'^targets/$', 'targets', name='all-targets'),
85 url(r'^machines/$', 'machines', name='machines'),
86 80
87 url(r'^projects/$', 'projects', name='all-projects'), 81 url(r'^projects/$', 'projects', name='all-projects'),
88 82
89 url(r'^project/$', lambda x: HttpResponseBadRequest(), name='base_project'), 83 url(r'^project/$', lambda x: HttpResponseBadRequest(), name='base_project'),
90 url(r'^project/(?P<pid>\d+)/$', 'project', name='project'), 84
85 url(r'^project/(?P<pid>\d+)$', 'project', name='project'),
91 url(r'^project/(?P<pid>\d+)/configuration$', 'projectconf', name='projectconf'), 86 url(r'^project/(?P<pid>\d+)/configuration$', 'projectconf', name='projectconf'),
92 url(r'^project/(?P<pid>\d+)/builds$', 'projectbuilds', name='projectbuilds'), 87 url(r'^project/(?P<pid>\d+)/builds/$', 'projectbuilds', name='projectbuilds'),
88
89 url(r'^project/(?P<pid>\d+)/layers/$', 'layers', name='all-layers'),
90 url(r'^project/(?P<pid>\d+)/layer/(?P<layerid>\d+)$', 'layerdetails', name='layerdetails'),
91 url(r'^project/(?P<pid>\d+)/layer/$', lambda x: HttpResponseBadRequest(), name='base_layerdetails'),
92
93 # the import layer is a project-specific functionality;
94 url(r'^project/(?P<pid>\d+)/importlayer$', 'importlayer', name='importlayer'),
95
96 url(r'^project/(?P<pid>\d+)/targets/$', 'targets', name='all-targets'),
97 url(r'^project/(?P<pid>\d+)/machines/$', 'machines', name='all-machines'),
93 98
94 url(r'^xhr_build/$', 'xhr_build', name='xhr_build'), 99 url(r'^xhr_build/$', 'xhr_build', name='xhr_build'),
95 url(r'^xhr_projectbuild/(?P<pid>\d+)/$', 'xhr_projectbuild', name='xhr_projectbuild'), 100 url(r'^xhr_projectbuild/(?P<pid>\d+)/$', 'xhr_projectbuild', name='xhr_projectbuild'),
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index e296cf6de3..23025a2a19 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1806,6 +1806,20 @@ def package_included_reverse_dependencies(request, build_id, target_id, package_
1806def image_information_dir(request, build_id, target_id, packagefile_id): 1806def image_information_dir(request, build_id, target_id, packagefile_id):
1807 # stubbed for now 1807 # stubbed for now
1808 return redirect(builds) 1808 return redirect(builds)
1809 # the context processor that supplies data used across all the pages
1810
1811
1812def managedcontextprocessor(request):
1813 import subprocess
1814 ret = {
1815 "projects": Project.objects.all(),
1816 "MANAGED" : toastermain.settings.MANAGED,
1817 "DEBUG" : toastermain.settings.DEBUG,
1818 "TOASTER_BRANCH": toastermain.settings.TOASTER_BRANCH,
1819 "TOASTER_REVISION" : toastermain.settings.TOASTER_REVISION,
1820 }
1821 return ret
1822
1809 1823
1810 1824
1811import toastermain.settings 1825import toastermain.settings
@@ -1827,23 +1841,6 @@ if toastermain.settings.MANAGED:
1827 1841
1828 class BadParameterException(Exception): pass # error thrown on invalid POST requests 1842 class BadParameterException(Exception): pass # error thrown on invalid POST requests
1829 1843
1830 # the context processor that supplies data used across all the pages
1831 def managedcontextprocessor(request):
1832 import subprocess
1833 ret = {
1834 "projects": Project.objects.all(),
1835 "MANAGED" : toastermain.settings.MANAGED,
1836 "DEBUG" : toastermain.settings.DEBUG,
1837 "TOASTER_BRANCH": toastermain.settings.TOASTER_BRANCH,
1838 "TOASTER_REVISION" : toastermain.settings.TOASTER_REVISION,
1839 }
1840 if 'project_id' in request.session:
1841 try:
1842 ret['project'] = Project.objects.get(pk = request.session['project_id'])
1843 except Project.DoesNotExist:
1844 del request.session['project_id']
1845 return ret
1846
1847 1844
1848 class InvalidRequestException(Exception): 1845 class InvalidRequestException(Exception):
1849 def __init__(self, response): 1846 def __init__(self, response):
@@ -2176,7 +2173,7 @@ if toastermain.settings.MANAGED:
2176 puser = None 2173 puser = None
2177 2174
2178 # we use implicit knowledge of the current user's project to filter layer information, e.g. 2175 # we use implicit knowledge of the current user's project to filter layer information, e.g.
2179 request.session['project_id'] = prj.id 2176 pid = prj.id
2180 2177
2181 from collections import Counter 2178 from collections import Counter
2182 freqtargets = [] 2179 freqtargets = []
@@ -2201,7 +2198,7 @@ if toastermain.settings.MANAGED:
2201 "name" : x.layercommit.layer.name, 2198 "name" : x.layercommit.layer.name,
2202 "giturl": x.layercommit.layer.vcs_url, 2199 "giturl": x.layercommit.layer.vcs_url,
2203 "url": x.layercommit.layer.layer_index_url, 2200 "url": x.layercommit.layer.layer_index_url,
2204 "layerdetailurl": reverse("layerdetails", args=(x.layercommit.pk,)), 2201 "layerdetailurl": reverse("layerdetails", args=(prj.id, x.layercommit.pk,)),
2205 # This branch name is actually the release 2202 # This branch name is actually the release
2206 "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name if x.layercommit.up_branch != None else None}}, 2203 "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name if x.layercommit.up_branch != None else None}},
2207 prj.projectlayer_set.all().order_by("id")), 2204 prj.projectlayer_set.all().order_by("id")),
@@ -2237,7 +2234,7 @@ if toastermain.settings.MANAGED:
2237 try: 2234 try:
2238 if request.method != "POST": 2235 if request.method != "POST":
2239 raise BadParameterException("invalid method") 2236 raise BadParameterException("invalid method")
2240 request.session['project_id'] = pid 2237 pid = pid
2241 prj = Project.objects.get(id = pid) 2238 prj = Project.objects.get(id = pid)
2242 2239
2243 2240
@@ -2326,7 +2323,7 @@ if toastermain.settings.MANAGED:
2326 # return all project settings 2323 # return all project settings
2327 return HttpResponse(jsonfilter( { 2324 return HttpResponse(jsonfilter( {
2328 "error": "ok", 2325 "error": "ok",
2329 "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=(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")), 2326 "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")),
2330 "builds" : _project_recent_build_list(prj), 2327 "builds" : _project_recent_build_list(prj),
2331 "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()), 2328 "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()),
2332 "machine": {"name": prj.projectvariable_set.get(name="MACHINE").value}, 2329 "machine": {"name": prj.projectvariable_set.get(name="MACHINE").value},
@@ -2344,8 +2341,6 @@ if toastermain.settings.MANAGED:
2344 prj = None 2341 prj = None
2345 if request.GET.has_key('project_id'): 2342 if request.GET.has_key('project_id'):
2346 prj = Project.objects.get(pk = request.GET['project_id']) 2343 prj = Project.objects.get(pk = request.GET['project_id'])
2347 elif 'project_id' in request.session:
2348 prj = Project.objects.get(pk = request.session['project_id'])
2349 else: 2344 else:
2350 raise Exception("No valid project selected") 2345 raise Exception("No valid project selected")
2351 2346
@@ -2389,8 +2384,6 @@ if toastermain.settings.MANAGED:
2389 2384
2390 # returns layer versions that would be deleted on the new release__pk 2385 # returns layer versions that would be deleted on the new release__pk
2391 if request.GET['type'] == "versionlayers": 2386 if request.GET['type'] == "versionlayers":
2392 if not 'project_id' in request.session:
2393 raise Exception("This call cannot makes no sense outside a project context")
2394 2387
2395 retval = [] 2388 retval = []
2396 for i in prj.projectlayer_set.all(): 2389 for i in prj.projectlayer_set.all():
@@ -2689,16 +2682,15 @@ if toastermain.settings.MANAGED:
2689 2682
2690 2683
2691 2684
2692 def importlayer(request): 2685 def importlayer(request, pid):
2693 template = "importlayer.html" 2686 template = "importlayer.html"
2694 context = { 2687 context = {
2688 'project': Project.objects.get(id=pid),
2695 } 2689 }
2696 return render(request, template, context) 2690 return render(request, template, context)
2697 2691
2698 2692
2699 def layers(request): 2693 def layers(request, pid):
2700 if not 'project_id' in request.session:
2701 raise Exception("invalid page: cannot show page without a project")
2702 2694
2703 template = "layers.html" 2695 template = "layers.html"
2704 # define here what parameters the view needs in the GET portion in order to 2696 # define here what parameters the view needs in the GET portion in order to
@@ -2708,13 +2700,13 @@ if toastermain.settings.MANAGED:
2708 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby }; 2700 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby };
2709 retval = _verify_parameters( request.GET, mandatory_parameters ) 2701 retval = _verify_parameters( request.GET, mandatory_parameters )
2710 if retval: 2702 if retval:
2711 return _redirect_parameters( 'layers', request.GET, mandatory_parameters) 2703 return _redirect_parameters( 'all-layers', request.GET, mandatory_parameters, pid=pid)
2712 2704
2713 # boilerplate code that takes a request for an object type and returns a queryset 2705 # boilerplate code that takes a request for an object type and returns a queryset
2714 # for that object type. copypasta for all needed table searches 2706 # for that object type. copypasta for all needed table searches
2715 (filter_string, search_term, ordering_string) = _search_tuple(request, Layer_Version) 2707 (filter_string, search_term, ordering_string) = _search_tuple(request, Layer_Version)
2716 2708
2717 prj = Project.objects.get(pk = request.session['project_id']) 2709 prj = Project.objects.get(pk = pid)
2718 2710
2719 queryset_all = prj.compatible_layerversions() 2711 queryset_all = prj.compatible_layerversions()
2720 2712
@@ -2729,6 +2721,7 @@ if toastermain.settings.MANAGED:
2729 2721
2730 2722
2731 context = { 2723 context = {
2724 'project' : prj,
2732 'projectlayerset' : jsonfilter(map(lambda x: x.layercommit.id, prj.projectlayer_set.all())), 2725 'projectlayerset' : jsonfilter(map(lambda x: x.layercommit.id, prj.projectlayer_set.all())),
2733 'objects' : layer_info, 2726 'objects' : layer_info,
2734 'objectname' : "layers", 2727 'objectname' : "layers",
@@ -2773,7 +2766,7 @@ if toastermain.settings.MANAGED:
2773 2766
2774 return response 2767 return response
2775 2768
2776 def layerdetails(request, layerid): 2769 def layerdetails(request, pid, layerid):
2777 template = "layerdetails.html" 2770 template = "layerdetails.html"
2778 limit = 10 2771 limit = 10
2779 2772
@@ -2806,8 +2799,9 @@ if toastermain.settings.MANAGED:
2806 machines = _build_page_range(Paginator(machines_query.order_by("name"), limit), request.GET.get('mpage', 1)) 2799 machines = _build_page_range(Paginator(machines_query.order_by("name"), limit), request.GET.get('mpage', 1))
2807 2800
2808 context = { 2801 context = {
2802 'project' : Project.objects.get(pk=pid),
2809 'layerversion': layer_version, 2803 'layerversion': layer_version,
2810 'layer_in_project' : ProjectLayer.objects.filter(project_id=request.session['project_id'],layercommit=layerid).count(), 2804 'layer_in_project' : ProjectLayer.objects.filter(project_id=pid,layercommit=layerid).count(),
2811 'machines': machines, 2805 'machines': machines,
2812 'targets': targets, 2806 'targets': targets,
2813 'total_targets': Recipe.objects.filter(layer_version=layer_version).count(), 2807 'total_targets': Recipe.objects.filter(layer_version=layer_version).count(),
@@ -2816,19 +2810,16 @@ if toastermain.settings.MANAGED:
2816 } 2810 }
2817 return render(request, template, context) 2811 return render(request, template, context)
2818 2812
2819 def targets(request): 2813 def targets(request, pid):
2820 if not 'project_id' in request.session:
2821 raise Exception("invalid page: cannot show page without a project")
2822
2823 template = 'targets.html' 2814 template = 'targets.html'
2824 (pagesize, orderby) = _get_parameters_values(request, 100, 'name:+') 2815 (pagesize, orderby) = _get_parameters_values(request, 100, 'name:+')
2825 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby } 2816 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby }
2826 retval = _verify_parameters( request.GET, mandatory_parameters ) 2817 retval = _verify_parameters( request.GET, mandatory_parameters )
2827 if retval: 2818 if retval:
2828 return _redirect_parameters( 'all-targets', request.GET, mandatory_parameters) 2819 return _redirect_parameters( 'all-targets', request.GET, mandatory_parameters, pid = pid)
2829 (filter_string, search_term, ordering_string) = _search_tuple(request, Recipe) 2820 (filter_string, search_term, ordering_string) = _search_tuple(request, Recipe)
2830 2821
2831 prj = Project.objects.get(pk = request.session['project_id']) 2822 prj = Project.objects.get(pk = pid)
2832 queryset_all = Recipe.objects.filter(Q(layer_version__up_branch__name= prj.release.name) | Q(layer_version__build__in = prj.build_set.all())).filter(name__regex=r'.{1,}.*') 2823 queryset_all = Recipe.objects.filter(Q(layer_version__up_branch__name= prj.release.name) | Q(layer_version__build__in = prj.build_set.all())).filter(name__regex=r'.{1,}.*')
2833 2824
2834 queryset_with_search = _get_queryset(Recipe, queryset_all, None, search_term, ordering_string, '-name') 2825 queryset_with_search = _get_queryset(Recipe, queryset_all, None, search_term, ordering_string, '-name')
@@ -2854,6 +2845,7 @@ if toastermain.settings.MANAGED:
2854 e.vcs_link_url = e.vcs_link_url.replace('%branch%', e.preffered_layerversion.up_branch.name) 2845 e.vcs_link_url = e.vcs_link_url.replace('%branch%', e.preffered_layerversion.up_branch.name)
2855 2846
2856 context = { 2847 context = {
2848 'project' : prj,
2857 'projectlayerset' : jsonfilter(map(lambda x: x.layercommit.id, prj.projectlayer_set.all().select_related("layercommit"))), 2849 'projectlayerset' : jsonfilter(map(lambda x: x.layercommit.id, prj.projectlayer_set.all().select_related("layercommit"))),
2858 'objects' : target_info, 2850 'objects' : target_info,
2859 'objectname' : "recipes", 2851 'objectname' : "recipes",
@@ -2916,10 +2908,7 @@ if toastermain.settings.MANAGED:
2916 2908
2917 return response 2909 return response
2918 2910
2919 def machines(request): 2911 def machines(request, pid):
2920 if not 'project_id' in request.session:
2921 raise Exception("invalid page: cannot show page without a project")
2922
2923 template = "machines.html" 2912 template = "machines.html"
2924 # define here what parameters the view needs in the GET portion in order to 2913 # define here what parameters the view needs in the GET portion in order to
2925 # be able to display something. 'count' and 'page' are mandatory for all views 2914 # be able to display something. 'count' and 'page' are mandatory for all views
@@ -2928,13 +2917,13 @@ if toastermain.settings.MANAGED:
2928 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby }; 2917 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby };
2929 retval = _verify_parameters( request.GET, mandatory_parameters ) 2918 retval = _verify_parameters( request.GET, mandatory_parameters )
2930 if retval: 2919 if retval:
2931 return _redirect_parameters( 'machines', request.GET, mandatory_parameters) 2920 return _redirect_parameters( 'all-machines', request.GET, mandatory_parameters, pid = pid)
2932 2921
2933 # boilerplate code that takes a request for an object type and returns a queryset 2922 # boilerplate code that takes a request for an object type and returns a queryset
2934 # for that object type. copypasta for all needed table searches 2923 # for that object type. copypasta for all needed table searches
2935 (filter_string, search_term, ordering_string) = _search_tuple(request, Machine) 2924 (filter_string, search_term, ordering_string) = _search_tuple(request, Machine)
2936 2925
2937 prj = Project.objects.get(pk = request.session['project_id']) 2926 prj = Project.objects.get(pk = pid)
2938 compatible_layers = prj.compatible_layerversions() 2927 compatible_layers = prj.compatible_layerversions()
2939 2928
2940 queryset_all = Machine.objects.filter(layer_version__in=compatible_layers) 2929 queryset_all = Machine.objects.filter(layer_version__in=compatible_layers)
@@ -2946,7 +2935,7 @@ if toastermain.settings.MANAGED:
2946 # Make sure we only show machines / layers which are compatible 2935 # Make sure we only show machines / layers which are compatible
2947 # with the current project 2936 # with the current project
2948 2937
2949 project_layers = ProjectLayer.objects.filter(project_id=request.session['project_id']).values_list('layercommit',flat=True) 2938 project_layers = ProjectLayer.objects.filter(project_id=pid).values_list('layercommit',flat=True)
2950 2939
2951 # Now we need to weed out the layers which will appear as duplicated 2940 # Now we need to weed out the layers which will appear as duplicated
2952 # because they're from a layer source which doesn't need to be used 2941 # because they're from a layer source which doesn't need to be used
@@ -2958,6 +2947,7 @@ if toastermain.settings.MANAGED:
2958 machine_info = _build_page_range(Paginator(queryset_all, request.GET.get('count', 100)),request.GET.get('page', 1)) 2947 machine_info = _build_page_range(Paginator(queryset_all, request.GET.get('count', 100)),request.GET.get('page', 1))
2959 2948
2960 context = { 2949 context = {
2950 'project': prj,
2961 'objects' : machine_info, 2951 'objects' : machine_info,
2962 'projectlayerset' : jsonfilter(map(lambda x: x.layercommit.id, prj.projectlayer_set.all())), 2952 'projectlayerset' : jsonfilter(map(lambda x: x.layercommit.id, prj.projectlayer_set.all())),
2963 'objectname' : "machines", 2953 'objectname' : "machines",
@@ -3041,6 +3031,7 @@ if toastermain.settings.MANAGED:
3041 configvars = configvars.exclude(name = var) 3031 configvars = configvars.exclude(name = var)
3042 3032
3043 context = { 3033 context = {
3034 'project': prj,
3044 'configvars': configvars, 3035 'configvars': configvars,
3045 'vars_managed': vars_managed, 3036 'vars_managed': vars_managed,
3046 'vars_fstypes': vars_fstypes, 3037 'vars_fstypes': vars_fstypes,
@@ -3316,17 +3307,6 @@ if toastermain.settings.MANAGED:
3316 3307
3317 3308
3318else: 3309else:
3319 # these are pages that are NOT available in interactive mode
3320 def managedcontextprocessor(request):
3321 return {
3322 "projects": [],
3323 "MANAGED" : toastermain.settings.MANAGED,
3324 "DEBUG" : toastermain.settings.DEBUG,
3325 "TOASTER_BRANCH": toastermain.settings.TOASTER_BRANCH,
3326 "TOASTER_REVISION" : toastermain.settings.TOASTER_REVISION,
3327 }
3328
3329
3330 # shows the "all builds" page for interactive mode; this is the old code, simply moved 3310 # shows the "all builds" page for interactive mode; this is the old code, simply moved
3331 def builds(request): 3311 def builds(request):
3332 template = 'build.html' 3312 template = 'build.html'