43 lines
1.4 KiB
Python
Executable file
43 lines
1.4 KiB
Python
Executable file
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
from datetime import datetime
|
|
|
|
GROUP_CHOICES = (
|
|
('forming', 'Forming'),
|
|
('negotiating', 'Negotiating'),
|
|
('confirming', 'Confirming'),
|
|
('closed', 'Closed')
|
|
)
|
|
|
|
class ProductGroup(models.Model):
|
|
url = models.URLField()
|
|
thumbnail_url = models.URLField()
|
|
fullimage_url = models.URLField()
|
|
bing_title = models.CharField(max_length=255)
|
|
created_by = models.ForeignKey(User, related_name='created_group')
|
|
name = models.CharField(max_length=255)
|
|
description = models.TextField(blank=True)
|
|
state = models.CharField(choices=GROUP_CHOICES, max_length=255)
|
|
created_time = models.DateTimeField(default=datetime.now)
|
|
end_time = models.DateTimeField()
|
|
negotiation_end_time = models.DateTimeField()
|
|
confirmation_end_time = models.DateTimeField()
|
|
is_locked = models.BooleanField(default=False)
|
|
users = models.ManyToManyField(User, blank=True, through='UserGroup')
|
|
|
|
def __unicode__(self):
|
|
return self.name
|
|
|
|
TIMELINE_CHOICES = (
|
|
('now', 'now'),
|
|
('10days', '10 days'),
|
|
('1month', '1 month')
|
|
)
|
|
|
|
class UserGroup(models.Model):
|
|
user = models.ForeignKey(User)
|
|
product = models.ForeignKey(ProductGroup)
|
|
is_confirmed = models.BooleanField(default=False)
|
|
timeline_of_purchase = models.CharField(choices=TIMELINE_CHOICES, max_length=64)
|
|
|
|
# Create your models here.
|