import datetime from django.db import models from django.utils import timezone from resume.models import PubItem, Publisher class Gig(models.Model): title = models.CharField(max_length=200) pitch = models.TextField(null=True, blank=True) created = models.DateTimeField(default=timezone.now) pub_date = models.DateTimeField(blank=True, null=True) due_date = models.DateField(blank=True, null=True) STATUS = ( (0, "Pitched"), (1, "Accepted"), (2, "Submitted"), (3, "Published"), (4, "Rejected"), (5, "TO PITCH"), ) status = models.IntegerField(choices=STATUS, default=1) invoice_date = models.DateTimeField(null=True, blank=True) payment = models.DecimalField(max_digits=10, decimal_places=2) PAY_STATUS = ( (0, "NOT SUBMITTED"), (1, "Invoiced"), (2, "Paid"), ) payment_status = models.IntegerField(choices=PAY_STATUS, default=1) PAY_TYPE = ( (0, "Flat Rate"), (1, "Per Word"), (2, "Hourly"), ) pay_type = models.IntegerField(choices=PAY_TYPE, default=1) word_count = models.DecimalField(max_digits=7, decimal_places=0, blank=True, null=True) publisher = models.ForeignKey(Publisher, blank=True, null=True) pub_item = models.ForeignKey(PubItem, blank=True, null=True) def __str__(self): return self.title def get_pay_date(self): days = self.publisher.payment_time * 7 if self.invoice_date: return self.invoice_date + datetime.timedelta(float(days))