summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-22 14:48:53 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-26 09:27:32 +0100
commit5d0abf197a513f09fa980b9aed1a02822639b7f0 (patch)
tree7ae9a32a197952feeede888388ea51f73dc744d8 /bitbake
parent70c4eb8d3acaad267ee943ebfba793f9cc1c5ee6 (diff)
downloadpoky-5d0abf197a513f09fa980b9aed1a02822639b7f0.tar.gz
bitbake: toastergui: select project types
This brings in project types in the New Project page. The "analisys" projects are the projects with no "release" set, and have read-only properties in the project page. (Bitbake rev: 2efc338cefd6e6e097af83d7dff63e9ba177d021) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/orm/models.py8
-rw-r--r--bitbake/lib/toaster/toastergui/templates/newproject.html99
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py11
3 files changed, 80 insertions, 38 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 077c94d818..8488aa4648 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -57,7 +57,11 @@ class ToasterSetting(models.Model):
57 57
58class ProjectManager(models.Manager): 58class ProjectManager(models.Manager):
59 def create_project(self, name, release): 59 def create_project(self, name, release):
60 prj = self.model(name = name, bitbake_version = release.bitbake_version, release = release) 60 if release is not None:
61 prj = self.model(name = name, bitbake_version = release.bitbake_version, release = release)
62 else:
63 prj = self.model(name = name, bitbake_version = None, release = None)
64
61 prj.save() 65 prj.save()
62 66
63 for defaultconf in ToasterSetting.objects.filter(name__startswith="DEFCONF_"): 67 for defaultconf in ToasterSetting.objects.filter(name__startswith="DEFCONF_"):
@@ -66,6 +70,8 @@ class ProjectManager(models.Manager):
66 name = name, 70 name = name,
67 value = defaultconf.value) 71 value = defaultconf.value)
68 72
73 if release is None:
74 return prj
69 75
70 for rdl in release.releasedefaultlayer_set.all(): 76 for rdl in release.releasedefaultlayer_set.all():
71 try: 77 try:
diff --git a/bitbake/lib/toaster/toastergui/templates/newproject.html b/bitbake/lib/toaster/toastergui/templates/newproject.html
index ed3a279052..1159d717ae 100644
--- a/bitbake/lib/toaster/toastergui/templates/newproject.html
+++ b/bitbake/lib/toaster/toastergui/templates/newproject.html
@@ -11,60 +11,74 @@
11 <div class="alert alert-error row-fluid" role="alert">{{alert}}</div> 11 <div class="alert alert-error row-fluid" role="alert">{{alert}}</div>
12 {% endif %} 12 {% endif %}
13 </div> 13 </div>
14 {% if releases.count > 0 %} 14
15 <div class="row-fluid">
16 <div class="span6">
15 <form method="POST">{% csrf_token %} 17 <form method="POST">{% csrf_token %}
18
16 <fieldset> 19 <fieldset>
17 <label>Project name <span class="muted">(required)</span></label> 20 <label>Project name <span class="muted">(required)</span></label>
18 <input type="text" class="input-xlarge" required id="new-project-name" name="projectname"> 21 <input type="text" class="input-xlarge" required id="new-project-name" name="projectname">
19 {% if releases.count > 1 %} 22 </fieldset>
23
24 <fieldset>
25 <label class="project-form">Project type</label>
26 <label class="project-form radio"><input type="radio" name="ptype" value="analysis" checked/> Analysis Project</label>
27
28 {% if releases.count > 0 %}
29 <label class="project-form radio"><input type="radio" name="ptype" value="build" checked /> Build Project</label>
30 {% endif %}
31 </fieldset>
32
33 {% if releases.count > 0 %}
34 <fieldset class="release">
35 {% if releases.count > 1 %}
20 <label class="project-form"> 36 <label class="project-form">
21 Release 37 Release
22 <i class="icon-question-sign get-help" title="The version of the build system you want to use"></i> 38 <i class="icon-question-sign get-help" title="The version of the build system you want to use"></i>
23 </label> 39 </label>
24 <select name="projectversion" id="projectversion"> 40 <select name="projectversion" id="projectversion">
25 {% for release in releases %} 41 {% for release in releases %}
26 <option value="{{release.id}}" 42 <option value="{{release.id}}"
27 {%if defaultbranch == release.name %} 43 {%if defaultbranch == release.name %}
28 selected 44 selected
29 {%endif%} 45 {%endif%}
30 46 >{{release.description}}</option>
31 >{{release.description}}</option> 47 {% endfor %}
32 {% endfor %}
33 </select> 48 </select>
34 {% for release in releases %} 49 {% for release in releases %}
35 <div class="row-fluid helptext" id="description-{{release.id}}" style="display: none"> 50 <div class="row-fluid helptext" id="description-{{release.id}}" style="display: none">
36 <span class="help-block span5">{{release.helptext|safe}}</span> 51 <span class="help-block span5">{{release.helptext|safe}}</span>
37 </div> 52 </div>
38 {% endfor %} 53 {% endfor %}
39 {% else %} 54 {% else %}
40 <input type="hidden" name="projectversion" value="{{releases.0.id}}"/> 55 <input type="hidden" name="projectversion" value="{{releases.0.id}}"/>
41 {% endif %} 56 {% endif %}
42
43 </fieldset> 57 </fieldset>
58 {% endif %}
44 59
45 <div class="form-actions"> 60 <div class="form-actions">
46 <input type="submit" class="btn btn-primary btn-large" value="Create project"/> 61 <input type="submit" class="btn btn-primary btn-large" value="Create project"/>
47 <span class="help-inline" style="vertical-align:middle;">To create a project, you need to enter a project name</span> 62 <span class="help-inline" style="vertical-align:middle;">To create a project, you need to enter a project name</span>
48 </div> 63 </div>
49 </form> 64 </form>
50 {% else %} 65 </div>
51 <br/>
52 <div class="alert alert-warning row-fluid span6">
53 <h3>No releases configured</h3>
54 <p>
55 It looks like Toaster releases have not been configured properly. Contact the person who set up Toaster, and tell them about it.
56 </p>
57 <p>
58 If you are the Toaster administrator, we are sorry: setting up Toaster is not easy.
59 <ul>
60 <li><a href="{% url 'admin:orm_release_changelist' %}">Log in to the Django administration interface</a> and check the "Releases" section.</li>
61 <li>Check out the <a href="https://wiki.yoctoproject.org/wiki/Setting_up_a_hosted_managed_mode_for_Toaster#Releases">documentation about configuring releases</a></li>
62 </ul>
63 </p>
64 </div>
65 {% endif %}
66 66
67</div> 67 <div class="span5 well">
68 <span class="help-block">
69 <h4>Toaster project types</h4>
70 <p>With a <strong>build project</strong> you configure and run your builds from Toaster.</p>
71 <p>With an <strong>analysis project</strong>, the builds are configured and run by another tool
72 (something like Buildbot or Jenkins), and the project only collects the information about the
73 builds (packages, recipes, dependencies, logs, etc). </p>
74 <p>You can read more on <a href="#">how to set up an analysis project</a>
75 in the Toaster manual.</p>
76 <h4>Release</h4>
77 <p>If you create a <strong>build project</strong>, you will need to select a <strong>release</strong>,
78 which is the version of the build system you want to use to run your builds.</p>
79 </div>
80 </div>
81 </div>
68 82
69 <script type="text/javascript"> 83 <script type="text/javascript">
70 $(document).ready(function () { 84 $(document).ready(function () {
@@ -94,6 +108,21 @@
94 $(".helptext").hide(); 108 $(".helptext").hide();
95 $('#description-' + new_release).fadeIn(); 109 $('#description-' + new_release).fadeIn();
96 }); 110 });
111
112 // Hide the project release when you select an analysis project
113 function projectType() {
114 if ($("input[type='radio']:checked").val() == 'build') {
115 $('.release').fadeIn();
116 }
117 else {
118 $('.release').fadeOut();
119 }
120 }
121 projectType();
122
123 $('input:radio').change(function(){
124 projectType();
125 });
97 }) 126 })
98 </script> 127 </script>
99 128
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 8c6f9fa84f..1a504b8455 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2104,8 +2104,11 @@ if True:
2104 # render new project page 2104 # render new project page
2105 return render(request, template, context) 2105 return render(request, template, context)
2106 elif request.method == "POST": 2106 elif request.method == "POST":
2107 mandatory_fields = ['projectname', 'projectversion'] 2107 mandatory_fields = ['projectname', 'ptype']
2108 try: 2108 try:
2109 ptype = request.POST.get('ptype')
2110 if ptype == "build":
2111 mandatory_fields.append('projectversion')
2109 # make sure we have values for all mandatory_fields 2112 # make sure we have values for all mandatory_fields
2110 if reduce( lambda x, y: x or y, map(lambda x: len(request.POST.get(x, '')) == 0, mandatory_fields)): 2113 if reduce( lambda x, y: x or y, map(lambda x: len(request.POST.get(x, '')) == 0, mandatory_fields)):
2111 # set alert for missing fields 2114 # set alert for missing fields
@@ -2121,7 +2124,11 @@ if True:
2121 login(request, user) 2124 login(request, user)
2122 2125
2123 # save the project 2126 # save the project
2124 prj = Project.objects.create_project(name = request.POST['projectname'], release = Release.objects.get(pk = request.POST['projectversion'])) 2127 release = Release.objects.get(pk = request.POST.get('projectversion', None ))
2128 if ptype == "analysis":
2129 release = None
2130
2131 prj = Project.objects.create_project(name = request.POST['projectname'], release = release)
2125 prj.user_id = request.user.pk 2132 prj.user_id = request.user.pk
2126 prj.save() 2133 prj.save()
2127 return redirect(reverse(project, args=(prj.pk,)) + "#/newproject") 2134 return redirect(reverse(project, args=(prj.pk,)) + "#/newproject")