Esempio n. 1
0
class TeacherCourse(object):
    query = db_session.query_property()

    def __init__(self, id=None, course_title=None, teacher_name=None):
        self.id = id
        self.course_title = course_title
        self.teacher_name = teacher_name
Esempio n. 2
0
class Postitem(object):
    query = db_session.query_property()

    def __init__(self,
                 post_id=None,
                 item_id=None,
                 color_id=None,
                 year_id=None,
                 latitude=None,
                 longitude=None,
                 status=None):
        self.post_id = post_id
        self.item_id = item_id
        self.color_id = color_id
        self.year_id = year_id
        self.latitude = latitude
        self.longitude = longitude
        self.status = status

    def serialize(self):
        return {
            "post_id": self.post_id,
            "item_id": self.item_id,
            "color_id": self.color_id,
            "year_id": self.year_id,
            "latitude": self.latitude,
            "longitude": self.longitude,
            "status": self.status
        }
Esempio n. 3
0
class Planning():
    query = db_session.query_property()

    def __init__(self, uuid, user_id, planning_txt, ics_fullpath, mbz_fullpath,
                 name, year, semester, group):
        self.uuid = uuid
        self.user_id = user_id
        self.planning_txt = planning_txt
        self.ics_fullpath = ics_fullpath
        self.mbz_fullpath = mbz_fullpath
        self.name = name
        self.year = year
        self.semester = semester
        self.group = group

    def as_pub_dict(self):
        pub_dict = {
            'uuid': self.uuid,
            'planning_txt': self.planning_txt,
            'name': self.name,
            'year': self.year,
            'semester': self.semester,
            'group': self.group,
            'created_at': self.created_at,
        }
        return pub_dict
Esempio n. 4
0
class Tags(Base):

    #表名
    __tablename__ ='tag'
    #表结构
    tagCode = Column(String(8), primary_key=True)
    tagName = Column(String(32),nullable=False)
    tagType = Column(String(16),nullable=False)

    # 查询构造器、、、
    query = db_session.query_property()

    def __init__(self, tagCode, tagType=None, tagName=None):
        self.tagCode = tagCode
        self.tagName = tagName
        self.tagType = tagType

    def __repr__(self):
        tag_dict = {
            u"tagCode":self.tagCode,
            u"tagName":self.tagName,
            u"tagType":self.tagType
        }
        return str(tag_dict)

    def __dir__(self):
        tag_dict = {
            u"tagCode": self.tagCode,
            u"tagName": self.tagName,
            u"tagType":self.tagType
        }
        return tag_dict
Esempio n. 5
0
class BlogPost(object):
    query = db_session.query_property()

    def __init__(self, id=None, title=None, post=None):
        self.id = id
        self.title = title
        self.post = post
Esempio n. 6
0
class TeamUser():
    query = db_session.query_property()

    def __init__(self, team_id, user_id, accepted=False):
        self.team_id = team_id
        self.user_id = user_id
        self.accepted = accepted

    def __repr__(self):
        return '<Team-User %r - %r>' % (self.team_id, self.user_id)

    def get_team_user_id(self):
        return TeamUser.query.filter(TeamUser.team_id == self.team_id) \
            .filter(TeamUser.user_id == self.user_id).first().id

    def get_user_name(self):
        user = User.query.filter(User.id == self.user_id).first()
        if user:
            return user.username

    def as_pub_dict(self):
        pub_dict = {
            'id': self.get_team_user_id(),
            'username': self.get_user_name(),
            'team_id': self.team_id,
            'accepted': self.accepted
        }
        return pub_dict
Esempio n. 7
0
class Team():
    query = db_session.query_property()

    def __init__(self, name, game, captain_id):
        self.name = name
        self.game = game
        self.captain_id = captain_id
        self.created_date = datetime.now

    def __repr__(self):
        return '<Team %r>' % (self.name)

    def get_team_id(self):
        return Team.query.filter(Team.name == self.name) \
            .filter(Team.game == self.game).first().id

    def get_captain_name(self):
        user = User.query.filter(User.id == self.captain_id).first()
        if user:
            return user.username

    def as_pub_dict(self):
        pub_dict = {
            'id': self.get_team_id(),
            'name': self.name,
            'game': self.game,
            'captain_name': self.get_captain_name(),
        }
        return pub_dict
