- Добавлена колонка 'Тип' во все таблицы истории сборок - Для push операций отображается registry вместо платформ - Сохранение пользователя при создании push лога - Исправлена ошибка с logger в push_docker_image endpoint - Улучшено отображение истории сборок с визуальными индикаторами
65 lines
2.5 KiB
Python
65 lines
2.5 KiB
Python
"""
|
||
Модель пользователя
|
||
Автор: Сергей Антропов
|
||
Сайт: 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})>"
|