Newer
Older
GestionHoteleriaApi / apps / user / models.py
Yesid Madrid on 22 May 2021 1 KB version 2
from django.contrib.auth.models import AbstractUser
from django.db import models

# Create your models here.


class TypeId(models.Model):
    name = models.CharField(max_length=100)
    acronym = models.CharField(max_length=50)
    active = models.BooleanField(blank=True, null=True)


class Region(models.Model):
    code = models.IntegerField()
    name = models.CharField(max_length=100)
    acronym = models.CharField(max_length=100)
    region = models.CharField(max_length=100)
    govern = models.ForeignKey(to="self", on_delete=models.PROTECT, blank=True, null=True, related_name="governed")
    active = models.BooleanField(blank=True, null=True)


class Gender(models.Model):
    name = models.CharField(max_length=100)
    acronym = models.CharField(max_length=50)
    active = models.BooleanField(blank=True, null=True)


class User(AbstractUser):
    photo = models.ImageField(blank=True, null=True, upload_to='logos/')
    gender = models.ForeignKey(Gender, null=True, blank=True, on_delete=models.PROTECT)
    city = models.ForeignKey(Region, null=True, blank=True, on_delete=models.PROTECT)
    notification_token = models.CharField(max_length=100, blank=True, null=True)
    type_id = models.ForeignKey(TypeId, blank=True, null=True, on_delete=models.PROTECT)