aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-02-09 14:01:46 +0000
committerMichael Wood <michael.g.wood@intel.com>2015-02-09 15:59:10 +0000
commit01d6d6d7fbe39bbdc96c74bb6ee16824ac51ce21 (patch)
tree4dd9b390d05537e25f4dae0734116f8e948981a7
parentbc2a77e017550c25def80f448c067c657bb18bf1 (diff)
downloaderror-report-web-01d6d6d7fbe39bbdc96c74bb6ee16824ac51ce21.tar.gz
error-report-web-01d6d6d7fbe39bbdc96c74bb6ee16824ac51ce21.tar.bz2
error-report-web-01d6d6d7fbe39bbdc96c74bb6ee16824ac51ce21.zip
views: Use the get method on the request object
Simpler to use this than our own property fallback mechanism Signed-off-by: Michael Wood <michael.g.wood@intel.com>
-rw-r--r--Post/views.py29
1 files changed, 7 insertions, 22 deletions
diff --git a/Post/views.py b/Post/views.py
index b945f8a..a676af9 100644
--- a/Post/views.py
+++ b/Post/views.py
@@ -102,9 +102,6 @@ def search(request, mode=results_mode.LATEST, build_id=None):
# Default page limit
limit = 25
- # Default page
- page = 1
-
items = BuildFailure.objects.all()
if request.GET.has_key("limit"):
@@ -116,16 +113,13 @@ def search(request, mode=results_mode.LATEST, build_id=None):
# just use the Default page limit
pass
- request.session['limit'] = limit
+ request.session['limit'] = limit
- if request.session.has_key('limit'):
- limit = request.session['limit']
+ # Default page = 1
+ page = request.GET.get('page', 1)
- if request.GET.has_key("order_by"):
- order_by = request.GET['order_by']
- else:
- # Default order by
- order_by = '-BUILD__DATE'
+ # Default order_by -BUILD__DATE
+ order_by = request.GET.get("order_by", '-BUILD__DATE')
context = {
'results_mode' : results_mode,
@@ -217,17 +211,8 @@ def search(request, mode=results_mode.LATEST, build_id=None):
# a range instead and then feed that to the paginator.
elif mode == results_mode.LATEST and not request.GET.has_key('filter'):
total = items.count()
- total_from = total - int(limit)
- if request.GET.has_key('page'):
- # fetch a 2 extra pages around the current page
- try:
- page = int(request.GET['page'])
- except:
- # We pick up the Default page
- pass
-
- # Get an extra two pages worth to populate the paginator
- total_from = total - limit*(page+2)
+ # Get an extra two pages worth to populate the paginator
+ total_from = total - limit*(int(page)+2)
items = items.filter(id__range=(total_from,total))