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.
 
 
 
 
 
 

48 lines
2.1 KiB

from mptt.models import TreeForeignKey
from sorl.thumbnail import ImageField
from django.db import models
from django.utils import timezone
from users.models import User
from projects.models import BuildingClassfication, ConstructionType, TERMS, CURRENCIES
from specializations.models import Specialization
class WorkSell(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True)
img = ImageField(upload_to='worksell/worksell', null=True, blank=True)
budget = models.DecimalField(max_digits=10, decimal_places=0, default=0, null=True, blank=True)
currency = models.CharField(max_length=20, default='rur', choices=CURRENCIES, null=True, blank=True)
specialization = TreeForeignKey(Specialization, related_name='worksells', null=True, blank=True)
term = models.IntegerField(default=0, null=True, blank=True)
term_type = models.CharField(max_length=20, choices=TERMS, default='hour', null=True, blank=True)
contractor = models.ForeignKey(User, related_name='work_sell')
building_classification = models.ForeignKey(BuildingClassfication, related_name='worksells', null=True, blank=True)
construction_type = models.ForeignKey(ConstructionType, related_name='worksells', null=True, blank=True)
location = TreeForeignKey('common.Location', related_name='worksells', null=True, blank=True)
created = models.DateTimeField(default=timezone.now, null=True, blank=True)
def __str__(self):
return self.name
def is_author_for_work(self):
pass
class Meta:
ordering = ['-created']
verbose_name = 'Готовая работа'
verbose_name_plural = 'Готовые работы'
class WorkSellPhoto(models.Model):
img = ImageField(upload_to='worksell/worksell')
worksell = models.ForeignKey(WorkSell, related_name='photos')
def __str__(self):
return self.worksell.name
class Meta:
verbose_name = 'Изображение Готовая работа'
verbose_name_plural = 'Изображения Готовые работы'