is_empty field

This commit is contained in:
Sanj 2012-05-26 02:13:04 +05:30
commit f53db828af
5 changed files with 24 additions and 8 deletions

View File

@ -54,9 +54,7 @@ def toHtml():
def isShip(row): def isShip(row):
try: try:
# if str(int(row[0])) == row[0]: if row[0].isdigit() or row[0].strip().lower() == 'import' or row[0].strip().lower() == 'rexport':
# return True
if row[0].strip().lower() == 'import' or row[0].strip().lower() == 'rexport':
return True return True
else: else:
return False return False
@ -101,6 +99,9 @@ def csvToJSON(prefix):
break break
currRow = rows[i] currRow = rows[i]
ships.append(thisShip) ships.append(thisShip)
else:
print c
print thisRow
data['ships'] = ships data['ships'] = ships
d.append(data) d.append(data)
outFile = prefix + "Data.json" outFile = prefix + "Data.json"

View File

@ -0,0 +1,12 @@
from models import *
from django.shortcuts import render_to_response
from django.http import HttpResponse
def uniqueShips(request):
ships = Ship.objects.values('ship_name', 'ship_name_trans').distinct('ship_name')
return render_to_response("uniqueShips.html", {'ships': ships, 'count': ships.count()})
def uniquePorts(request):
ports = Ship.objects.order_by('port').values('port').distinct()
return render_to_response("uniquePorts.html", {'ports': ports, 'count': ports.count()})

View File

@ -1,4 +1,5 @@
# Create your views here. # Create your views here.
import math
from models import * from models import *
from django.http import HttpResponse from django.http import HttpResponse
from ships import models from ships import models
@ -197,17 +198,17 @@ def shipList(request):
if billType != '': if billType != '':
qset = qset.filter(bill_type__iexact=billType) qset = qset.filter(bill_type__iexact=billType)
if shipName != '': if shipName != '':
qset = qset.filter(ship_name_trans__icontains=shipName) qset = qset.filter(Q(ship_name_trans__icontains=shipName) | Q(ship_name__icontains=shipName))
if captain != '': if captain != '':
qset = qset.filter(captain_trans__icontains=captain) qset = qset.filter(Q(captain_trans__icontains=captain) | Q(captain__icontains=captain))
if flag != '': if flag != '':
qset = qset.filter(flag__iexact=flag) qset = qset.filter(flag__iexact=flag)
if owner != '': if owner != '':
qset = qset.filter(owner_trans__icontains=owner) qset = qset.filter(Q(captain_trans__icontains=captain) | Q(captain__icontains=captain))
if port != '': if port != '':
qset = qset.filter(port__icontains=port) qset = qset.filter(port__icontains=port)
if goods != '': if goods != '':
qset = qset.filter(good__description_string_trans__icontains=goods).distinct() qset = qset.filter(Q(good__description_string_trans__icontains=goods) | Q(good__description_string__icontains=goods) | Q(good__description__icontains=goods)).distinct()
if is_empty != False: if is_empty != False:
qset = qset.annotate(num_goods=Count('good')).filter(num_goods=0) qset = qset.annotate(num_goods=Count('good')).filter(num_goods=0)

View File

@ -17,6 +17,8 @@ urlpatterns = patterns('',
(r'^$', 'ships.views.shipList'), (r'^$', 'ships.views.shipList'),
(r'^uniqueShips', 'ships.queryviews.uniqueShips'),
(r'^uniquePorts', 'ships.queryviews.uniquePorts'),
# for human translators # for human translators
(r'^trans/(?P<model>[A-Za-z].*?)/(?P<field>[A-Za-z].*?)/(?P<page_no>\d*)/', 'ships.views.translate'), (r'^trans/(?P<model>[A-Za-z].*?)/(?P<field>[A-Za-z].*?)/(?P<page_no>\d*)/', 'ships.views.translate'),
(r'^dotrans/(?P<model>[A-Za-z].*?)/(?P<field>[A-Za-z].*?)/', 'ships.views.dotranslate'), (r'^dotrans/(?P<model>[A-Za-z].*?)/(?P<field>[A-Za-z].*?)/', 'ships.views.dotranslate'),

View File

@ -15,7 +15,7 @@ sys.path.append(root_dir)
sys.path.append(os.path.join(root_dir, project_module)) sys.path.append(os.path.join(root_dir, project_module))
#reload if this django.wsgi gets touched #reload if this django.wsgi gets touched
from oxdjango import monitor from ox.django import monitor
monitor.start(interval=1.0) monitor.start(interval=1.0)
monitor.track(os.path.abspath(os.path.dirname(__file__))) monitor.track(os.path.abspath(os.path.dirname(__file__)))