28 lines
974 B
Python
28 lines
974 B
Python
"""Permission model."""
|
|
|
|
from sqlalchemy import Column, String, Boolean, Text, Integer
|
|
from sqlalchemy.orm import relationship
|
|
from request_app.models.base import Base, TimestampMixin
|
|
|
|
|
|
class Permission(Base, TimestampMixin):
|
|
"""Permission model — Module-owned permission catalog.
|
|
|
|
Permissions are defined by Module, not Platform.
|
|
This table is the single source of truth for Module permissions.
|
|
"""
|
|
|
|
__tablename__ = "permissions"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(100), unique=True, nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
module_id = Column(String(50), nullable=False, default="request")
|
|
is_system = Column(Boolean, default=True)
|
|
|
|
# Relationships
|
|
role_permissions = relationship("RolePermission", back_populates="permission", cascade="all, delete-orphan")
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<Permission(id={self.id}, name='{self.name}')>"
|