summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-03-24 15:08:04 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-25 11:17:34 +0000
commit478f1b7afe46c0d6328d4b8db1d32e22aef6759d (patch)
tree796bcfcfd1290edba2d186c12e9f05af4878e10f /bitbake
parent70f1a3db5e102cff658e51007e0cac5207f197bb (diff)
downloadpoky-478f1b7afe46c0d6328d4b8db1d32e22aef6759d.tar.gz
bitbake: toaster: replace package dependency tag w/ view queries
This patch moves the queries for package dependencies from the project tags to the views. This is done to bring the code inline with the Django philosophy of making all data queries in views.py This change has no performance implication. (Bitbake rev: 9dd53bd4355148916a89cf672b6c5db5f6b1ae35) 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/toastergui/templates/target.html4
-rw-r--r--bitbake/lib/toaster/toastergui/templatetags/projecttags.py14
-rw-r--r--bitbake/lib/toaster/toastergui/views.py6
3 files changed, 8 insertions, 16 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/target.html b/bitbake/lib/toaster/toastergui/templates/target.html
index 45128986e1..5396b17dc9 100644
--- a/bitbake/lib/toaster/toastergui/templates/target.html
+++ b/bitbake/lib/toaster/toastergui/templates/target.html
@@ -79,7 +79,7 @@
79 {{package.license}} 79 {{package.license}}
80 </td> 80 </td>
81 <td class="depends"> 81 <td class="depends">
82 {% with deps=package|runtime_dependencies:target.id %} 82 {% with deps=package.runtime_dependencies %}
83 {% with deps_count=deps|length %} 83 {% with deps_count=deps|length %}
84 {% if deps_count > 0 %} 84 {% if deps_count > 0 %}
85 <a class="btn" 85 <a class="btn"
@@ -96,7 +96,7 @@
96 {% endwith %} 96 {% endwith %}
97 </td> 97 </td>
98 <td class="brought_in_by"> 98 <td class="brought_in_by">
99 {% with rdeps=package|reverse_runtime_dependencies:target.id %} 99 {% with rdeps=package.reverse_runtime_dependencies %}
100 {% with rdeps_count=rdeps|length %} 100 {% with rdeps_count=rdeps|length %}
101 {% if rdeps_count > 0 %} 101 {% if rdeps_count > 0 %}
102 <a class="btn" 102 <a class="btn"
diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
index 39e92ce776..12c2468fa1 100644
--- a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
+++ b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
@@ -217,20 +217,6 @@ def filtered_packageversion(version, revision):
217 """ 217 """
218 return "" if (not version or version == "") else version if (not revision or revision == "") else version + "-" + revision 218 return "" if (not version or version == "") else version if (not revision or revision == "") else version + "-" + revision
219 219
220from django.db import models
221from orm.models import Package
222@register.filter
223def runtime_dependencies(package_object, targetid):
224 """ Return a queryset that lists the packages this package depends on
225 """
226 return package_object.package_dependencies_source.filter(target_id__exact=targetid, dep_type__in={'1'})
227
228@register.filter
229def reverse_runtime_dependencies(package_object, targetid):
230 """ Return a queryset that lists the packages depending on this package
231 """
232 return package_object.package_dependencies_target.filter(target_id__exact = targetid,dep_type__in={'1'})
233
234@register.filter 220@register.filter
235def filter_sizeovertotal(package_object, total_size): 221def filter_sizeovertotal(package_object, total_size):
236 """ Return the % size of the package over the total size argument 222 """ Return the % size of the package over the total size argument
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 732be8f285..e523c3181c 100644
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -429,6 +429,12 @@ def target(request, build_id, target_id):
429 packages_sum = queryset.aggregate(Sum('installed_size')) 429 packages_sum = queryset.aggregate(Sum('installed_size'))
430 queryset = _get_queryset(Package, queryset, filter_string, search_term, ordering_string) 430 queryset = _get_queryset(Package, queryset, filter_string, search_term, ordering_string)
431 packages = _build_page_range(Paginator(queryset, request.GET.get('count', 25)),request.GET.get('page', 1)) 431 packages = _build_page_range(Paginator(queryset, request.GET.get('count', 25)),request.GET.get('page', 1))
432
433 # bring in package dependencies
434 for p in packages.object_list:
435 p.runtime_dependencies = p.package_dependencies_source.filter(target_id = target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS)
436 p.reverse_runtime_dependencies = p.package_dependencies_target.filter(target_id = target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS)
437
432 context = { 'build': Build.objects.filter(pk=build_id)[0], 438 context = { 'build': Build.objects.filter(pk=build_id)[0],
433 'target': Target.objects.filter(pk=target_id)[0], 439 'target': Target.objects.filter(pk=target_id)[0],
434 'objects': packages, 440 'objects': packages,