isDone = db.Column(db.Boolean) message = db.Column(db.String) executionTime = db.Column(db.DateTime) isRead = db.Column(db.Boolean) command_id = db.Column( db.Integer, db.ForeignKey('command.id', ondelete="cascade", onupdate="cascade")) def __hash__(self): return hash(self.id) RaspberryUser = db.Table( 'raspberry_user', db.Column('raspberry_id', db.Integer, db.ForeignKey('raspberry.id')), db.Column('user_id', db.Integer, db.ForeignKey('user.id')), db.PrimaryKeyConstraint('raspberry_id', 'user_id')) @dataclass class Raspberry(db.Model, Base): id: int updateAt: datetime name: str name = db.Column(db.String, nullable=True) hardwares = db.relationship("Hardware", backref="raspberry", lazy='dynamic') users = db.relationship('User',
#!/usr/local/bin/python # -*- coding:utf-8 -*- from web import db from web.utils.jsonencoder import JsonSerializer __author__ = 'Rocky Peng' rel_user_project = db.Table( "rel_user_project", db.Column("id", db.Integer, primary_key=True), db.Column("user_id", db.Integer, db.ForeignKey("users.id")), db.Column("project_id", db.Integer, db.ForeignKey("projects.id")), db.Column("created_at", db.DateTime, default=db.func.now()), db.Column("updated_at", db.DateTime, default=db.func.now(), onupdate=db.func.now()), ) class Projects(JsonSerializer, db.Model): __json_hidden__ = ["deploys", "users"] id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(64), unique=True) repo_url = db.Column(db.String(200)) checkout_dir = db.Column(db.String(200)) target_dir = db.Column(db.String(200)) deploy_dir = db.Column(db.String(200)) deploy_history_dir = db.Column(db.String(200)) before_checkout = db.Column(db.Text, default="")
from web import db from sqlalchemy.dialects.postgresql import JSON from sqlalchemy import UniqueConstraint from flask_user import UserMixin episodes = db.Table('episodes', db.Column('episode_id', db.Integer, db.ForeignKey('episode.id')), db.Column('user_id', db.Integer, db.ForeignKey('user.id')), db.Column('episode_assigned', db.Boolean(), nullable=False, default=False), UniqueConstraint('episode_id', 'user_id', name='episode_user_id') ) teachers = db.Table('teachers', db.Column('student_id', db.Integer, db.ForeignKey('user.id')), db.Column('teacher_id', db.Integer, db.ForeignKey('user.id')) ) class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) # User authentication information username = db.Column(db.String(50), nullable=False, unique=True) password = db.Column(db.String(255), nullable=False, server_default='') reset_password_token = db.Column(db.String(100), nullable=False, server_default='') # User email information email = db.Column(db.String(255), nullable=False, unique=True) confirmed_at = db.Column(db.DateTime()) # User information
# coding=utf-8 import shutil import hashlib import os import json from datetime import datetime from uuid import uuid4 from flask import url_for from web import db, app, avatars, backgrounds WatchHistory = db.Table( 'WatchHistory', db.Model.metadata, db.Column('User_id', db.Integer, db.ForeignKey('User.id')), db.Column('Video_id', db.String(32), db.ForeignKey('Video.id'))) Likes = db.Table( 'Likes', db.Model.metadata, db.Column('User_id', db.Integer, db.ForeignKey('User.id')), db.Column('Video_id', db.String(32), db.ForeignKey('Video.id'))) Dislikes = db.Table( 'Dislikes', db.Model.metadata, db.Column('User_id', db.Integer, db.ForeignKey('User.id')), db.Column('Video_id', db.String(32), db.ForeignKey('Video.id'))) Subscription = db.Table( 'Subscription', db.Model.metadata, db.Column('User_id', db.Integer, db.ForeignKey('User.id')), db.Column('UserB_id', db.Integer, db.ForeignKey('User.id'))) VideoTags = db.Table(
from web import app, db, resize from gravatar import gravatar from flask import url_for import flask_whooshalchemy as whooshalchemy from sqlalchemy.sql.expression import func from datetime import datetime from slugify import slugify movie_genres = db.Table( 'movie_genres', db.Column('movie_id', db.Integer, db.ForeignKey('movie.id')), db.Column('genre_id', db.Integer, db.ForeignKey('genre.id')), ) movie_directors = db.Table( 'movie_directors', db.Column('movie_id', db.Integer, db.ForeignKey('movie.id')), db.Column('person_id', db.Integer, db.ForeignKey('person.id')), ) class Movie(db.Model): __searchable__ = ['description', ] id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(140), nullable=False) original_title = db.Column(db.String(140), nullable=True) slug = db.Column(db.String(64), nullable=False, unique=True) wiki_url = db.Column(db.String(64), nullable=True)
from web import db #association table between students and programs association_table = db.Table( 'association', db.Column('student_id', db.Integer, db.ForeignKey('student.ruid')), db.Column('program_id', db.Integer, db.ForeignKey('program.id'))) class Attendance(db.Model): __tablename__ = 'attendance' studentId = db.Column(db.Integer, db.ForeignKey('student.ruid'), primary_key=True) programId = db.Column(db.Integer, db.ForeignKey('program.id'), primary_key=True) leader = db.Column(db.Boolean, default=False) description = db.Column(db.Text) program = db.relationship("Program", back_populates="attendances") student = db.relationship("Student", back_populates="attendances") def __init__(self, student, program, description="", leader=False): self.program = program self.description = description self.leader = leader self.student = student
from web import db from gravatar import gravatar from web.models.post import Post ROLE_USER = 0 ROLE_ADMIN = 1 followers = db.Table( 'followers', db.Column('follower_id', db.Integer, db.ForeignKey('user.id')), db.Column('followed_id', db.Integer, db.ForeignKey('user.id')), ) class User(db.Model): id = db.Column(db.Integer, primary_key=True) nickname = db.Column(db.String(64), index=True, unique=True) email = db.Column(db.String(120), index=True, unique=True) role = db.Column(db.SmallInteger, default=ROLE_USER) posts = db.relationship('Post', backref='author', lazy='dynamic') movies = db.relationship('Movie', backref='posted_by', lazy='dynamic') about_me = db.Column(db.String(140)) last_seen = db.Column(db.DateTime) followed = db.relationship( 'User', secondary=followers, primaryjoin=(followers.c.follower_id == id), secondaryjoin=(followers.c.followed_id == id), backref=db.backref('followers', lazy='dynamic'), lazy='dynamic', )