Last active
July 25, 2019 18:28
-
-
Save wildlux/d777223c60d06f3d83203679984af571 to your computer and use it in GitHub Desktop.
Models for real estate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
import datetime | |
''' | |
FOTO=models.ImageField(upload_to='cartella_foto /' , blank=False, null=False) | |
nome=models.CharField( max_length=50) | |
cognome=models.CharField( max_length=50) | |
Telefono=models.CharField( max_length=15 ) | |
Campo_si_no=models.BooleanField(default='False') | |
anni=models.IntegerField(default=0) | |
SQM = models.FloatField(max_digits=10, decimal_places=3) | |
DATA_COSTRUZIONE = models.DateField( auto_now=False blank=False, null=False ) | |
Note= models.TextField() | |
relazione_1_N=models.ForeignKey(user) # uno a molti | |
relazione_1_a_1 = models.OneToOneField(Entry, on_delete=models.PROTECT) | |
relazione_N_a_N = models.ManyToManyField(Author)''' | |
class BATHROOM( models.Model ): | |
WC = models.BooleanField(default='True') | |
DOCCIA = models.BooleanField(default='False') | |
VASCA = models.BooleanField(default='False') | |
BIDET = models.BooleanField(default='False') | |
LAVAMANI = models.BooleanField(default='True') | |
def __str__(self): | |
BAGNO_1= str(self.WC) + " " + str(self.DOCCIA) + " " + str(self.VASCA) | |
BAGNO_2= " "+ str(self.BIDET)+" "+ str(self.LAVAMANI) | |
return BAGNO_1+BAGNO_2 | |
class Meta: | |
verbose_name = "Bagno" | |
verbose_name_plural = "Bagni" | |
class Media_homes(): # models.Model ): | |
CF='cartella_foto/' # CARTELLA FOTO | |
#FOTO1=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO2=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO3=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO4=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO5=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO6=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO7=models.ImageField(upload_to=CF , blank=False, null=False) | |
link= models.TextField() | |
#FOTO_360_1=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO_360_2=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO_360_3=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO_360_4=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO_360_5=models.ImageField(upload_to=CF , blank=False, null=False) | |
#FOTO_360_6=models.ImageField(upload_to=CF , blank=False, null=False) | |
P="Documenti casa del proprietario" | |
def __str__(self): | |
pass #return self.FOTO1 | |
class Meta: | |
verbose_name = "ZZZ MEDIA Case" | |
verbose_name_plural = "ZZZ MEDIA Casa" | |
class CITY( models.Model ): | |
Nome_CITY=models.CharField( max_length=13 ) | |
def __str__(self): | |
return self.Nome_CITY | |
def __str__(self): | |
return self.nome | |
class Meta: | |
verbose_name = "Città" | |
verbose_name_plural = "Città" | |
class TIPOLOGIA( models.Model ): | |
#iD_tipologia_casa (int) | |
TIPO_CASA=models.CharField( max_length=25 ) | |
def __str__(self): | |
return self.TIPO_CASA | |
class Meta: | |
verbose_name = "Tipologia casa" | |
verbose_name_plural = "tipologie case" | |
class Service_Home( models.Model ): | |
PROP="Proprietario immobile" | |
SQM = models.FloatField(verbose_name=" Superficie metri Quadri ") | |
PIANO = models.IntegerField(default=0 , verbose_name="Piano dell'immobile") | |
KITCHEN = models.BooleanField(default='False', verbose_name="Cucina") | |
DINNING = models.BooleanField(default='False', verbose_name="Stanza Dinning") | |
LIVING = models.BooleanField(default='False', verbose_name="Stanza Living") | |
STUDING = models.BooleanField(default='False', verbose_name="Stanza studio") | |
ROOM = models.IntegerField(default='False',verbose_name="Stanze") | |
ENSUITE = models.BooleanField(default='False',verbose_name="Ensuite") | |
POOL= models.BooleanField(default='False', verbose_name="Piscina ") | |
WIFI = models.BooleanField(default='False', verbose_name="Wireless internet") | |
PET = models.BooleanField(default='False' ,verbose_name="PET Frendly ") | |
LIFT = models.BooleanField(default='False',verbose_name="Lift") | |
TERRAZZO = models.BooleanField(default='False', verbose_name="terrazzo") | |
BALCONE = models.BooleanField(default='False', verbose_name="Balcone") | |
GIARDINO= models.BooleanField(default='False',verbose_name="Garden") | |
CORTILE = models.BooleanField(default='False', verbose_name="Cortile") | |
SEAVIEW = models.BooleanField(default='False', verbose_name="Vista Mare") | |
GARAGE = models.BooleanField(default='False') | |
KEY_BATH_S= models.ForeignKey( BATHROOM , on_delete=models.PROTECT ,verbose_name=PROP) | |
def __str__(self): | |
metraggio=chr(int(self.SQM)) | |
metraggio=metraggio + " " | |
S_Home_1 = "Piano : "+ str(self.PIANO) + ", Cucina :" + str(self.KITCHEN) | |
S_Home_2 = "Stanza : " + str(self.DINNING) + ", Stanza :" + str(self.LIVING) | |
S_Home_3= ", Stanza studio :"+ str(self.STUDING) + ", Stanze :" + str(self.ROOM) + ", Stanza " | |
S_Home_4 = str(self.ENSUITE) + ", Piscina : " + str(self.POOL) +", Connessione wifi :" + str(self.WIFI) | |
S_Home_5 = ", Animali da compagnia " + str(self.PET) + ", Ascensore" + str(self.LIFT) | |
S_Home_6 = ", Terrazzo : " + str(self.TERRAZZO) + ", Balcone :" + str(self.BALCONE) | |
S_Home_7 = ", Giardino : " + str(self.GIARDINO) + ", Cortile : " + str(self.CORTILE) | |
S_Home_8 = ", Vista mare " + str(self.SEAVIEW) + ", Garage : " + str(self.GARAGE) | |
return S_Home_1+S_Home_2+S_Home_3 + S_Home_4 + S_Home_5 +S_Home_6 + S_Home_7 + S_Home_8 | |
class Meta: | |
verbose_name = "stanza e caratteristica" | |
verbose_name_plural = "Stanze e caratteristiche" | |
#################### ordine corretto | |
class Doc_PDF_Owner(): #models.Model ): | |
Note= models.TextField() | |
DOC_1_PDF="Documenti PDF Proprietari " | |
def __str__(self): | |
return self.Note | |
class Meta: | |
verbose_name = "ZZZ Documento PDF propriatario" | |
verbose_name_plural = "ZZZ Documenti PDF Proprietari" | |
class Doc_PDF_CUSTOMER( ):#models.Model): | |
Note= models.TextField() | |
nome_PDF="Documenti PDF CUSTOMERS" | |
def __str__(self): | |
return self.Note | |
class Meta: | |
verbose_name = "ZZZ Documento PDF CUSTOMERS" | |
verbose_name_plural = "ZZZ Documenti PDF CUSTOMERS" | |
class Rubrica_owner( models.Model ): | |
nome=models.CharField( max_length=50) | |
cognome=models.CharField( max_length=50) | |
email=models.CharField( max_length=30 ) | |
Telefono=models.CharField( max_length=15 ) | |
Telefono_2=models.CharField( max_length=15 ) | |
def __str__(self): | |
return self.nome | |
class Meta: | |
verbose_name = "RRR - Rubrica Proprietario" | |
verbose_name_plural = "RRR- Rubrica Proprietari" | |
class Rubrica_Homes ( models.Model ): | |
D="01/01/2019" | |
DATA_FAB="Anno di costruzione " | |
DATA_DISP_INI="Disponibilità da " | |
DATA_DISP_FINE=" Disponibilità fine " | |
PRZ="Prezzo Euro" | |
Tip_casa="Tipologia di casa " | |
CTY="Città" | |
PROP="Proprietario " | |
affitto=models.BooleanField(default='False') | |
vendita=models.BooleanField(default='False') | |
freehold=models.BooleanField(default='False') | |
shell=models.BooleanField(default='False') | |
finisched=models.BooleanField(default='False') | |
furnisched=models.BooleanField(default='False') | |
Prezzo= models.IntegerField(default='0', verbose_name= PRZ) | |
DATA_FABRICAZIONE = models.DateField( default=D, verbose_name= DATA_FAB ) | |
DATA_DISPONIBILE_INIZIO = models.DateField( default=D ,verbose_name= DATA_DISP_INI) | |
DATA_DISPONIBILE_FINE = models.DateField( default=D ,verbose_name=DATA_DISP_FINE ) | |
# chiavi esterne caratteristiche Casa | |
#MEDIA_HOME= models.ForeignKey(Media_homes , on_delete=models.CASCADE) #Rubrica home -> media home | |
#city_to_rub_homes = models.OneToOneField(CITY , on_delete=models.DO_NOTHING ,verbose_name=CTY ) #Rubrica home -> city | |
#tipologia_to_rubrica_homes = models.ForeignKey(TIPOLOGIA , on_delete=models.CASCADE ,verbose_name= Tip_casa )#Rubrica-> tipologia | |
Service_Home_V = models.ForeignKey(Service_Home , on_delete=models.CASCADE , null=True ,verbose_name= PROP ) # Service_Home ->bagno | |
#chiave delle Rubrica owner | |
Rub_owner= models.ForeignKey(Rubrica_owner, on_delete=models.DO_NOTHING) # rubrica home <-rubrica owner | |
def __str__(self): | |
R1_Home = str(self.freehold ) + str(self.shell) + str( int(self.vendita)) | |
R2_Home= str(self.furnisched) + str(self.furnisched) +str(self.Prezzo) | |
#R3_Home = str(chr(self.DATA_FABRICAZIONE)+(self.DATA_DISPONIBILE_INIZIO)+ (self.DATA_DISPONIBILE_FINE)) | |
return "CASA"+ str(self.vendita)+ str(self.Prezzo) | |
class Meta: | |
verbose_name = "RRR - Rubrica Casa" | |
verbose_name_plural = "RRR - Rubrica Case" | |
class Rubrica_Customers( models.Model ): | |
nome=models.CharField( max_length=50, verbose_name="Nome") | |
cognome=models.CharField( max_length=50 , verbose_name="Cognome " ) | |
email=models.CharField( max_length=30, verbose_name="E-Mail " ) | |
Telefono=models.CharField( max_length=15 , verbose_name="Telefono principale " ) | |
Telefono_2=models.CharField( max_length=15 ,verbose_name="telefono secondario ") | |
def __str__(self): | |
return self.nome+self.cognome+self.email | |
class Meta: | |
verbose_name = "RRR - Rubrica Cliente affittuario o compratore" | |
verbose_name_plural = "RRR - Rubrica Clienti affittuari o compratori" | |
class DISPONIBILITY_V_A(models.Model ): | |
D="01/01/2019" | |
DATA_DISPONIBILE_INIZIO = models.DateField( default= D ) | |
DATA_DISPONIBILE_FINE = models.DateField( default= D ) | |
# RElation N a N | |
DISP_Vendita_Affitto_to_Rubrica_home = models.OneToOneField( Rubrica_Homes , on_delete=models.DO_NOTHING ) | |
DISP_Vendita_Affitto_to_Rubrica_customers = models.OneToOneField( Rubrica_Customers , on_delete=models.DO_NOTHING ) | |
class Meta: | |
verbose_name = "Disponibilità vendita affitto" | |
verbose_name_plural = "Disponibilità vendite affitti" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment