push
This commit is contained in:
29
app/models/company.py
Normal file
29
app/models/company.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from app.extensions import db
|
||||
from app.models.base import TimestampMixin
|
||||
|
||||
|
||||
class Company(TimestampMixin, db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(255), nullable=False, unique=True)
|
||||
tax_id = db.Column(db.String(32), index=True)
|
||||
regon = db.Column(db.String(32), index=True, default='')
|
||||
address = db.Column(db.String(255), default='')
|
||||
bank_account = db.Column(db.String(64), default='')
|
||||
is_active = db.Column(db.Boolean, default=True, nullable=False)
|
||||
sync_enabled = db.Column(db.Boolean, default=False, nullable=False)
|
||||
sync_interval_minutes = db.Column(db.Integer, default=60, nullable=False)
|
||||
notification_enabled = db.Column(db.Boolean, default=True, nullable=False)
|
||||
note = db.Column(db.Text)
|
||||
|
||||
|
||||
class UserCompanyAccess(TimestampMixin, db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False, index=True)
|
||||
company_id = db.Column(db.Integer, db.ForeignKey('company.id'), nullable=False, index=True)
|
||||
access_level = db.Column(db.String(20), default='full', nullable=False)
|
||||
|
||||
user = db.relationship('User', back_populates='company_access')
|
||||
company = db.relationship('Company', back_populates='user_access')
|
||||
|
||||
|
||||
Company.user_access = db.relationship('UserCompanyAccess', back_populates='company', cascade='all, delete-orphan')
|
||||
Reference in New Issue
Block a user