Esempio n. 8
0
class Templates(Base):

    #表名
    __tablename__ = 'templates'
    #表结构
    templateid = Column(String(16), nullable=False, primary_key=True)
    sign = Column(String(256), nullable=False)
    content = Column(String(1024), nullable=False)
    smsCount = Column(Integer, nullable=False, default=0)
    tagStatus = Column(String(8), nullable=False, default='未标记')
    sample = Column(String(1024), nullable=False, default='')

    industry1 = Column(String(16), nullable=False, default='0')
    industry1Name = Column(String(16), nullable=False, default='0')
    industry2 = Column(String(16), nullable=False, default='0')
    industry2Name = Column(String(16), nullable=False, default='0')
    industry3 = Column(String(16), nullable=False, default='0')
    industry3Name = Column(String(16), nullable=False, default='0')
    offlineRisk = Column(String(16), nullable=False, default='0')
    offlineRiskName = Column(String(16), nullable=False, default='0')

    # 查询构造器、、、
    query = db_session.query_property()

    def __init__(self,
                 templateid=None,
                 sign=None,
                 content=None,
                 sample=None,
                 smsCount=None,
                 tagStatus=None):

        self.templateid = templateid
        self.sign = sign
        self.content = content
        self.sample = sample
        self.smsCount = smsCount
        self.tagStatus = tagStatus

    def __repr__(self):
        template_dict = {
            u"templateid": self.templateid,
            u"sign": self.sign,
            u"content": self.content,
            u"sample": self.sample,
            u"smsCount": int(self.smsCount),
        }
        return str(template_dict)

    def __dir__(self):
        template_dict = {
            u"templateid": self.templateid,
            u"sign": self.sign,
            u"content": self.content,
            u"sample": self.sample,
            u"smsCount": int(self.smsCount),
        }
        return template_dict
Esempio n. 9
0
class User(object):
    query = db_session.query_property()

    def __init__(self, name=None, email=None):
        self.name = name
        self.email = email

    def __repr__(self):
        return '<User %r>' % (self.name)
Esempio n. 10
0
class Year(object):
    query = db_session.query_property()

    def __init__(self, year_id=None, year_range=None):
        self.year_id = year_id
        self.year_range = year_range

    def serialize(self):
        return {"year_id": self.year_id, "year_range": self.year_range}
Esempio n. 11
0
class Color(object):
    query = db_session.query_property()

    def __init__(self, color_id=None, color_name=None):
        self.color_id = color_id
        self.color_name = color_name

    def serialize(self):
        return {"color_id": self.color_id, "color_name": self.color_name}
Esempio n. 12
0
class UserDetail(object):
    query = db_session.query_property()

    def __init__(self, user_email=None, user_name=None):
        self.user_email = user_email
        self.user_name = user_name

    def serialize(self):
        return {"user_email": self.user_email, "user_name": self.user_name}
Esempio n. 13
0
class Thumbnail(object):
    query = db_session.query_property()

    def __init__(self, photo_uuid=None,
                 width=None, height=None, url=None):
        self.photo_uuid = photo_uuid
        self.width = width
        self.height = height
        self.url = url
Esempio n. 14
0
class Invite():
    query = db_session.query_property()

    def __init__(self, code, creator_id):
        self.code = code
        self.creator_id = creator_id

    def __repr__(self):
        return '<Invite %r>' % (self.code)
Esempio n. 15
0
class User(object):
    query = db_session.query_property()

    def __init__(self, username=None, password=None):
        self.username = username
        self.password = password

    def __repr__(self):
        return '<User %r>' % (self.username)
Esempio n. 16
0
class File(object):
    query = db_session.query_property()

    def __init__(self, fileName=None, filePath=None):
        self.filePath = filePath
        self.fileName = fileName

    def __repr__(self):
        return '<File %r>' % (self.fileName)
Esempio n. 17
0
class Permission(object):
    query = db_session.query_property()

    def __init__(self, fileID=None, userID=None):
        self.fileID = fileID
        self.userID = userID

    def __repr__(self):
        return '<Permission %r, %r>' % (self.userID, self.fileID)
Esempio n. 18
0
class User(Base):
    """Sqlalchemy User model"""
    __tablename__ = '_user'
    query = db_session.query_property()

    id = Column(Integer, Sequence('_user_id_seq'), primary_key=True)
    email = Column(VARCHAR(255), unique=True, nullable=False)
    password = Column(CHAR(32), nullable=False)
    name = Column(VARCHAR(255), nullable=False)
Esempio n. 19
0
class Users(Base):

    #表名
    __tablename__ = 'user'
    #表结构
    userid = Column(Integer, autoincrement=True, primary_key=True)
    username = Column(String(64), nullable=False)
    passwd = Column(String(64), nullable=False)
    identity = Column(Integer, nullable=False)
    email = Column(String(64), nullable=True)
    lastTaskId = Column(String(16), nullable=True)
    #关联变量名 = relationship('关联表名',lazy='dynamic'不级联增加,ForeignKey('table.column'))

    # 查询构造器、、、
    query = db_session.query_property()

    def __init__(self,
                 passwd=None,
                 username=None,
                 identity=None,
                 email=None,
                 lastTaskId=None,
                 utility=None,
                 from_result=False):
        if from_result == True:
            self.userid = utility.userid
            self.username = utility.username
            self.identity = utility.identityname
            self.email = utility.email
            self.lastTaskId = utility.lastTaskId
        else:
            self.passwd = passwd
            self.username = username
            self.identity = identity
            self.email = email
            self.lastTaskId = lastTaskId

    def __repr__(self):
        user_dict = {
            u"userid": int(self.userid),
            u"username": self.username,
            u"identity": self.identity,
            u"email": self.email,
            u"lastTaskId": self.lastTaskId
        }
        return str(user_dict)

    def __dir__(self):
        user_dict = {
            u"userid": int(self.userid),
            u"username": self.username,
            u"identity": self.identity,
            u"email": self.email,
            u"lastTaskId": self.lastTaskId
        }
        return user_dict
