54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
"""
|
|
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
|
|
|
|
from database import db
|
|
|
|
# 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}"
|