class ArchiveModel(models.Model): objects = Manager() uuid = fields.UUIDField(auto=True) owner = fields.UUIDField() created = models.DateTimeField(auto_now_add=True) def natural_key(self): return self.uuid class Meta: abstract = True
class JumpLog(base.ArchiveModel): archive = True location = fields.UUIDField(blank=True, null=True) number = models.IntegerField(blank=True, null=True) location_name = models.CharField(max_length=64, blank=True, null=True) aircraft_type = models.CharField(max_length=32, blank=True, null=True) date = models.DateField() jump_type = models.CharField(max_length=32, blank=True, null=True) altitude = models.CharField(max_length=32, blank=True, null=True) note = models.CharField(max_length=100, blank=True, null=True) def save(self, *args, **kwargs): if not self.number: max_number = JumpLog.objects.filter(owner=self.owner).aggregate( Max('number'))['number__max'] if max_number is None: try: person = models.get_model( settings.DATA_APP, 'Person').objects.get_by_natural_key(self.owner) past_jumps = person.past_jumps except: past_jumps = 0 self.number = past_jumps + 1 else: self.number = max_number + 1 super(JumpLog, self).save(*args, **kwargs)
class LoadLog(base.ArchiveModel): archive = True location = fields.UUIDField() aircraft = fields.UUIDField() pilot = fields.UUIDField() aircraft_reg = models.CharField(max_length=16) pilot_name = models.CharField(max_length=64) date = models.DateField() number = models.SmallIntegerField() total_slots = models.SmallIntegerField() prepaid_slots = models.SmallIntegerField() postpaid_slots = models.SmallIntegerField() unpaid_slots = models.SmallIntegerField() staff_slots = models.SmallIntegerField() prices = models.CharField(max_length=512) note = models.CharField(max_length=200, blank=True, null=True)
class AnonymousModel(models.Model): objects = Manager() uuid = fields.UUIDField(auto=True) def natural_key(self): return self.uuid class Meta: abstract = True
class AccountOperationLog(base.ArchiveModel): archive = True location = fields.UUIDField() date = models.DateField() type = models.CharField(max_length=1, choices=ACCOUNT_OPERATIONS) amount = models.CharField(max_length=64) currency = models.CharField(max_length=5) note = models.CharField(max_length=100)
class Model(models.Model): objects = Manager() uuid = fields.UUIDField(auto=True) owner = models.ForeignKey(contrib.auth.models.User) deleted = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) def natural_key(self): return self.uuid class Meta: abstract = True
class SlotLog(base.ArchiveModel): archive = True load = models.ForeignKey('LoadLog') jumper = fields.UUIDField(blank=True, null=True) jumper_name = models.CharField(max_length=64) is_worker = models.BooleanField(default=False) catalog_item = models.CharField(max_length=64) exit_order = models.SmallIntegerField() catalog_price = models.CharField(max_length=64, blank=True, null=True) payer = models.CharField(max_length=64, blank=True, null=True) payment = models.CharField(max_length=64) payment_type = models.CharField(max_length=16)
class Slot(base.Model): show_created = True relations = 'Person Phantom' related_fields = '+all -is_paid -payer -price' related_relations = 'Person Phantom' load = models.ForeignKey('Load') person = models.ForeignKey('Person', blank=True, null=True) membership_uuid = fields.UUIDField(blank=True, null=True) phantom = models.ForeignKey('Phantom', blank=True, null=True) worker = models.ForeignKey('Worker', blank=True, null=True) item = models.ForeignKey('LocationCatalogItem', blank=True, null=True) element = models.ForeignKey('LocationCatalogElement', blank=True, null=True) price = models.ForeignKey('LocationCatalogPrice', blank=True, null=True) payer = models.ForeignKey('Person', blank=True, null=True, related_name='+') jump_type = models.ForeignKey('JumpType', blank=True, null=True) exit_order = models.SmallIntegerField(blank=True, null=True) related_slot = models.ForeignKey('Slot', blank=True, null=True) worker_type = models.ForeignKey('WorkerType', blank=True, null=True) is_paid = models.BooleanField(default=True) is_ready = models.BooleanField(default=True) problematic = models.BooleanField(default=False) problem = models.CharField(max_length=100, blank=True, null=True) class Meta: ordering = ['exit_order']
class GlobalSearch(base.AnonymousModel): show_all = True search_text = models.TextField() item_model = models.CharField(max_length=64) item_uuid = fields.UUIDField()