Removed circular import for DB
This commit is contained in:
parent
755cb03aaf
commit
d09d9d77bd
5 changed files with 88 additions and 4 deletions
|
|
@ -2,3 +2,4 @@ from .kratos_api import *
|
|||
from .error_handler import *
|
||||
from .hydra_oauth import *
|
||||
from .kratos import *
|
||||
from .models import *
|
||||
|
|
|
|||
54
helpers/models.py
Normal file
54
helpers/models.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
"""
|
||||
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
|
||||
|
||||
db = SQLAlchemy()
|
||||
|
||||
# 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}"
|
||||
Reference in a new issue