Initial commit: enterprise digital platform with portal SSO, DigiServer, IT Assets, NetworkView, Server Monitor
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from datetime import datetime
|
||||
from app.extensions import db
|
||||
|
||||
|
||||
class AppAccess(db.Model):
|
||||
"""Controls which portal users have access to which sub-applications."""
|
||||
__tablename__ = 'app_access'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('portal_users.id'), nullable=False)
|
||||
app_name = db.Column(db.String(50), nullable=False) # 'digiserver' | 'networkview' | 'itassets'
|
||||
is_active = db.Column(db.Boolean, default=True)
|
||||
# Per-app role override: 'admin' | 'user' | None (None = inherit the portal-level role)
|
||||
app_role = db.Column(db.String(20), nullable=True)
|
||||
granted_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
|
||||
__table_args__ = (db.UniqueConstraint('user_id', 'app_name', name='uq_user_app'),)
|
||||
|
||||
def __repr__(self):
|
||||
return f'<AppAccess user={self.user_id} app={self.app_name} role={self.app_role}>'
|
||||
Reference in New Issue
Block a user