from django.db import models

VEHICLE_CHOICES = (
    ('OASISSB', 'OASIS Small Business'),
    ('OASIS', 'OASIS Unrestricted')
)

STATUS_CHOICES = (
    ('P', 'In Progress'),
    ('C', 'Completed'), 
    ('F', 'Cancelled') 
)


class Vendor(models.Model):

    name = models.CharField(max_length=128)
    duns = models.CharField(max_length=9, unique=True)
    duns_4 = models.CharField(max_length=13, unique=True)
    cage = models.CharField(max_length=15, null=True)
    sam_address = models.CharField(null=True, max_length=128)
    sam_citystate = models.CharField(null=True, max_length=128)
    cm_name = models.CharField(null=True, max_length=128)
    cm_email = models.CharField(null=True, max_length=128)
    cm_phone = models.CharField(null=True, max_length=128)
    pm_name = models.CharField(null=True, max_length=128)
    pm_email = models.CharField(null=True, max_length=128)
    pm_phone = models.CharField(null=True, max_length=128)
    pools = models.ManyToManyField('Pool', through='PoolPIID')
    setasides = models.ManyToManyField('SetAside', null=True, blank=True)
    sam_status = models.CharField(null=True, max_length=128)
    sam_activation_date = models.DateTimeField(null=True)
    sam_expiration_date = models.DateTimeField(null=True)
    sam_exclusion = models.NullBooleanField(null=True)
    sam_url = models.URLField(null=True)
    annual_revenue = models.BigIntegerField(null=True)
    number_of_employees = models.IntegerField(null=True)


    def __str__(self):
        return self.name


class Pool(models.Model):
    id = models.CharField(primary_key=True, max_length=128)
    name = models.CharField(max_length=128, default='Pool')
    number = models.CharField(max_length=128)
    vehicle = models.CharField(choices=VEHICLE_CHOICES, max_length=7)
    naics = models.ManyToManyField('Naics')
    threshold = models.CharField(null=True, max_length=128)

    def __str__(self):
        return "Pool {0} - {1}".format(self.number, self.get_vehicle_display())


class PoolPIID(models.Model):
    vendor = models.ForeignKey('Vendor')
    pool = models.ForeignKey('Pool')
    piid = models.CharField(max_length=128)

    def __str__(self):
        return "{0} - {1} - {2}".format(self.vendor.name, self.pool.id, self.piid)


class SetAside(models.Model):
    code = models.CharField(unique=True, max_length=128)
    short_name = models.CharField(max_length=128)
    abbreviation = models.CharField(max_length=10, null=True)
    far_order = models.IntegerField(null=True)

    def  __str__(self):
        return self.short_name


class Naics(models.Model):
    code = models.CharField(max_length=128)
    description = models.TextField()
    short_code = models.CharField(unique=True, max_length=25)

    def __str__(self):
        return "{0} - {1}".format(self.code, self.description)

class SamLoad(models.Model):
    sam_load = models.DateField()

[(17, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(128)'}), False, 'from django.db import models\n'), (18, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(9)', 'unique': '(True)'}), False, 'from django.db import models\n'), (19, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(13)', 'unique': '(True)'}), False, 'from django.db import models\n'), (20, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(15)', 'null': '(True)'}), False, 'from django.db import models\n'), (21, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (22, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (23, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (24, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (25, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (26, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (27, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (28, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (29, 'django.db.models.ManyToManyField', 'models.ManyToManyField', (['"""Pool"""'], {'through': '"""PoolPIID"""'}), False, 'from django.db import models\n'), (30, 'django.db.models.ManyToManyField', 'models.ManyToManyField', (['"""SetAside"""'], {'null': '(True)', 'blank': '(True)'}), False, 'from django.db import models\n'), (31, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (32, 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'null': '(True)'}), False, 'from django.db import models\n'), (33, 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'null': '(True)'}), False, 'from django.db import models\n'), (34, 'django.db.models.NullBooleanField', 'models.NullBooleanField', ([], {'null': '(True)'}), False, 'from django.db import models\n'), (35, 'django.db.models.URLField', 'models.URLField', ([], {'null': '(True)'}), False, 'from django.db import models\n'), (36, 'django.db.models.BigIntegerField', 'models.BigIntegerField', ([], {'null': '(True)'}), False, 'from django.db import models\n'), (37, 'django.db.models.IntegerField', 'models.IntegerField', ([], {'null': '(True)'}), False, 'from django.db import models\n'), (45, 'django.db.models.CharField', 'models.CharField', ([], {'primary_key': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (46, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(128)', 'default': '"""Pool"""'}), False, 'from django.db import models\n'), (47, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(128)'}), False, 'from django.db import models\n'), (48, 'django.db.models.CharField', 'models.CharField', ([], {'choices': 'VEHICLE_CHOICES', 'max_length': '(7)'}), False, 'from django.db import models\n'), (49, 'django.db.models.ManyToManyField', 'models.ManyToManyField', (['"""Naics"""'], {}), False, 'from django.db import models\n'), (50, 'django.db.models.CharField', 'models.CharField', ([], {'null': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (57, 'django.db.models.ForeignKey', 'models.ForeignKey', (['"""Vendor"""'], {}), False, 'from django.db import models\n'), (58, 'django.db.models.ForeignKey', 'models.ForeignKey', (['"""Pool"""'], {}), False, 'from django.db import models\n'), (59, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(128)'}), False, 'from django.db import models\n'), (66, 'django.db.models.CharField', 'models.CharField', ([], {'unique': '(True)', 'max_length': '(128)'}), False, 'from django.db import models\n'), (67, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(128)'}), False, 'from django.db import models\n'), (68, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(10)', 'null': '(True)'}), False, 'from django.db import models\n'), (69, 'django.db.models.IntegerField', 'models.IntegerField', ([], {'null': '(True)'}), False, 'from django.db import models\n'), (76, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(128)'}), False, 'from django.db import models\n'), (77, 'django.db.models.TextField', 'models.TextField', ([], {}), False, 'from django.db import models\n'), (78, 'django.db.models.CharField', 'models.CharField', ([], {'unique': '(True)', 'max_length': '(25)'}), False, 'from django.db import models\n'), (84, 'django.db.models.DateField', 'models.DateField', ([], {}), False, 'from django.db import models\n')]