Beispiel #1
0
class Organisation(db.Model):
    id = db.Column(db.Integer(), primary_key=True, autoincrement=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))
    projectmgrs = db.relationship('Projectmgr',
                                  secondary=organisations_projectmgrs,
                                  backref=db.backref('organisations',
                                                     lazy='dynamic'))
    projects = db.relationship('Project',
                               secondary=organisations_projects,
                               backref=db.backref('organisations',
                                                  lazy='dynamic'))

    def __str__(self):
        return self.name

    def __repr__(self):
        return '<models.Organisation[name=%s]>' % self.name
Beispiel #2
0
# -*- coding: utf-8 -*-
from Mandark.project.app import db
from sqlalchemy.ext.hybrid import hybrid_property
from flask_security import UserMixin, RoleMixin
"""
We need a table to relate users to roles by id.
This is an example of a many-to-many relationship in SQLAlchemy
i.e. a user can have many roles and roles can have many users
"""
roles_users = db.Table(
    'roles_users', db.Column('user_id', db.Integer(),
                             db.ForeignKey('user.id')),
    db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))

organisations_projectmgrs = db.Table(
    'organisations_projectmgrs',
    db.Column('organisation_id', db.Integer(),
              db.ForeignKey('organisation.id')),
    db.Column('projectmgr_id', db.Integer(), db.ForeignKey('projectmgr.id')))

organisations_projects = db.Table(
    'organisations_projects',
    db.Column('organisation_id', db.Integer(),
              db.ForeignKey('organisation.id')),
    db.Column('project_id', db.Integer(), db.ForeignKey('project.id')))

change_request_types_change_request_submitters = \
    db.Table('change_request_types_change_request_submitters',
             db.Column('crt_id', db.Integer(),
                       db.ForeignKey('change_request_type.id')),
             db.Column('crs_id', db.Integer(),