Files
vpn-control-panel/app/models/notification.py
smolkik-code 7c7c88621d Initial commit: VPN Control Panel
- FastAPI REST API with JWT auth
- aiogram 3 Telegram bot with admin middleware
- APScheduler daily tasks (expiry, reminders, revoke, sync)
- SQLAlchemy 2 async ORM with Alembic migrations
- Jinja2 admin panel (Dashboard, Users, Payments, Servers, Tariffs)
- VPN provider abstraction with MockProvider
- Stats service with revenue/subscription analytics
- Docker Compose (PostgreSQL + Redis + app)
- Healthcheck endpoint
2026-07-05 17:50:11 +07:00

38 lines
1.2 KiB
Python

import enum
from datetime import datetime
from sqlalchemy import Boolean, DateTime, Enum, ForeignKey, Integer, String, Text, func
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.database import Base
class NotificationType(str, enum.Enum):
INFO = "info"
WARNING = "warning"
SUCCESS = "success"
PAYMENT = "payment"
class Notification(Base):
__tablename__ = "notifications"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
user_id: Mapped[int] = mapped_column(
Integer, ForeignKey("users.id"), nullable=False
)
type: Mapped[NotificationType] = mapped_column(
Enum(NotificationType, name="notification_type"), default=NotificationType.INFO
)
title: Mapped[str] = mapped_column(String(128), nullable=False)
text: Mapped[str] = mapped_column(Text, nullable=False)
is_read: Mapped[bool] = mapped_column(Boolean, default=False)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now()
)
user: Mapped["User"] = relationship(back_populates="notifications")
def __repr__(self) -> str:
return f"<Notification id={self.id} {self.type.value} user={self.user_id}>"