feat: Implement main application shell with navigation and color scheme toggle
- Added Appshell component with responsive navbar and main content area - Integrated ColorSchemeToggle for light/dark mode switching - Created Welcome component with styled title and introductory text - Developed ChatPage for LLM interaction with WebSocket support - Implemented Biblioteca for managing notes with rich text editor - Added LoginPage for user authentication with error handling - Introduced MessageList and MessageBubble components for chat messages - Styled components with CSS modules for consistent design
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
class Usuario:
|
||||
def __init__(self, id: int, nombre: str, email: str, activo: bool = True):
|
||||
self.id = id
|
||||
self.nombre = nombre
|
||||
self.email = email
|
||||
self.activo = activo
|
||||
|
||||
def activar(self):
|
||||
self.activo = True
|
||||
|
||||
def desactivar(self):
|
||||
self.activo = False
|
||||
|
||||
def __repr__(self):
|
||||
return f"Usuario(id={self.id}, nombre='{self.nombre}', email='{self.email}', activo={self.activo})"
|
||||
@@ -0,0 +1,82 @@
|
||||
from sqlalchemy import Column, Integer, String, Boolean
|
||||
from domains.ArquitectureLayer.Model import Model_base
|
||||
from domains.ArquitectureLayer.Mapper import Mapper_base
|
||||
from domains.ArquitectureLayer.Repo import Repo_base
|
||||
from domains.Usuario.usuario import Usuario
|
||||
|
||||
# ----------------------
|
||||
# MODELO (SQLAlchemy)
|
||||
# ----------------------
|
||||
|
||||
class UsuarioModel(Model_base):
|
||||
__tablename__ = 'usuarios'
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
nombre = Column(String, nullable=False)
|
||||
email = Column(String, unique=True, nullable=False)
|
||||
activo = Column(Boolean, default=True, nullable=False)
|
||||
|
||||
# ----------------------
|
||||
# MAPPER
|
||||
# ----------------------
|
||||
|
||||
class UsuarioMapper(Mapper_base[Usuario, UsuarioModel]):
|
||||
@staticmethod
|
||||
def to_model(obj: Usuario) -> UsuarioModel:
|
||||
return UsuarioModel(
|
||||
id=obj.id,
|
||||
nombre=obj.nombre,
|
||||
email=obj.email,
|
||||
activo=obj.activo
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_model(model: UsuarioModel) -> Usuario:
|
||||
return Usuario(
|
||||
id=model.id,
|
||||
nombre=model.nombre,
|
||||
email=model.email,
|
||||
activo=model.activo
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def to_dict(obj: Usuario) -> dict:
|
||||
return {
|
||||
'id': obj.id,
|
||||
'nombre': obj.nombre,
|
||||
'email': obj.email,
|
||||
'activo': obj.activo
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data: dict) -> Usuario:
|
||||
return Usuario(
|
||||
id=data['id'],
|
||||
nombre=data['nombre'],
|
||||
email=data['email'],
|
||||
activo=data.get('activo', True)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_model_list(models: list[UsuarioModel]) -> list[Usuario]:
|
||||
return [UsuarioMapper.from_model(m) for m in models]
|
||||
|
||||
# ----------------------
|
||||
# REPO
|
||||
# ----------------------
|
||||
|
||||
class UsuarioRepo(Repo_base[UsuarioModel, Usuario]):
|
||||
def __init__(self, session):
|
||||
super().__init__(
|
||||
session=session,
|
||||
modelo=UsuarioModel,
|
||||
mapper=UsuarioMapper
|
||||
)
|
||||
|
||||
def get_by_email(self, email: str) -> Usuario | None:
|
||||
model = (
|
||||
self.session.query(self.Modelo)
|
||||
.filter_by(email=email, sys_deleted_at=None)
|
||||
.first()
|
||||
)
|
||||
return self.Mapper.from_model(model) if model else None
|
||||
Reference in New Issue
Block a user