29 lines
790 B
Python
29 lines
790 B
Python
from sqlalchemy import ForeignKey, Integer, String
|
|
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 = db.Column(String(length=64))
|
|
|
|
def __repr__(self):
|
|
return f"{self.role} for {self.user_id} on {self.app_id}"
|