some admin tweaks
This commit is contained in:
parent
30620bc121
commit
533ffc79df
|
@ -10,6 +10,8 @@ class GoodInline(admin.TabularInline):
|
||||||
|
|
||||||
class ShipAdmin(admin.ModelAdmin):
|
class ShipAdmin(admin.ModelAdmin):
|
||||||
inlines = [GoodInline]
|
inlines = [GoodInline]
|
||||||
|
list_filter = ('bill_type', 'manifest_file',)
|
||||||
|
list_display = ('__unicode__', 'bill_type', 'number', 'date', 'flag', 'captain', 'owner', 'port', 'country', 'no_of_goods',)
|
||||||
|
|
||||||
class GoodAdmin(admin.ModelAdmin):
|
class GoodAdmin(admin.ModelAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -8,10 +8,16 @@ class Manifest(models.Model):
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.filename
|
return self.filename
|
||||||
|
|
||||||
|
TYPE_CHOICES = (
|
||||||
|
('Import', 'Import'),
|
||||||
|
('Export', 'Export'),
|
||||||
|
('Rexport', 'Rexport'),
|
||||||
|
)
|
||||||
|
|
||||||
#['type', 'number', 'date', 'ship_name', 'captain', 'flag', 'trader', 'port', 'country']
|
#['type', 'number', 'date', 'ship_name', 'captain', 'flag', 'trader', 'port', 'country']
|
||||||
class Ship(models.Model):
|
class Ship(models.Model):
|
||||||
manifest_file = models.ForeignKey(Manifest)
|
manifest_file = models.ForeignKey(Manifest)
|
||||||
bill_type = models.CharField(max_length=50)
|
bill_type = models.CharField(max_length=50, choices=TYPE_CHOICES)
|
||||||
number = models.IntegerField(max_length=20)
|
number = models.IntegerField(max_length=20)
|
||||||
date = models.DateField()
|
date = models.DateField()
|
||||||
ship_name = models.CharField(max_length=255)
|
ship_name = models.CharField(max_length=255)
|
||||||
|
@ -24,6 +30,12 @@ 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,)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ['number']
|
||||||
|
|
||||||
|
def no_of_goods(self):
|
||||||
|
return Good.objects.filter(ship=self).count()
|
||||||
|
|
||||||
#['description', 'package_type', 'no_of_packages', 'weight', 'value']
|
#['description', 'package_type', 'no_of_packages', 'weight', 'value']
|
||||||
class Good(models.Model):
|
class Good(models.Model):
|
||||||
ship = models.ForeignKey(Ship)
|
ship = models.ForeignKey(Ship)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user