summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui
diff options
context:
space:
mode:
authorMarius Avram <marius.avram@intel.com>2014-08-29 15:51:01 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-09-05 10:14:25 +0100
commit69e5cbdac50418738d72987b6ee943933f6bfd51 (patch)
tree71a234c7d815c51730b5798f33729ed793a66d44 /bitbake/lib/toaster/toastergui
parenta6f1e3172173ac0a77c27ae410a786521e6391d3 (diff)
downloadpoky-69e5cbdac50418738d72987b6ee943933f6bfd51.tar.gz
bitbake: toaster: use cookies for count and sorting in templates tables
Until now cookies were used to save which columns were shown and which were hidden in toaster tables. The tables from the templates also have functionalities like sorting the entries on a certain column and limiting the number of entries displayed on a page. The later however were not saved using cookies. This patch brings this new feature. The cookies are not saved only in the front-end. They are saved both in the frontend in case the user uses the inputs/buttons to change a parameter and also in the backend in case the user specifies manually using GET variables the value of the parameters. When no GET parameters are given the views will redirect the url to one containg the parameters saved as cookies. When no cookies exist, default values will be used. [YOCTO #6126] (Bitbake rev: 880b58c845e3a501fa90d24e1bd89c87ca84b709) Signed-off-by: Marius Avram <marius.avram@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui')
-rw-r--r--bitbake/lib/toaster/toastergui/templates/basetable_bottom.html15
-rw-r--r--bitbake/lib/toaster/toastergui/templates/basetable_top.html11
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py122
3 files changed, 102 insertions, 46 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html b/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html
index ac14363798..cbdc164273 100644
--- a/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html
+++ b/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html
@@ -26,7 +26,7 @@
26 <span class="help-inline" style="padding-top:5px;">Show rows:</span> 26 <span class="help-inline" style="padding-top:5px;">Show rows:</span>
27 <select style="margin-top:5px;margin-bottom:0px;" class="pagesize"> 27 <select style="margin-top:5px;margin-bottom:0px;" class="pagesize">
28 {% with "2 5 10 25 50 100" as list%} 28 {% with "2 5 10 25 50 100" as list%}
29 {% for i in list.split %}<option{%if i == request.GET.count %} selected{%endif%}>{{i}}</option> 29 {% for i in list.split %}<option value="{{i}}">{{i}}</option>
30 {% endfor %} 30 {% endfor %}
31 {% endwith %} 31 {% endwith %}
32 </select> 32 </select>
@@ -56,6 +56,14 @@
56 } 56 }
57 } 57 }
58 58
59 // load cookie for number of entries to be displayed on page
60 pagesize = $.cookie('count');
61 if (!pagesize)
62 pagesize = 10;
63 $('.pagesize option').prop('selected', false)
64 .filter('[value="' + pagesize + '"]')
65 .attr('selected', true);
66
59 $('.chbxtoggle').each(function () { 67 $('.chbxtoggle').each(function () {
60 showhideTableColumn($(this).attr('id'), $(this).is(':checked')) 68 showhideTableColumn($(this).attr('id'), $(this).is(':checked'))
61 }); 69 });
@@ -72,8 +80,9 @@
72 $('.progress, .lead span').tooltip({container:'table', placement:'top'}); 80 $('.progress, .lead span').tooltip({container:'table', placement:'top'});
73 81
74 $(".pagesize").change(function () { 82 $(".pagesize").change(function () {
75 console.log("page size change"); 83 reload_params({"count":$(this).val()});
76 reload_params({"count":$(this).val()}); ; 84 // save cookie with pagesize
85 $.cookie("count", $(this).val(), { path : $(location).attr('pathname') });
77 }); 86 });
78}); 87});
79</script> 88</script>
diff --git a/bitbake/lib/toaster/toastergui/templates/basetable_top.html b/bitbake/lib/toaster/toastergui/templates/basetable_top.html
index 1231e1f924..037554b627 100644
--- a/bitbake/lib/toaster/toastergui/templates/basetable_top.html
+++ b/bitbake/lib/toaster/toastergui/templates/basetable_top.html
@@ -156,6 +156,13 @@
156 showhideImmediateTableAction( clname, sh, orderkey ); 156 showhideImmediateTableAction( clname, sh, orderkey );
157 } 157 }
158 158
159 //
160 // saves a cookie with selected order field
161 //
162 function saveOrderCookie( orderfield ) {
163 $.cookie("orderby", orderfield, { path: $(location).attr('pathname') });
164 }
165
159 </script> 166 </script>
160 167
161<!-- control header --> 168<!-- control header -->
@@ -205,7 +212,7 @@
205 <span class="help-inline" style="padding-top:5px;">Show rows:</span> 212 <span class="help-inline" style="padding-top:5px;">Show rows:</span>
206 <select style="margin-top:5px;margin-bottom:0px;" class="pagesize"> 213 <select style="margin-top:5px;margin-bottom:0px;" class="pagesize">
207 {% with "2 5 10 25 50 100" as list%} 214 {% with "2 5 10 25 50 100" as list%}
208{% for i in list.split %} <option{%if i == request.GET.count %} selected{%endif%}>{{i}}</option> 215{% for i in list.split %} <option value="{{i}}">{{i}}</option>
209 {% endfor %} 216 {% endfor %}
210 {% endwith %} 217 {% endwith %}
211 </select> 218 </select>
@@ -221,7 +228,7 @@
221 <tr> 228 <tr>
222 {% for tc in tablecols %}<th class="{{tc.dclass}} {{tc.clclass}}"> 229 {% for tc in tablecols %}<th class="{{tc.dclass}} {{tc.clclass}}">
223 {%if tc.qhelp%}<i class="icon-question-sign get-help" title="{{tc.qhelp}}"></i>{%endif%} 230 {%if tc.qhelp%}<i class="icon-question-sign get-help" title="{{tc.qhelp}}"></i>{%endif%}
224 {%if tc.orderfield%}<a {%if tc.ordericon%} class="sorted" {%endif%}href="javascript:reload_params({'page': 1, 'orderby' : '{{tc.orderfield}}' })" >{{tc.name}}</a>{%else%}<span class="muted">{{tc.name}}</span>{%endif%} 231 {%if tc.orderfield%}<a {%if tc.ordericon%} class="sorted" {%endif%}href="javascript:reload_params({'page': 1, 'orderby' : '{{tc.orderfield}}' })" onclick="saveOrderCookie('{{tc.orderfield}}')">{{tc.name}}</a>{%else%}<span class="muted">{{tc.name}}</span>{%endif%}
225 {%if tc.ordericon%} <i class="icon-caret-{{tc.ordericon}}"></i>{%endif%} 232 {%if tc.ordericon%} <i class="icon-caret-{{tc.ordericon}}"></i>{%endif%}
226 {%if tc.filter%}<div class="btn-group pull-right"> 233 {%if tc.filter%}<div class="btn-group pull-right">
227 <a href="#filter_{{tc.filter.class}}" role="button" class="btn btn-mini {%if request.GET.filter%}{{tc.filter.options|filtered_icon:request.GET.filter}} {%endif%}" {%if request.GET.filter and tc.filter.options|filtered_tooltip:request.GET.filter %} title="<p>{{tc.filter.options|filtered_tooltip:request.GET.filter}}</p><p><a class='btn btn-small btn-primary' href=javascript:reload_params({'filter':''})>Show all {% if filter_search_display %}{{filter_search_display}}{% else %}{{objectname}}{% endif %}</a></p>" {%endif%} data-toggle="modal"> <i class="icon-filter filtered"></i> </a> 234 <a href="#filter_{{tc.filter.class}}" role="button" class="btn btn-mini {%if request.GET.filter%}{{tc.filter.options|filtered_icon:request.GET.filter}} {%endif%}" {%if request.GET.filter and tc.filter.options|filtered_tooltip:request.GET.filter %} title="<p>{{tc.filter.options|filtered_tooltip:request.GET.filter}}</p><p><a class='btn btn-small btn-primary' href=javascript:reload_params({'filter':''})>Show all {% if filter_search_display %}{{filter_search_display}}{% else %}{{objectname}}{% endif %}</a></p>" {%endif%} data-toggle="modal"> <i class="icon-filter filtered"></i> </a>
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 22b26d0e83..defbbbfa4c 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -20,6 +20,7 @@
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 21
22import operator,re 22import operator,re
23import HTMLParser
23 24
24from django.db.models import Q, Sum 25from django.db.models import Q, Sum
25from django.db import IntegrityError 26from django.db import IntegrityError
@@ -32,6 +33,7 @@ from django.core.urlresolvers import reverse
32from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger 33from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
33from django.http import HttpResponseBadRequest, HttpResponseNotFound 34from django.http import HttpResponseBadRequest, HttpResponseNotFound
34from django.utils import timezone 35from django.utils import timezone
36from django.utils.html import escape
35from datetime import timedelta 37from datetime import timedelta
36from django.utils import formats 38from django.utils import formats
37import json 39import json
@@ -200,6 +202,22 @@ def _get_queryset(model, queryset, filter_string, search_term, ordering_string,
200 # insure only distinct records (e.g. from multiple search hits) are returned 202 # insure only distinct records (e.g. from multiple search hits) are returned
201 return queryset.distinct() 203 return queryset.distinct()
202 204
205# returns the value of entries per page and the name of the applied sorting field.
206# if the value is given explicitly as a GET parameter it will be the first selected,
207# otherwise the cookie value will be used.
208def _get_parameters_values(request, default_count, default_order):
209 pagesize = request.GET.get('count', request.COOKIES.get('count', default_count))
210 orderby = request.GET.get('orderby', request.COOKIES.get('orderby', default_order))
211 return (pagesize, orderby)
212
213
214# set cookies for parameters. this is usefull in case parameters are set
215# manually from the GET values of the link
216def _save_parameters_cookies(response, pagesize, orderby, request):
217 html_parser = HTMLParser.HTMLParser()
218 response.set_cookie(key='count', value=pagesize, path=request.path)
219 response.set_cookie(key='orderby', value=html_parser.unescape(orderby), path=request.path)
220 return response
203 221
204# shows the "all builds" page 222# shows the "all builds" page
205def builds(request): 223def builds(request):
@@ -207,7 +225,8 @@ def builds(request):
207 # define here what parameters the view needs in the GET portion in order to 225 # define here what parameters the view needs in the GET portion in order to
208 # be able to display something. 'count' and 'page' are mandatory for all views 226 # be able to display something. 'count' and 'page' are mandatory for all views
209 # that use paginators. 227 # that use paginators.
210 mandatory_parameters = { 'count': 10, 'page' : 1, 'orderby' : 'completed_on:-' }; 228 (pagesize, orderby) = _get_parameters_values(request, 10, 'completed_on:-')
229 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby }
211 retval = _verify_parameters( request.GET, mandatory_parameters ) 230 retval = _verify_parameters( request.GET, mandatory_parameters )
212 if retval: 231 if retval:
213 return _redirect_parameters( 'all-builds', request.GET, mandatory_parameters) 232 return _redirect_parameters( 'all-builds', request.GET, mandatory_parameters)
@@ -220,7 +239,7 @@ def builds(request):
220 queryset = _get_queryset(Build, queryset_all, filter_string, search_term, ordering_string, '-completed_on') 239 queryset = _get_queryset(Build, queryset_all, filter_string, search_term, ordering_string, '-completed_on')
221 240
222 # retrieve the objects that will be displayed in the table; builds a paginator and gets a page range to display 241 # retrieve the objects that will be displayed in the table; builds a paginator and gets a page range to display
223 build_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1)) 242 build_info = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1))
224 243
225 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) 244 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
226 build_mru = Build.objects.filter(completed_on__gte=(timezone.now()-timedelta(hours=24))).order_by("-started_on")[:3] 245 build_mru = Build.objects.filter(completed_on__gte=(timezone.now()-timedelta(hours=24))).order_by("-started_on")[:3]
@@ -368,7 +387,9 @@ def builds(request):
368 ] 387 ]
369 } 388 }
370 389
371 return render(request, template, context) 390 response = render(request, template, context)
391 _save_parameters_cookies(response, pagesize, orderby, request)
392 return response
372 393
373 394
374## 395##
@@ -537,8 +558,8 @@ def recipe(request, build_id, recipe_id):
537 558
538def target_common( request, build_id, target_id, variant ): 559def target_common( request, build_id, target_id, variant ):
539 template = "target.html" 560 template = "target.html"
540 default_orderby = 'name:+'; 561 (pagesize, orderby) = _get_parameters_values(request, 25, 'name:+')
541 mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'name:+'}; 562 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby': orderby }
542 retval = _verify_parameters( request.GET, mandatory_parameters ) 563 retval = _verify_parameters( request.GET, mandatory_parameters )
543 if retval: 564 if retval:
544 return _redirect_parameters( 565 return _redirect_parameters(
@@ -554,8 +575,7 @@ def target_common( request, build_id, target_id, variant ):
554 packages_sum = queryset.aggregate( Sum( 'installed_size' )) 575 packages_sum = queryset.aggregate( Sum( 'installed_size' ))
555 queryset = _get_queryset( 576 queryset = _get_queryset(
556 Package, queryset, filter_string, search_term, ordering_string, 'name' ) 577 Package, queryset, filter_string, search_term, ordering_string, 'name' )
557 packages = _build_page_range( Paginator( 578 packages = _build_page_range( Paginator(queryset, pagesize), request.GET.get( 'page', 1 ))
558 queryset, request.GET.get( 'count', 25 )),request.GET.get( 'page', 1 ))
559 579
560 # bring in package dependencies 580 # bring in package dependencies
561 for p in packages.object_list: 581 for p in packages.object_list:
@@ -679,7 +699,7 @@ his package',
679 'objects' : packages, 699 'objects' : packages,
680 'packages_sum' : packages_sum[ 'installed_size__sum' ], 700 'packages_sum' : packages_sum[ 'installed_size__sum' ],
681 'object_search_display': "packages included", 701 'object_search_display': "packages included",
682 'default_orderby' : default_orderby, 702 'default_orderby' : orderby,
683 'tablecols' : [ 703 'tablecols' : [
684 tc_package, 704 tc_package,
685 tc_packageVersion, 705 tc_packageVersion,
@@ -696,7 +716,10 @@ his package',
696 tc_layerDir, 716 tc_layerDir,
697 ] 717 ]
698 } 718 }
699 return( render( request, template, context )) 719
720 response = render(request, template, context)
721 _save_parameters_cookies(response, pagesize, orderby, request)
722 return response
700 723
701def target( request, build_id, target_id ): 724def target( request, build_id, target_id ):
702 return( target_common( request, build_id, target_id, "target" )) 725 return( target_common( request, build_id, target_id, "target" ))
@@ -878,26 +901,25 @@ def tasks_common(request, build_id, variant, task_anchor):
878 title_variant='Time' 901 title_variant='Time'
879 object_search_display="time data" 902 object_search_display="time data"
880 filter_search_display="tasks" 903 filter_search_display="tasks"
881 mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'elapsed_time:-'}; 904 (pagesize, orderby) = _get_parameters_values(request, 25, 'elapsed_time:-')
882 default_orderby = 'elapsed_time:-';
883 elif 'diskio' == variant: 905 elif 'diskio' == variant:
884 title_variant='Disk I/O' 906 title_variant='Disk I/O'
885 object_search_display="disk I/O data" 907 object_search_display="disk I/O data"
886 filter_search_display="tasks" 908 filter_search_display="tasks"
887 mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'disk_io:-'}; 909 (pagesize, orderby) = _get_parameters_values(request, 25, 'disk_io:-')
888 default_orderby = 'disk_io:-';
889 elif 'cpuusage' == variant: 910 elif 'cpuusage' == variant:
890 title_variant='CPU usage' 911 title_variant='CPU usage'
891 object_search_display="CPU usage data" 912 object_search_display="CPU usage data"
892 filter_search_display="tasks" 913 filter_search_display="tasks"
893 mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'cpu_usage:-'}; 914 (pagesize, orderby) = _get_parameters_values(request, 25, 'cpu_usage:-')
894 default_orderby = 'cpu_usage:-';
895 else : 915 else :
896 title_variant='Tasks' 916 title_variant='Tasks'
897 object_search_display="tasks" 917 object_search_display="tasks"
898 filter_search_display="tasks" 918 filter_search_display="tasks"
899 mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'order:+'}; 919 (pagesize, orderby) = _get_parameters_values(request, 25, 'order:+')
900 default_orderby = 'order:+'; 920
921
922 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby': orderby }
901 923
902 template = 'tasks.html' 924 template = 'tasks.html'
903 retval = _verify_parameters( request.GET, mandatory_parameters ) 925 retval = _verify_parameters( request.GET, mandatory_parameters )
@@ -923,7 +945,7 @@ def tasks_common(request, build_id, variant, task_anchor):
923 del request.GET['anchor'] 945 del request.GET['anchor']
924 i=0 946 i=0
925 a=int(anchor) 947 a=int(anchor)
926 count_per_page=int(request.GET.get('count', 100)) 948 count_per_page=int(pagesize)
927 for task in queryset.iterator(): 949 for task in queryset.iterator():
928 if a == task.order: 950 if a == task.order:
929 new_page= (i / count_per_page ) + 1 951 new_page= (i / count_per_page ) + 1
@@ -932,7 +954,7 @@ def tasks_common(request, build_id, variant, task_anchor):
932 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id) 954 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id)
933 i += 1 955 i += 1
934 956
935 tasks = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) 957 tasks = _build_page_range(Paginator(queryset, pagesize),request.GET.get('page', 1))
936 958
937 # define (and modify by variants) the 'tablecols' members 959 # define (and modify by variants) the 'tablecols' members
938 tc_order={ 960 tc_order={
@@ -1063,7 +1085,7 @@ def tasks_common(request, build_id, variant, task_anchor):
1063 'title': title_variant, 1085 'title': title_variant,
1064 'build': Build.objects.filter(pk=build_id)[0], 1086 'build': Build.objects.filter(pk=build_id)[0],
1065 'objects': tasks, 1087 'objects': tasks,
1066 'default_orderby' : default_orderby, 1088 'default_orderby' : orderby,
1067 'search_term': search_term, 1089 'search_term': search_term,
1068 'total_count': queryset_with_search.count(), 1090 'total_count': queryset_with_search.count(),
1069 'tablecols':[ 1091 'tablecols':[
@@ -1080,7 +1102,9 @@ def tasks_common(request, build_id, variant, task_anchor):
1080 tc_log, 1102 tc_log,
1081 ]} 1103 ]}
1082 1104
1083 return render(request, template, context) 1105 response = render(request, template, context)
1106 _save_parameters_cookies(response, pagesize, orderby, request)
1107 return response
1084 1108
1085def tasks(request, build_id): 1109def tasks(request, build_id):
1086 return tasks_common(request, build_id, 'tasks', '') 1110 return tasks_common(request, build_id, 'tasks', '')
@@ -1100,7 +1124,8 @@ def cpuusage(request, build_id):
1100 1124
1101def recipes(request, build_id): 1125def recipes(request, build_id):
1102 template = 'recipes.html' 1126 template = 'recipes.html'
1103 mandatory_parameters = { 'count': 100, 'page' : 1, 'orderby':'name:+'}; 1127 (pagesize, orderby) = _get_parameters_values(request, 100, 'name:+')
1128 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby }
1104 retval = _verify_parameters( request.GET, mandatory_parameters ) 1129 retval = _verify_parameters( request.GET, mandatory_parameters )
1105 if retval: 1130 if retval:
1106 return _redirect_parameters( 'recipes', request.GET, mandatory_parameters, build_id = build_id) 1131 return _redirect_parameters( 'recipes', request.GET, mandatory_parameters, build_id = build_id)
@@ -1108,7 +1133,7 @@ def recipes(request, build_id):
1108 queryset = Recipe.objects.filter(layer_version__id__in=Layer_Version.objects.filter(build=build_id)) 1133 queryset = Recipe.objects.filter(layer_version__id__in=Layer_Version.objects.filter(build=build_id))
1109 queryset = _get_queryset(Recipe, queryset, filter_string, search_term, ordering_string, 'name') 1134 queryset = _get_queryset(Recipe, queryset, filter_string, search_term, ordering_string, 'name')
1110 1135
1111 recipes = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) 1136 recipes = _build_page_range(Paginator(queryset, pagesize),request.GET.get('page', 1))
1112 1137
1113 # prefetch the forward and reverse recipe dependencies 1138 # prefetch the forward and reverse recipe dependencies
1114 deps = { }; revs = { } 1139 deps = { }; revs = { }
@@ -1207,8 +1232,9 @@ def recipes(request, build_id):
1207 ] 1232 ]
1208 } 1233 }
1209 1234
1210 return render(request, template, context) 1235 response = render(request, template, context)
1211 1236 _save_parameters_cookies(response, pagesize, orderby, request)
1237 return response
1212 1238
1213def configuration(request, build_id): 1239def configuration(request, build_id):
1214 template = 'configuration.html' 1240 template = 'configuration.html'
@@ -1247,7 +1273,8 @@ def configuration(request, build_id):
1247 1273
1248def configvars(request, build_id): 1274def configvars(request, build_id):
1249 template = 'configvars.html' 1275 template = 'configvars.html'
1250 mandatory_parameters = { 'count': 100, 'page' : 1, 'orderby':'variable_name:+', 'filter':'description__regex:.+'}; 1276 (pagesize, orderby) = _get_parameters_values(request, 100, 'variable_name:+')
1277 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby, 'filter' : 'description__regex:.+' }
1251 retval = _verify_parameters( request.GET, mandatory_parameters ) 1278 retval = _verify_parameters( request.GET, mandatory_parameters )
1252 (filter_string, search_term, ordering_string) = _search_tuple(request, Variable) 1279 (filter_string, search_term, ordering_string) = _search_tuple(request, Variable)
1253 if retval: 1280 if retval:
@@ -1262,7 +1289,7 @@ def configvars(request, build_id):
1262 # remove records where the value is empty AND there are no history files 1289 # remove records where the value is empty AND there are no history files
1263 queryset = queryset.exclude(variable_value='',vhistory__file_name__isnull=True) 1290 queryset = queryset.exclude(variable_value='',vhistory__file_name__isnull=True)
1264 1291
1265 variables = _build_page_range(Paginator(queryset, request.GET.get('count', 50)), request.GET.get('page', 1)) 1292 variables = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1))
1266 1293
1267 # show all matching files (not just the last one) 1294 # show all matching files (not just the last one)
1268 file_filter= search_term + ":" 1295 file_filter= search_term + ":"
@@ -1328,12 +1355,14 @@ def configvars(request, build_id):
1328 ], 1355 ],
1329 } 1356 }
1330 1357
1331 return render(request, template, context) 1358 response = render(request, template, context)
1332 1359 _save_parameters_cookies(response, pagesize, orderby, request)
1360 return response
1333 1361
1334def bpackage(request, build_id): 1362def bpackage(request, build_id):
1335 template = 'bpackage.html' 1363 template = 'bpackage.html'
1336 mandatory_parameters = { 'count': 100, 'page' : 1, 'orderby':'name:+'}; 1364 (pagesize, orderby) = _get_parameters_values(request, 100, 'name:+')
1365 mandatory_parameters = { 'count' : pagesize, 'page' : 1, 'orderby' : orderby }
1337 retval = _verify_parameters( request.GET, mandatory_parameters ) 1366 retval = _verify_parameters( request.GET, mandatory_parameters )
1338 if retval: 1367 if retval:
1339 return _redirect_parameters( 'packages', request.GET, mandatory_parameters, build_id = build_id) 1368 return _redirect_parameters( 'packages', request.GET, mandatory_parameters, build_id = build_id)
@@ -1341,7 +1370,7 @@ def bpackage(request, build_id):
1341 queryset = Package.objects.filter(build = build_id).filter(size__gte=0) 1370 queryset = Package.objects.filter(build = build_id).filter(size__gte=0)
1342 queryset = _get_queryset(Package, queryset, filter_string, search_term, ordering_string, 'name') 1371 queryset = _get_queryset(Package, queryset, filter_string, search_term, ordering_string, 'name')
1343 1372
1344 packages = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) 1373 packages = _build_page_range(Paginator(queryset, pagesize),request.GET.get('page', 1))
1345 1374
1346 context = { 1375 context = {
1347 'objectname': 'packages built', 1376 'objectname': 'packages built',
@@ -1421,7 +1450,9 @@ def bpackage(request, build_id):
1421 ] 1450 ]
1422 } 1451 }
1423 1452
1424 return render(request, template, context) 1453 response = render(request, template, context)
1454 _save_parameters_cookies(response, pagesize, orderby, request)
1455 return response
1425 1456
1426def bfile(request, build_id, package_id): 1457def bfile(request, build_id, package_id):
1427 template = 'bfile.html' 1458 template = 'bfile.html'
@@ -1576,7 +1607,8 @@ def package_built_detail(request, build_id, package_id):
1576 1607
1577 # follow convention for pagination w/ search although not used for this view 1608 # follow convention for pagination w/ search although not used for this view
1578 queryset = Package_File.objects.filter(package_id__exact=package_id) 1609 queryset = Package_File.objects.filter(package_id__exact=package_id)
1579 mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'path:+'}; 1610 (pagesize, orderby) = _get_parameters_values(request, 25, 'path:+')
1611 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby }
1580 retval = _verify_parameters( request.GET, mandatory_parameters ) 1612 retval = _verify_parameters( request.GET, mandatory_parameters )
1581 if retval: 1613 if retval:
1582 return _redirect_parameters( 'package_built_detail', request.GET, mandatory_parameters, build_id = build_id, package_id = package_id) 1614 return _redirect_parameters( 'package_built_detail', request.GET, mandatory_parameters, build_id = build_id, package_id = package_id)
@@ -1607,7 +1639,10 @@ def package_built_detail(request, build_id, package_id):
1607 } 1639 }
1608 if paths.all().count() < 2: 1640 if paths.all().count() < 2:
1609 context['disable_sort'] = True; 1641 context['disable_sort'] = True;
1610 return render(request, template, context) 1642
1643 response = render(request, template, context)
1644 _save_parameters_cookies(response, pagesize, orderby, request)
1645 return response
1611 1646
1612def package_built_dependencies(request, build_id, package_id): 1647def package_built_dependencies(request, build_id, package_id):
1613 template = "package_built_dependencies.html" 1648 template = "package_built_dependencies.html"
@@ -1632,9 +1667,9 @@ def package_included_detail(request, build_id, target_id, package_id):
1632 if Build.objects.filter(pk=build_id).count() == 0 : 1667 if Build.objects.filter(pk=build_id).count() == 0 :
1633 return redirect(builds) 1668 return redirect(builds)
1634 1669
1635
1636 # follow convention for pagination w/ search although not used for this view 1670 # follow convention for pagination w/ search although not used for this view
1637 mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'path:+'}; 1671 (pagesize, orderby) = _get_parameters_values(request, 25, 'path:+')
1672 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby }
1638 retval = _verify_parameters( request.GET, mandatory_parameters ) 1673 retval = _verify_parameters( request.GET, mandatory_parameters )
1639 if retval: 1674 if retval:
1640 return _redirect_parameters( 'package_included_detail', request.GET, mandatory_parameters, build_id = build_id, target_id = target_id, package_id = package_id) 1675 return _redirect_parameters( 'package_included_detail', request.GET, mandatory_parameters, build_id = build_id, target_id = target_id, package_id = package_id)
@@ -1669,8 +1704,10 @@ def package_included_detail(request, build_id, target_id, package_id):
1669 ] 1704 ]
1670 } 1705 }
1671 if paths.all().count() < 2: 1706 if paths.all().count() < 2:
1672 context['disable_sort'] = True; 1707 context['disable_sort'] = True
1673 return render(request, template, context) 1708 response = render(request, template, context)
1709 _save_parameters_cookies(response, pagesize, orderby, request)
1710 return response
1674 1711
1675def package_included_dependencies(request, build_id, target_id, package_id): 1712def package_included_dependencies(request, build_id, target_id, package_id):
1676 template = "package_included_dependencies.html" 1713 template = "package_included_dependencies.html"
@@ -1699,7 +1736,8 @@ def package_included_reverse_dependencies(request, build_id, target_id, package_
1699 if Build.objects.filter(pk=build_id).count() == 0 : 1736 if Build.objects.filter(pk=build_id).count() == 0 :
1700 return redirect(builds) 1737 return redirect(builds)
1701 1738
1702 mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'package__name:+'}; 1739 (pagesize, orderby) = _get_parameters_values(request, 25, 'package__name:+')
1740 mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby': orderby }
1703 retval = _verify_parameters( request.GET, mandatory_parameters ) 1741 retval = _verify_parameters( request.GET, mandatory_parameters )
1704 if retval: 1742 if retval:
1705 return _redirect_parameters( 'package_included_reverse_dependencies', request.GET, mandatory_parameters, build_id = build_id, target_id = target_id, package_id = package_id) 1743 return _redirect_parameters( 'package_included_reverse_dependencies', request.GET, mandatory_parameters, build_id = build_id, target_id = target_id, package_id = package_id)
@@ -1741,8 +1779,10 @@ def package_included_reverse_dependencies(request, build_id, target_id, package_
1741 ] 1779 ]
1742 } 1780 }
1743 if objects.all().count() < 2: 1781 if objects.all().count() < 2:
1744 context['disable_sort'] = True; 1782 context['disable_sort'] = True
1745 return render(request, template, context) 1783 response = render(request, template, context)
1784 _save_parameters_cookies(response, pagesize, orderby, request)
1785 return response
1746 1786
1747def image_information_dir(request, build_id, target_id, packagefile_id): 1787def image_information_dir(request, build_id, target_id, packagefile_id):
1748 # stubbed for now 1788 # stubbed for now