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):
try:
# if str(int(row[0])) == row[0]:
# return True
if row[0].strip().lower() == 'import' or row[0].strip().lower() == 'rexport':
if row[0].isdigit() or row[0].strip().lower() == 'import' or row[0].strip().lower() == 'rexport':
return True
else:
return False
@ -101,6 +99,9 @@ def csvToJSON(prefix):
break
currRow = rows[i]
ships.append(thisShip)
else:
print c
print thisRow
data['ships'] = ships
d.append(data)
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.
import math
from models import *
from django.http import HttpResponse
from ships import models
@ -197,17 +198,17 @@ def shipList(request):
if billType != '':
qset = qset.filter(bill_type__iexact=billType)
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 != '':
qset = qset.filter(captain_trans__icontains=captain)
qset = qset.filter(Q(captain_trans__icontains=captain) | Q(captain__icontains=captain))
if flag != '':
qset = qset.filter(flag__iexact=flag)
if owner != '':
qset = qset.filter(owner_trans__icontains=owner)
qset = qset.filter(Q(captain_trans__icontains=captain) | Q(captain__icontains=captain))
if port != '':
qset = qset.filter(port__icontains=port)
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:
qset = qset.annotate(num_goods=Count('good')).filter(num_goods=0)

View File

@ -17,6 +17,8 @@ urlpatterns = patterns('',
(r'^$', 'ships.views.shipList'),
(r'^uniqueShips', 'ships.queryviews.uniqueShips'),
(r'^uniquePorts', 'ships.queryviews.uniquePorts'),
# for human translators
(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'),

View File

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