You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.3 KiB
142 lines
4.3 KiB
from datetime import datetime
|
|
from django.db import models
|
|
from django.utils import timezone
|
|
|
|
from users.models import User
|
|
from specializations.models import Specialization
|
|
|
|
|
|
class Realty(models.Model):
|
|
BUILDING_CLASSIFICATION_CHOICES = (
|
|
|
|
)
|
|
TYPE_CONSTRUCTION_CHOICES = (
|
|
|
|
)
|
|
name = models.CharField(max_length=255)
|
|
building_classification = models.CharField(max_length=50)
|
|
type_construction = models.CharField(max_length=50)
|
|
country = models.CharField(max_length=50)
|
|
city = models.CharField(max_length=50)
|
|
user = models.ForeignKey(User, related_name='realty')
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class Meta:
|
|
verbose_name = 'Объект'
|
|
verbose_name_plural = 'Объекты'
|
|
|
|
|
|
class Project(models.Model):
|
|
TYPE_WORK_CHOICES = (
|
|
('1', 'проектирование'),
|
|
('2', 'техническое сопровождение')
|
|
)
|
|
|
|
name = models.CharField(max_length=255)
|
|
price = models.DecimalField(max_digits=10, decimal_places=0)
|
|
specialization = models.ForeignKey(Specialization, related_name='projects')
|
|
text = models.TextField(blank=True)
|
|
user = models.ForeignKey(User, related_name='projects')
|
|
budget = models.CharField(max_length=20, blank=True)
|
|
cro = models.BooleanField(default=False)
|
|
type_work = models.CharField(max_length=20, choices=TYPE_WORK_CHOICES, default='1')
|
|
term_cost = models.BooleanField(default=False)
|
|
secure_transaction = models.BooleanField(default=False)
|
|
realty = models.ForeignKey(Realty, null=True, related_name='projects')
|
|
created = models.DateTimeField(default=timezone.now)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class Meta:
|
|
verbose_name = 'Проект'
|
|
verbose_name_plural = 'Проекты'
|
|
|
|
|
|
class Order(models.Model):
|
|
project = models.OneToOneField(Project, related_name='order')
|
|
contractor = models.ForeignKey(User)
|
|
cost = models.DecimalField(max_digits=10, decimal_places=0)
|
|
term = models.IntegerField(default=1)
|
|
created = models.DateTimeField(default=timezone.now, editable=False)
|
|
status = models.BooleanField(default=False)
|
|
|
|
def __str__(self):
|
|
return self.project.name
|
|
|
|
class Meta:
|
|
verbose_name = 'Заказ'
|
|
verbose_name_plural = 'Заказы'
|
|
|
|
|
|
class Answer(models.Model):
|
|
COST_TYPE_CHOICES = (
|
|
('rur', 'rur'),
|
|
('usd', 'usd'),
|
|
('eur', 'eur'),
|
|
)
|
|
|
|
TERM_TYPE_CHOICES = (
|
|
('hour', 'hour'),
|
|
('day', 'day'),
|
|
('month', 'month'),
|
|
)
|
|
|
|
cost = models.DecimalField(max_digits=10, decimal_places=0)
|
|
cost_type = models.CharField(max_length=5, choices=COST_TYPE_CHOICES, default='rur')
|
|
text = models.TextField()
|
|
term = models.IntegerField(default=0)
|
|
term_type = models.CharField(max_length=10, choices=TERM_TYPE_CHOICES, default='hour')
|
|
project = models.ForeignKey(Project, related_name='answers')
|
|
user = models.ForeignKey(User, related_name='answers')
|
|
created = models.DateTimeField(default=timezone.now)
|
|
|
|
def __str__(self):
|
|
return self.text
|
|
|
|
class Meta:
|
|
verbose_name = 'Ответ к проекту'
|
|
verbose_name_plural = 'Ответы к проектам'
|
|
ordering = ('-created',)
|
|
|
|
|
|
class Candidate(models.Model):
|
|
answer = models.ForeignKey(Answer, related_name='candidates')
|
|
project = models.ForeignKey(Project, related_name='candidates')
|
|
status = models.BooleanField(default=False)
|
|
|
|
def __str__(self):
|
|
return self.user.get_full_name()
|
|
|
|
class Meta:
|
|
verbose_name = 'Кандидат'
|
|
verbose_name_plural = 'Кандидаты'
|
|
|
|
class Portfolio(models.Model):
|
|
name = models.CharField(max_length=255)
|
|
description = models.TextField()
|
|
user = models.ForeignKey(User,related_name='portfolio')
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class Meta:
|
|
verbose_name = 'Портфолио'
|
|
verbose_name_plural = 'Портфолио'
|
|
|
|
|
|
class PortfolioPhoto(models.Model):
|
|
img = models.ImageField(upload_to='projects/portfolio')
|
|
portfolio = models.ForeignKey(Portfolio)
|
|
|
|
class Meta:
|
|
verbose_name = 'Фото портфолио'
|
|
verbose_name_plural = 'Фото портфолио'
|
|
|
|
# def __str__(self):
|
|
# return self.img
|
|
|
|
|
|
|
|
|