update
This commit is contained in:
@@ -13,6 +13,9 @@ from .checkin_checkout import CheckInCheckOut
|
||||
from .banner import Banner
|
||||
from .review import Review
|
||||
from .favorite import Favorite
|
||||
from .audit_log import AuditLog
|
||||
from .cookie_policy import CookiePolicy
|
||||
from .cookie_integration_config import CookieIntegrationConfig
|
||||
|
||||
__all__ = [
|
||||
"Role",
|
||||
@@ -30,5 +33,8 @@ __all__ = [
|
||||
"Banner",
|
||||
"Review",
|
||||
"Favorite",
|
||||
"AuditLog",
|
||||
"CookiePolicy",
|
||||
"CookieIntegrationConfig",
|
||||
]
|
||||
|
||||
|
||||
Binary file not shown.
BIN
Backend/src/models/__pycache__/audit_log.cpython-312.pyc
Normal file
BIN
Backend/src/models/__pycache__/audit_log.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
Backend/src/models/__pycache__/cookie_policy.cpython-312.pyc
Normal file
BIN
Backend/src/models/__pycache__/cookie_policy.cpython-312.pyc
Normal file
Binary file not shown.
28
Backend/src/models/audit_log.py
Normal file
28
Backend/src/models/audit_log.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""
|
||||
Audit log model for tracking important actions
|
||||
"""
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, JSON
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from ..config.database import Base
|
||||
|
||||
|
||||
class AuditLog(Base):
|
||||
__tablename__ = "audit_logs"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=True, index=True)
|
||||
action = Column(String(100), nullable=False, index=True) # e.g., "user.created", "booking.cancelled"
|
||||
resource_type = Column(String(50), nullable=False, index=True) # e.g., "user", "booking"
|
||||
resource_id = Column(Integer, nullable=True, index=True)
|
||||
ip_address = Column(String(45), nullable=True) # IPv6 compatible
|
||||
user_agent = Column(String(255), nullable=True)
|
||||
request_id = Column(String(36), nullable=True, index=True) # UUID
|
||||
details = Column(JSON, nullable=True) # Additional context
|
||||
status = Column(String(20), nullable=False, default="success") # success, failed, error
|
||||
error_message = Column(Text, nullable=True)
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False, index=True)
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", foreign_keys=[user_id])
|
||||
|
||||
30
Backend/src/models/cookie_integration_config.py
Normal file
30
Backend/src/models/cookie_integration_config.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from ..config.database import Base
|
||||
|
||||
|
||||
class CookieIntegrationConfig(Base):
|
||||
"""
|
||||
Stores IDs for well-known integrations (e.g., Google Analytics, Meta Pixel).
|
||||
Does NOT allow arbitrary script injection from the dashboard.
|
||||
"""
|
||||
|
||||
__tablename__ = "cookie_integration_configs"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
|
||||
ga_measurement_id = Column(String(64), nullable=True) # e.g. G-XXXXXXXXXX
|
||||
fb_pixel_id = Column(String(64), nullable=True) # e.g. 1234567890
|
||||
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
updated_at = Column(
|
||||
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False
|
||||
)
|
||||
|
||||
updated_by_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
updated_by = relationship("User", lazy="joined")
|
||||
|
||||
|
||||
31
Backend/src/models/cookie_policy.py
Normal file
31
Backend/src/models/cookie_policy.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from ..config.database import Base
|
||||
|
||||
|
||||
class CookiePolicy(Base):
|
||||
"""
|
||||
Global cookie policy controlled by administrators.
|
||||
|
||||
This does NOT store per-user consent; it controls which cookie categories
|
||||
are available to be requested from users (e.g., disable analytics entirely).
|
||||
"""
|
||||
|
||||
__tablename__ = "cookie_policies"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
|
||||
analytics_enabled = Column(Boolean, default=True, nullable=False)
|
||||
marketing_enabled = Column(Boolean, default=True, nullable=False)
|
||||
preferences_enabled = Column(Boolean, default=True, nullable=False)
|
||||
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
|
||||
|
||||
updated_by_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
updated_by = relationship("User", lazy="joined")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user