Ejemplo n.º 1
0
Archivo: models.py Proyecto: mdmjsh/soa
class Course(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name =  db.Column(db.String(64), index=True, unique=True)
    description = db.Column(db.Text)
    level = db.Column(db.String(64))
    created_at = db.Column(db.DateTime)
    updated_up = db.Column(db.DateTime)
    deleted_at = db.Column(db.DateTime)
    institutions = db.relationship('Institution', secondary=course_institutions,
        # primaryjoin=(course_institutions.c.course_id == id),
        # secondaryjoin=(course_institutions.c.institution_id == id),
        backref=db.backref('courses', lazy='dynamic'), lazy='dynamic')

    modules = db.relationship('Module', secondary=course_modules,
        # Commented out as 'sqlalchemy.orm.exc.UnmappedColumnError' on insert
        # primaryjoin=(course_modules.c.course_id == id),  
        # secondaryjoin=(course_modules.c.module_id == id),
        backref=db.backref('courses', lazy='dynamic'), lazy='dynamic')
Ejemplo n.º 2
0
Archivo: models.py Proyecto: mdmjsh/soa
class Institution(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name =  db.Column(db.String(64), index=True, unique=True)
    created_at = db.Column(db.DateTime)
    updated_up = db.Column(db.DateTime)
    deleted_at = db.Column(db.DateTime)
    users = db.relationship('User', secondary=institution_users,
        # primaryjoin=(institution_users.c.institution_id == id),
        # secondaryjoin=(institution_users.c.user_id == id),
        backref=db.backref('institutions', lazy='dynamic'), lazy='dynamic')
Ejemplo n.º 3
0
Archivo: models.py Proyecto: mdmjsh/soa
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    firstname = db.Column(db.String(64))
    lastname = db.Column(db.String(64))
    email = db.Column(db.String(120), index=True, unique=True)
    password_hash = db.Column(db.String(128))
    created_at = db.Column(db.DateTime)
    updated_up = db.Column(db.DateTime)
    deleted_at = db.Column(db.DateTime)
    last_sign_in = db.Column(db.DateTime)
    user_type = db.Column(db.String(32))
    modules = db.relationship('Module', secondary=user_modules,
        # primaryjoin=(user_modules.c.user_id == id),
        # secondaryjoin=(user_modules.c.module_id == id),
        backref=db.backref('users', lazy='dynamic'), lazy='dynamic')
    courses = db.relationship('Course', secondary=user_courses,
        # primaryjoin=(user_modules.c.user_id == id),
        # secondaryjoin=(user_modules.c.module_id == id),
        backref=db.backref('users', lazy='dynamic'), lazy='dynamic')

    # modules = many_to_many_relationship(user_modules, 'users', 'modules')

    def __repr__(self):
        return '<User {}>'.format(self.username)

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
Ejemplo n.º 4
0
Archivo: models.py Proyecto: mdmjsh/soa
class Module(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name =  db.Column(db.String(64), index=True)
    created_at = db.Column(db.DateTime)
    updated_up = db.Column(db.DateTime)
    deleted_at = db.Column(db.DateTime)
    description = db.Column(db.Text)
    tags = db.relationship('Tag', secondary=module_tags,
        # primaryjoin=(module_categories.c.module_id == id),
        # secondaryjoin=(module_categories.c.category_id == id),
        backref=db.backref('modules', lazy='dynamic'), lazy='dynamic')

    institutions = db.relationship('Institution', secondary=module_institutions,
        # primaryjoin=(module_institutions.c.module_id == id),
        # secondaryjoin=(module_institutions.c.institution_id == id),
        backref=db.backref('modules', lazy='dynamic'), lazy='dynamic')
Ejemplo n.º 5
0
Archivo: models.py Proyecto: mdmjsh/soa
class Tag(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name =  db.Column(db.String(64), index=True, unique=True)
    created_at = db.Column(db.DateTime)
    updated_up = db.Column(db.DateTime)
    deleted_at = db.Column(db.DateTime)