diff options
| author | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-10-19 22:10:20 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-10-19 22:10:20 +0200 | 
| commit | 029d08540f66524c371ae87ede5c1281fbe2c568 (patch) | |
| tree | 3fa5ef50970a84f5499b6a2ad8629ab3623ef2b5 /archaeological_warehouse/models.py | |
| parent | c3a22e06e4a1d50e90854194e786effc7d49f3e6 (diff) | |
| download | Ishtar-029d08540f66524c371ae87ede5c1281fbe2c568.tar.bz2 Ishtar-029d08540f66524c371ae87ede5c1281fbe2c568.zip  | |
Djangoization - Major refactoring (step 2) models reorganization in django apps
Diffstat (limited to 'archaeological_warehouse/models.py')
| -rw-r--r-- | archaeological_warehouse/models.py | 82 | 
1 files changed, 82 insertions, 0 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py new file mode 100644 index 000000000..fe381e521 --- /dev/null +++ b/archaeological_warehouse/models.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2012 Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program.  If not, see <http://www.gnu.org/licenses/>. + +# See the file COPYING for details. + +from django.conf import settings +from django.contrib.gis.db import models +from django.utils.translation import ugettext_lazy as _, ugettext + +from ishtar_common.models import GeneralType, BaseHistorizedItem, \ +                          LightHistorizedItem, OwnPerms, Address, Person + + +class WarehouseType(GeneralType): +    class Meta: +        verbose_name = _(u"Warehouse type") +        verbose_name_plural = _(u"Warehouse types") + +class Warehouse(Address, OwnPerms): +    name = models.CharField(_(u"Name"), max_length=40) +    warehouse_type = models.ForeignKey(WarehouseType, +                                       verbose_name=_(u"Warehouse type")) +    person_in_charge = models.ForeignKey(Person, +                     verbose_name=_(u"Person in charge"), null=True, blank=True) +    comment = models.TextField(_(u"Comment"), null=True, blank=True) + +    class Meta: +        verbose_name = _(u"Warehouse") +        verbose_name_plural = _(u"Warehouses") +        permissions = ( +            ("view_own_warehouse", ugettext(u"Can view own Warehouse")), +            ("add_own_warehouse", ugettext(u"Can add own Warehouse")), +            ("change_own_warehouse", ugettext(u"Can change own Warehouse")), +            ("delete_own_warehouse", ugettext(u"Can delete own Warehouse")), +        ) + +    def __unicode__(self): +        return u"%s (%s)" % (self.name, unicode(self.warehouse_type)) + + +class ContainerType(GeneralType): +    length = models.IntegerField(_(u"Length (mm)"), blank=True, null=True) +    width = models.IntegerField(_(u"Width (mm)"), blank=True, null=True) +    height = models.IntegerField(_(u"Height (mm)"), blank=True, null=True) +    volume = models.IntegerField(_(u"Volume (l)"), blank=True, null=True) +    reference = models.CharField(_(u"Reference"), max_length=30) + +    class Meta: +        verbose_name = _(u"Container type") +        verbose_name_plural = _(u"Container types") + +class Container(LightHistorizedItem): +    TABLE_COLS = ['reference', 'container_type', 'location',] +    location = models.ForeignKey(Warehouse, verbose_name=_(u"Warehouse")) +    container_type = models.ForeignKey(ContainerType, +                                       verbose_name=_("Container type")) +    reference = models.CharField(_(u"Reference"), max_length=40) +    comment = models.TextField(_(u"Comment")) + +    class Meta: +        verbose_name = _(u"Container") +        verbose_name_plural = _(u"Containers") + +    def __unicode__(self): +        lbl = u" - ".join((self.reference, unicode(self.container_type), +                           unicode(self.location))) +        return lbl +  | 
