table
This commit is contained in:
parent
8078cee13f
commit
dad1e8274d
|
@ -39,6 +39,27 @@ class Ship(models.Model):
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return "%d: %s" % (self.number, self.ship_name,)
|
return "%d: %s" % (self.number, self.ship_name,)
|
||||||
|
|
||||||
|
def get_ship_name(self):
|
||||||
|
if self.ship_name_trans is not None:
|
||||||
|
return self.ship_name_trans
|
||||||
|
else:
|
||||||
|
return self.ship_name
|
||||||
|
|
||||||
|
|
||||||
|
def get_captain(self):
|
||||||
|
if self.captain_trans is not None:
|
||||||
|
return self.captain_trans
|
||||||
|
else:
|
||||||
|
return self.captain
|
||||||
|
|
||||||
|
|
||||||
|
def get_owner(self):
|
||||||
|
if self.owner_trans is not None:
|
||||||
|
return self.owner_trans
|
||||||
|
else:
|
||||||
|
return self.owner
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def total_weight(self):
|
def total_weight(self):
|
||||||
return self.good_set.all().aggregate(Sum('weight'))['weight__sum']
|
return self.good_set.all().aggregate(Sum('weight'))['weight__sum']
|
||||||
|
|
|
@ -196,8 +196,14 @@ def shipList(request):
|
||||||
# qset = qset.filter(country__icontains=country)
|
# qset = qset.filter(country__icontains=country)
|
||||||
paginator = Paginator(qset, page_size)
|
paginator = Paginator(qset, page_size)
|
||||||
results = paginator.page(page)
|
results = paginator.page(page)
|
||||||
|
no_of_results = qset.count()
|
||||||
return render_to_response("shipList.html", {'ships': results.object_list})
|
return render_to_response("shipList.html", {
|
||||||
|
'ships': results.object_list,
|
||||||
|
'no_of_pages': paginator.num_pages,
|
||||||
|
'page': page,
|
||||||
|
'page_size': page_size,
|
||||||
|
'no_of_results': no_of_results
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@ $(function() {
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
|
<div id="status">
|
||||||
|
No of results: {{ no_of_results }} displaying page {{ page }} of {{ no_of_pages }} Results per page: {{ page_size }}
|
||||||
|
</div>
|
||||||
<div id="leftCol">
|
<div id="leftCol">
|
||||||
<form id="shipFilterForm" action="" method="GET">
|
<form id="shipFilterForm" action="" method="GET">
|
||||||
Form goes here
|
Form goes here
|
||||||
|
@ -28,19 +31,30 @@ $(function() {
|
||||||
</div>
|
</div>
|
||||||
<div id="rightCol">
|
<div id="rightCol">
|
||||||
<table>
|
<table>
|
||||||
|
<thead>
|
||||||
|
<td>Ship Number</td>
|
||||||
|
<td>Bill Type</td>
|
||||||
|
<td>Date</td>
|
||||||
|
<td>Ship Name</td>
|
||||||
|
<td>Captain</td>
|
||||||
|
<td>Owner</td>
|
||||||
|
<td>Port</td>
|
||||||
|
<td>Country</td>
|
||||||
|
</thead>
|
||||||
{% for s in ships %}
|
{% for s in ships %}
|
||||||
<tr class="shipRow">
|
<tr class="shipRow">
|
||||||
<td>{{ s.number }}</td>
|
<td>{{ s.number }}</td>
|
||||||
|
<td>{{ s.bill_type }}</td>
|
||||||
<td>{{ s.date|date:"d, M, Y" }}</td>
|
<td>{{ s.date|date:"d, M, Y" }}</td>
|
||||||
<td>{{ s.ship_name_trans }}</td>
|
<td>{{ s.get_ship_name }}</td>
|
||||||
<td>{{ s.captain_trans }}</td>
|
<td>{{ s.get_captain }}</td>
|
||||||
<td>{{ s.owner_trans }}</td>
|
<td>{{ s.get_owner }}</td>
|
||||||
<td>{{ s.port }}</td>
|
<td>{{ s.port }}</td>
|
||||||
<td>{{ s.country }}</td>
|
<td>{{ s.country|default:"" }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="goodRow">
|
<tr class="goodRow">
|
||||||
<td></td>
|
<td></td>
|
||||||
<td colspan="6">
|
<td colspan="7">
|
||||||
<table class="goodTable">
|
<table class="goodTable">
|
||||||
{% for good in s.good_set.all %}
|
{% for good in s.good_set.all %}
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user