91 lines
2.7 KiB
Python
91 lines
2.7 KiB
Python
|
from django.db import models
|
||
|
from django.utils.translation import gettext_lazy as _
|
||
|
from django.urls import reverse
|
||
|
from users.models import Base_User
|
||
|
import users
|
||
|
|
||
|
|
||
|
class Offer_Category(models.Model):
|
||
|
id = models.AutoField(primary_key= True)
|
||
|
name = models.CharField(max_length=50,null = False, blank = False,)
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name = 'Category'
|
||
|
verbose_name_plural = 'Categories'
|
||
|
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.name
|
||
|
STATUS = (
|
||
|
('Active',_('Active offer')),
|
||
|
('Inactive',_('Inactive offer')),
|
||
|
('Verification',_('Waiting for verication')),
|
||
|
('Blocked',_('Blocked Offer')),
|
||
|
)
|
||
|
|
||
|
DMC_Value = (
|
||
|
('B',_('Do 3.5 tony.')),
|
||
|
('C',_('Między 3.5 a 7.5 tony')),
|
||
|
('C1',_('Powyzej 7.5 tony')),
|
||
|
)
|
||
|
|
||
|
COOKER_Option = (
|
||
|
('Elecric',_('Kuchenka elektryczna')),
|
||
|
('Gas',_('Kuchenka gazowa')),
|
||
|
('None',_('Brak')),
|
||
|
)
|
||
|
|
||
|
GEARBOX_Option = (
|
||
|
('Manual',_('Skrzynia manualna')),
|
||
|
('Automat',_('Skrzynia automatyczna')),
|
||
|
)
|
||
|
class Offer(models.Model):
|
||
|
id = models.AutoField(primary_key= True)
|
||
|
created_by = models.ForeignKey('users.Base_User', on_delete=models.CASCADE)
|
||
|
title = models.CharField(_("Title"), max_length=50,default='Tytuł oferty')
|
||
|
category = models.ForeignKey(Offer_Category,null = False, blank = False, default= None,on_delete= models.CASCADE)
|
||
|
price = models.DecimalField(max_digits=10, decimal_places=2)
|
||
|
date_added = models.DateTimeField(auto_now_add=True)
|
||
|
status = models.CharField(max_length=32, choices=STATUS, default='Inactive')
|
||
|
DMC = models.CharField(max_length=32, choices=DMC_Value, default='B')
|
||
|
Places_to_sleep = models.IntegerField(default=2)
|
||
|
|
||
|
cooker = models.CharField(max_length = 32, choices=COOKER_Option, default='None')
|
||
|
fridge = models.BooleanField(default=False)
|
||
|
microwave = models.BooleanField(default= False)
|
||
|
Webasto = models.BooleanField(default=False)
|
||
|
auto_temp_control = models.BooleanField(default= False)
|
||
|
water_level_indicator = models.BooleanField(default=False)
|
||
|
battery_level = models.BooleanField(default=False)
|
||
|
photovoltaic_panels = models.BooleanField(default=False)
|
||
|
|
||
|
gearbox = models.CharField(max_length=32, choices=GEARBOX_Option,default='Manual')
|
||
|
tempomat = models.BooleanField(default=False)
|
||
|
|
||
|
class Meta:
|
||
|
pass
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.title
|
||
|
|
||
|
class Image_offer(models.Model):
|
||
|
offer = models.ForeignKey("Offer", verbose_name="", on_delete = models.CASCADE, default=None)
|
||
|
name = models.CharField(max_length=255)
|
||
|
image = models.ImageField(upload_to='images/')
|
||
|
main_image = models.BooleanField(default= False)
|
||
|
|
||
|
|
||
|
|
||
|
class Offer_Stats(models.Model):
|
||
|
offer = models.ForeignKey('Offer',on_delete=models.CASCADE, default=None)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|