dashboard/helpers/models.py

55 lines
1.5 KiB
Python
Raw Normal View History

2022-03-22 08:56:36 +01:00
"""
Implement different models used by Stackspin panel
"""
from flask import current_app
from flask_sqlalchemy import SQLAlchemy
# pylint: disable=cyclic-import
# This is based on the documentation of Flask Alchemy
#from app import db
# We need this import at some point to hook up roles and users
# from sqlalchemy.orm import relationship
from sqlalchemy import ForeignKey, Integer, String
2022-04-01 09:15:30 +02:00
from database import db
2022-03-22 08:56:36 +01:00
# Pylint complains about too-few-public-methods. Methods will be added once
# this is implemented.
# pylint: disable=too-few-public-methods
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}>"
# Pylint complains about too-few-public-methods. Methods will be added once
# this is implemented.
# pylint: disable=too-few-public-methods
class AppRole(db.Model):
"""
The AppRole object, stores the roles Users have on Apps
"""
# pylint: disable=no-member
user_id = db.Column(String(length=64), primary_key=True)
# pylint: disable=no-member
app_id = db.Column(Integer, ForeignKey('app.id'),
primary_key=True)
# pylint: disable=no-member
role = db.Column(String(length=64))
def __repr__(self):
return f"{self.role} for {self.user_id} on {self.app_id}"