Esempio n. 20
0
class Payment():
    query = db_session.query_property()

    def __init__(self, amount, ticket_id, paypal_payment_id):
        self.amount = amount
        self.ticket_id = ticket_id
        self.paypal_payment_id = paypal_payment_id

    def __repr__(self):
        return '<Seat %r>' % (self.id)
Esempio n. 21
0
class Photo(object):
    query = db_session.query_property()

    def __init__(self, uuid=None, url=None, status=None):
        self.uuid = uuid
        self.url = url
        self.status = status

    def __repr__(self):
        return '<Photo %r> [%r] %r' % (self.uuid, self.status, self.url)
Esempio n. 22
0
class Caminhao(object):
    query = db_session.query_property()

    def __init__(self, id=None, tipo=None):
        self.id = id
        self.tipo = tipo

    def add(self):
        db_session.add(self)
        db_session.commit
Esempio n. 23
0
class Upload():
    query = db_session.query_property()

    def __init__(self, hash, short_url, mime_type):
        self.hash = hash
        self.short_url = short_url
        self.mime_type = mime_type

    def __repr__(self):
        return '<Upload %r>' % (self.hash)
Esempio n. 24
0
class User():
    query = db_session.query_property()

    def __init__(self, username, password, salt):
        self.username = username
        self.password = password
        self.salt = salt

    def __repr__(self):
        return '<User %r>' % (self.username)
class VideosDB(object):
    query = db_session.query_property()

    def __init__(self, *params):
        for name, value in zip(
            ("input_content_id", "input_content_origin", "video_track_number",
             "status", "output_file_path", "video_key", "kid",
             "packaged_content_id", "url"), tuple(params)):
            setattr(self, name, None)

    def __repr__(self):
        return '<VideosDB %r>' % (self.input_content_id)
Esempio n. 26
0
class UserCollectsPhoto(Base):
    """Sqlalchemy UserCollectsPhoto model"""
    __tablename__ = 'user_collects_photo'
    query = db_session.query_property()

    id = Column(Integer, Sequence('activity_id_seq'), primary_key=True)
    user_id = Column(Integer, ForeignKey('_user.id'), nullable=False)
    photo_id = Column(Integer, ForeignKey('photo.id'), nullable=False)
    collect_time = Column(TIMESTAMP, nullable=False)

    user = relationship('User', foreign_keys=[user_id])
    photo = relationship('Photo', foreign_keys=[photo_id])
Esempio n. 27
0
class Photo(Base):
    """Sqlalchemy Photo model"""
    __tablename__ = 'photo'
    query = db_session.query_property()

    id = Column(Integer, Sequence('_photo_id_seq'), primary_key=True)
    url = Column(TEXT, nullable=False)
    created_time = Column(TIMESTAMP, nullable=False)
    created_by = Column(Integer, ForeignKey('_user.id'), nullable=False)
    recommended_count = Column(Integer, default=0)
    rank = Column(Integer, default=0)
    creator = relationship('User', foreign_keys=[created_by])
Esempio n. 28
0
class User(object):
    query = db_session.query_property()

    def __init__(self, name=None, email=None):
        self.name = name
        self.email = email

    def __repr__(self):
        return '<User %r>' % (self.name)

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
Esempio n. 29
0
class Student:
    query = db_session.query_property()
    def __init__(self, first_name, last_name, age=None, email=None):
        self.first_name = first_name
        self.last_name = last_name
        self.age = age
        self.email = email

    def expell(self):
        self.is_expelled = True

    def print_self(self):
        print(self.first_name, self.last_name, self.age, self.email)
Esempio n. 30
0
class User(object):
    query = db_session.query_property()

    def __init__(self, date=None, ip=None, funcn=None, value1=None, value2=None, result=None):
        self.date = date
        self.ip = ip
        self.funcn = funcn
        self.value1 = value1
        self.value2 = value2
        self.result = result

    def __repr__(self):
        return '%r | %r  | %r  | %r | %r | %r \n' % (self.date, self.ip, self.funcn, self.value1, self.value2, self.result)
Esempio n. 31
0
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from database import db, engine, db_session


Base = declarative_base()
Base.query = db_session.query_property()

# Set your classes here.

class Professional(Base):
    __tablename__ = 'professionals'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(120), unique=True)
    address = db.Column(db.String(320))
    web = db.Column(db.String(120))
    phone_number = db.Column(db.String(120))
    shi = db.Column(db.Boolean)
    qualification = db.Column(db.String(30))
    other_info = relationship("OtherInfo", back_populates="therapist");

    #Professional("Katie", "Rainbow Drive", "www.google.com", "73", False, "Self-certified")
    def __init__(self, name=None, address=None, web=None,
                 phone_number = None, shi=None, qualification=None):
        self.name = name
        self.web= web
        self.shi = shi
        self.qualification = qualification