Files
DevOpsLab/app/models/user.py
Сергей Антропов 1fbf9185a2 feat: добавлена пометка типа операции (Build/Push) в истории сборок Dockerfile
- Добавлена колонка 'Тип' во все таблицы истории сборок
- Для push операций отображается registry вместо платформ
- Сохранение пользователя при создании push лога
- Исправлена ошибка с logger в push_docker_image endpoint
- Улучшено отображение истории сборок с визуальными индикаторами
2026-02-15 22:59:02 +03:00

65 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Модель пользователя
Автор: Сергей Антропов
Сайт: https://devops.org.ru
"""
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, JSON, Text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from datetime import datetime
Base = declarative_base()
class User(Base):
"""Модель пользователя"""
__tablename__ = "users"
id = Column(Integer, primary_key=True, index=True)
username = Column(String, unique=True, index=True, nullable=False)
hashed_password = Column(String, nullable=False)
is_active = Column(Boolean, default=True, nullable=False)
is_superuser = Column(Boolean, default=False, nullable=False)
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
# Связи
profile = relationship("UserProfile", back_populates="user", uselist=False, cascade="all, delete-orphan")
def __repr__(self):
return f"<User(username='{self.username}', is_active={self.is_active})>"
class UserProfile(Base):
"""Профиль пользователя с настройками"""
__tablename__ = "user_profiles"
id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey("users.id"), unique=True, nullable=False, index=True)
# Docker Hub настройки
dockerhub_username = Column(String)
dockerhub_password = Column(Text) # Зашифрованный пароль
dockerhub_repository = Column(String) # Имя репозитория по умолчанию
# Harbor настройки
harbor_url = Column(String) # URL Harbor репозитория
harbor_username = Column(String)
harbor_password = Column(Text) # Зашифрованный пароль
harbor_project = Column(String) # Имя проекта в Harbor
# Дополнительные настройки
email = Column(String)
full_name = Column(String)
extra_data = Column(JSON) # Дополнительные настройки
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
# Связи
user = relationship("User", back_populates="profile")
def __repr__(self):
return f"<UserProfile(user_id={self.user_id})>"