first commit
This commit is contained in:
79
app/modules/users/models.py
Normal file
79
app/modules/users/models.py
Normal file
@@ -0,0 +1,79 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Float, Boolean, Text, ForeignKey, Enum as SQLEnum
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.orm import relationship
|
||||
from database import Base
|
||||
|
||||
import enum
|
||||
|
||||
class Rol(str, enum.Enum):
|
||||
COMPRAS ="compras"
|
||||
VENTAS ="ventas"
|
||||
LOGISTICA ="logistica"
|
||||
ADUANA_SOFT ="aduana_soft"
|
||||
CLIENTE ="cliente"
|
||||
OPERATIVO ="operativo"
|
||||
|
||||
class TipoUsuario(str, enum.Enum):
|
||||
ROOT ="root"
|
||||
ADMIN ="admin"
|
||||
PRIVILEGED ="privileged"
|
||||
ADMIN_LICENCIAS ="admin_licencias"
|
||||
UPDATER = "updater"
|
||||
USER ="user"
|
||||
|
||||
|
||||
class Users(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(Integer, primary_key=True, nullable=False, index=True, autoincrement=True)
|
||||
#identity
|
||||
name = Column(String(100), nullable=False)
|
||||
middle_Name = Column(String(100), nullable=True)
|
||||
last_Name = Column(String(120), nullable=False)
|
||||
rfc = Column(String(60), nullable=False, unique=True)
|
||||
|
||||
#==== CONEXIONS ====#
|
||||
email = Column(String(120), nullable=False, unique=True)
|
||||
password = Column(String(255), nullable=False)
|
||||
|
||||
#=== credentials
|
||||
rol_operativo = Column(SQLEnum(Rol), default="operativo", nullable=False)
|
||||
tipo_usuario = Column(SQLEnum(TipoUsuario), default="user", nullable=False)
|
||||
permite_diot = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
#==== WHERES
|
||||
enterprise_id = Column(Integer, nullable=True)
|
||||
firma = Column(String(110), nullable=True, unique=True)
|
||||
is_active = Column(Boolean, nullable=False, default=True)
|
||||
|
||||
|
||||
#timestamsp
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now(), nullable=True)
|
||||
deleted_at = Column(DateTime(timezone=True), nullable=True)
|
||||
last_login = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
||||
|
||||
#trace
|
||||
created_by = Column(Integer, nullable=True)
|
||||
updated_by = Column(Integer, nullable=True)
|
||||
deleted_by = Column(Integer, nullable=True)
|
||||
|
||||
|
||||
#=====
|
||||
# PASSWORD RESET
|
||||
#=====
|
||||
|
||||
password_reset_token = Column(String, nullable=True)
|
||||
password_reset_expires = Column(String, nullable=True)
|
||||
|
||||
|
||||
#relationships
|
||||
clients = relationship("Client", back_populates="user")
|
||||
branch = relationship("Branches", back_populates="user")
|
||||
interactions = relationship("Interacction", back_populates="user")
|
||||
moves = relationship("Moves", back_populates="user", primaryjoin="Users.id == Moves.user_id")
|
||||
licenses = relationship("License", back_populates="user")
|
||||
feed = relationship("Feed", back_populates="user", primaryjoin="Users.id == Feed.user_id")
|
||||
coments = relationship("Coments", back_populates="user", primaryjoin="Users.id == Coments.user_id")
|
||||
affidavit_logs = relationship("AffidavitRecord", back_populates="user", primaryjoin="Users.id == AffidavitRecord.user_id")
|
||||
|
||||
Reference in New Issue
Block a user