Added admin panel.
This commit is contained in:
@ -5,6 +5,7 @@ from app.models.bet import Bet, BetProposal, BetCategory, BetStatus, BetVisibili
|
||||
from app.models.sport_event import SportEvent, SportType, EventStatus
|
||||
from app.models.spread_bet import SpreadBet, SpreadBetStatus, TeamSide
|
||||
from app.models.admin_settings import AdminSettings
|
||||
from app.models.admin_audit_log import AdminAuditLog
|
||||
from app.models.match_comment import MatchComment
|
||||
from app.models.event_comment import EventComment
|
||||
from app.models.gamification import (
|
||||
@ -40,6 +41,7 @@ __all__ = [
|
||||
"SpreadBetStatus",
|
||||
"TeamSide",
|
||||
"AdminSettings",
|
||||
"AdminAuditLog",
|
||||
"MatchComment",
|
||||
"EventComment",
|
||||
# Gamification
|
||||
|
||||
54
backend/app/models/admin_audit_log.py
Normal file
54
backend/app/models/admin_audit_log.py
Normal file
@ -0,0 +1,54 @@
|
||||
from sqlalchemy import String, DateTime, Integer, Text, ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from datetime import datetime
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class AdminAuditLog(Base):
|
||||
"""
|
||||
Audit log for tracking all admin actions on the platform.
|
||||
Every admin action should be logged for accountability and debugging.
|
||||
"""
|
||||
__tablename__ = "admin_audit_logs"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
|
||||
# Who performed the action
|
||||
admin_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
admin_username: Mapped[str] = mapped_column(String(50), nullable=False)
|
||||
|
||||
# What action was performed
|
||||
action: Mapped[str] = mapped_column(String(50), nullable=False, index=True)
|
||||
# Action codes:
|
||||
# - DATA_WIPE: Database wipe executed
|
||||
# - DATA_SEED: Database seeded with test data
|
||||
# - SIMULATION_START: Activity simulation started
|
||||
# - SIMULATION_STOP: Activity simulation stopped
|
||||
# - USER_STATUS_CHANGE: User enabled/disabled
|
||||
# - USER_BALANCE_ADJUST: User balance adjusted
|
||||
# - USER_ADMIN_GRANT: Admin privileges granted
|
||||
# - USER_ADMIN_REVOKE: Admin privileges revoked
|
||||
# - USER_UPDATE: User details updated
|
||||
# - SETTINGS_UPDATE: Platform settings changed
|
||||
# - EVENT_CREATE: Sport event created
|
||||
# - EVENT_UPDATE: Sport event updated
|
||||
# - EVENT_DELETE: Sport event deleted
|
||||
|
||||
# Target of the action (if applicable)
|
||||
target_type: Mapped[str | None] = mapped_column(String(50), nullable=True) # e.g., "user", "event", "bet"
|
||||
target_id: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
|
||||
# Description of the action
|
||||
description: Mapped[str] = mapped_column(String(500), nullable=False)
|
||||
|
||||
# Additional details as JSON string
|
||||
details: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
|
||||
# IP address of the admin (for security)
|
||||
ip_address: Mapped[str | None] = mapped_column(String(45), nullable=True)
|
||||
|
||||
# Timestamp
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, index=True)
|
||||
|
||||
# Relationship to admin user
|
||||
admin: Mapped["User"] = relationship("User", foreign_keys=[admin_id])
|
||||
@ -15,6 +15,8 @@ class TransactionType(enum.Enum):
|
||||
BET_CANCELLED = "bet_cancelled"
|
||||
ESCROW_LOCK = "escrow_lock"
|
||||
ESCROW_RELEASE = "escrow_release"
|
||||
ADMIN_CREDIT = "admin_credit"
|
||||
ADMIN_DEBIT = "admin_debit"
|
||||
|
||||
|
||||
class TransactionStatus(enum.Enum):
|
||||
|
||||
Reference in New Issue
Block a user