dashboard/areas/apps/models.py

30 lines
806 B
Python
Raw Normal View History

2022-04-13 10:27:17 +02:00
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)
2022-04-13 15:11:51 +02:00
role_id = db.Column(Integer, ForeignKey("role.id"))
2022-04-13 10:27:17 +02:00
def __repr__(self):
return f"{self.role} for {self.user_id} on {self.app_id}"