From c43d1053bf5be8d434eb133c30de5954080b0d4d Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 22 Apr 2012 16:37:35 +0530 Subject: [PATCH] form handling --- manifests/ships/views.py | 34 +++++++++++++++---------------- manifests/templates/shipList.html | 1 + 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/manifests/ships/views.py b/manifests/ships/views.py index 48fd54a..afa0e51 100644 --- a/manifests/ships/views.py +++ b/manifests/ships/views.py @@ -169,31 +169,31 @@ def stringtranslate(request): def shipList(request): page = request.GET.get('page', 1) page_size = request.GET.get('page_size', 50) - startDate = request.GET.get('start_date', None) - endDate = request.GET.get('end_date', None) - billType = request.GET.get('bill_type', None) - shipName = request.GET.get('ship_name', None) - captain = request.GET.get('captain', None) - flag = request.GET.get('flag', None) - owner = request.GET.get('owner', None) - port = request.GET.get('port', None) - goods = request.GET.get('goods', None) + startDate = request.GET.get('start_date', '') + endDate = request.GET.get('end_date', '') + billType = request.GET.get('bill_type', '') + shipName = request.GET.get('ship_name', '') + captain = request.GET.get('captain', '') + flag = request.GET.get('flag', '') + owner = request.GET.get('owner', '') + port = request.GET.get('port', '') + goods = request.GET.get('goods', '') # country = request.GET.get('country', None) qset = Ship.objects.all() #add dates stuff - if billType: - qset = qset.filter(billType__iexact=billType) - if shipName: + if billType != '': + qset = qset.filter(bill_type__iexact=billType) + if shipName != '': qset = qset.filter(ship_name_trans__icontains=shipName) - if captain: + if captain != '': qset = qset.filter(captain_trans__icontains=captain) - if flag: + if flag != '': qset = qset.filter(flag__iexact=flag) - if owner: + if owner != '': qset = qset.filter(owner_trans__icontains=owner) - if port: + if port != '': qset = qset.filter(port__icontains=port) - if goods: + if goods != '': qset = qset.filter(good__description_string_trans__icontains=goods).distinct() # if country: # qset = qset.filter(country__icontains=country) diff --git a/manifests/templates/shipList.html b/manifests/templates/shipList.html index f17e5d1..552b2f7 100644 --- a/manifests/templates/shipList.html +++ b/manifests/templates/shipList.html @@ -33,6 +33,7 @@ No of results: {{ no_of_results }}   displaying page {{ page }} of {{ no_of -->