[bitbake-devel] [PATCH 01/14] toaster: link task order to right tasks page

Alex DAMIAN alexandru.damian at intel.com
Fri Apr 4 14:10:40 UTC 2014


From: David Reyna <David.Reyna at windriver.com>

When linking from a task order number to the All Tasks
page, automatically display the correct page for that link
anchor.

[YOCTO #5933]

Signed-off-by: David Reyna <David.Reyna at windriver.com>
Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
 lib/toaster/toastergui/templates/task.html |  2 +-
 lib/toaster/toastergui/urls.py             |  1 +
 lib/toaster/toastergui/views.py            | 36 +++++++++++++++++++++++++-----
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/lib/toaster/toastergui/templates/task.html b/lib/toaster/toastergui/templates/task.html
index 1a7e9d4..5c32250 100644
--- a/lib/toaster/toastergui/templates/task.html
+++ b/lib/toaster/toastergui/templates/task.html
@@ -199,7 +199,7 @@
         <i class="icon-question-sign get-help" title="The running sequence of each task in the build"></i>
         Task order
     </dt>
-    <dd><a href="{%url "tasks" build.pk %}#{{task.order}}">{{task.order}}</a></dd>
+    <dd><a href="{%url "tasks_task" build.pk task.order %}#{{task.order}}">{{task.order}}</a></dd>
     {% if task.task_executed %}
         <dt>
             <i class="icon-question-sign get-help" title="If this task executes a Python or Shell function(s)"></i>
diff --git a/lib/toaster/toastergui/urls.py b/lib/toaster/toastergui/urls.py
index ac83b38..d7e9457 100644
--- a/lib/toaster/toastergui/urls.py
+++ b/lib/toaster/toastergui/urls.py
@@ -26,6 +26,7 @@ urlpatterns = patterns('toastergui.views',
         url(r'^build/(?P<build_id>\d+)$', 'builddashboard', name="builddashboard"),
 
         url(r'^build/(?P<build_id>\d+)/tasks/$', 'tasks', name='tasks'),
+        url(r'^build/(?P<build_id>\d+)/tasks/(?P<task_id>\d+)/$', 'tasks_task', name='tasks_task'),
         url(r'^build/(?P<build_id>\d+)/task/(?P<task_id>\d+)$', 'task', name='task'),
 
         url(r'^build/(?P<build_id>\d+)/recipes/$', 'recipes', name='recipes'),
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 05e24ea..a92a03f 100644
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -196,7 +196,7 @@ def _get_queryset(model, queryset, filter_string, search_term, ordering_string,
         else:
             queryset = queryset.order_by(column)
 
-    # insure only distinct records (e.g. from multiple search hits) are returned 
+    # insure only distinct records (e.g. from multiple search hits) are returned
     return queryset.distinct()
 
 
@@ -746,7 +746,7 @@ def _find_task_provider(task):
             return trc
     return None
 
-def tasks_common(request, build_id, variant):
+def tasks_common(request, build_id, variant, task_anchor):
 # This class is shared between these pages
 #
 # Column    tasks  buildtime  diskio  cpuusage
@@ -766,6 +766,10 @@ def tasks_common(request, build_id, variant):
 # 'min':on always, 'def':on by default, else hidden
 # '+' default column sort up, '-' default column sort down
 
+    anchor = request.GET.get('anchor', '')
+    if not anchor:
+        anchor=task_anchor
+
     # default ordering depends on variant
     if   'buildtime' == variant:
         title_variant='Time'
@@ -791,12 +795,29 @@ def tasks_common(request, build_id, variant):
     template = 'tasks.html'
     retval = _verify_parameters( request.GET, mandatory_parameters )
     if retval:
+        if task_anchor:
+	        mandatory_parameters['anchor']=task_anchor
         return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id)
     (filter_string, search_term, ordering_string) = _search_tuple(request, Task)
     queryset_all = Task.objects.filter(build=build_id, order__gt=0)
     queryset_with_search = _get_queryset(Task, queryset_all, None , search_term, ordering_string, 'order')
     queryset = _get_queryset(Task, queryset_all, filter_string, search_term, ordering_string, 'order')
 
+	# compute the anchor's page
+    if anchor:
+	    request.GET = request.GET.copy()
+        del request.GET['anchor']
+        i=0
+        a=int(anchor)
+		count_per_page=int(request.GET.get('count', 100))
+        for task in queryset.iterator():
+            if a == task.order:
+				new_page= (i / count_per_page ) + 1
+				request.GET.__setitem__('page', new_page)
+				mandatory_parameters['page']=new_page
+				return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id)
+            i += 1
+
     tasks = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1))
 
     # define (and modify by variants) the 'tablecols' members
@@ -937,16 +958,19 @@ def tasks_common(request, build_id, variant):
     return render(request, template, context)
 
 def tasks(request, build_id):
-    return tasks_common(request, build_id, 'tasks')
+    return tasks_common(request, build_id, 'tasks', '')
+
+def tasks_task(request, build_id, task_id):
+    return tasks_common(request, build_id, 'tasks', task_id)
 
 def buildtime(request, build_id):
-    return tasks_common(request, build_id, 'buildtime')
+    return tasks_common(request, build_id, 'buildtime', '')
 
 def diskio(request, build_id):
-    return tasks_common(request, build_id, 'diskio')
+    return tasks_common(request, build_id, 'diskio', '')
 
 def cpuusage(request, build_id):
-    return tasks_common(request, build_id, 'cpuusage')
+    return tasks_common(request, build_id, 'cpuusage', '')
 
 
 def recipes(request, build_id):
-- 
1.9.1



More information about the bitbake-devel mailing list