dashboard/areas/apps/models.py

33 lines
922 B
Python
Raw Normal View History

2022-04-13 10:27:17 +02:00
from sqlalchemy import ForeignKey, Integer, String
from sqlalchemy.orm import relationship
2022-04-13 10:27:17 +02:00
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
role = relationship("Role")
2022-04-13 10:27:17 +02:00
def __repr__(self):
return f"role_id: {self.role_id}, user_id: {self.user_id}, app_id: {self.app_id}, role: {self.role}"