32 lines
922 B
Python
32 lines
922 B
Python
from sqlalchemy import ForeignKey, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
from database import db
|
|
|
|
|
|
class App(db.Model):
|
|
"""
|
|
The App object, interact with the App database object. Data is stored in
|
|
the local database.
|
|
"""
|
|
|
|
id = db.Column(Integer, primary_key=True)
|
|
name = db.Column(String(length=64))
|
|
slug = db.Column(String(length=64), unique=True)
|
|
|
|
def __repr__(self):
|
|
return f"{self.id} <{self.name}>"
|
|
|
|
|
|
class AppRole(db.Model):
|
|
"""
|
|
The AppRole object, stores the roles Users have on Apps
|
|
"""
|
|
|
|
user_id = db.Column(String(length=64), primary_key=True)
|
|
app_id = db.Column(Integer, ForeignKey("app.id"), primary_key=True)
|
|
role_id = db.Column(Integer, ForeignKey("role.id"))
|
|
|
|
role = relationship("Role")
|
|
|
|
def __repr__(self):
|
|
return f"role_id: {self.role_id}, user_id: {self.user_id}, app_id: {self.app_id}, role: {self.role}"
|