コード例 #1
0
class User(db.Model):
    id = db.Column(db.Integer,
                   primary_key=True,
                   nullable=False,
                   autoincrement=True)
    user_name = db.Column(db.String, nullable=False)
    user_surname = db.Column(db.String, nullable=False)
    email = db.Column(db.String, nullable=False, unique=True)
コード例 #2
0
ファイル: userModel.py プロジェクト: SaveYourCar/EsempioBlogR
class User(db.Model):

    user_id = db.Column(db.String, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)
    password_hash = db.Column(db.String(128))
    posts = db.relationship('Post', backref='author', lazy='dynamic')

    def __repr__(self):
        return '<User {}>'.format(self.username)
コード例 #3
0
class Post(db.Model):

    sno = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.user_id'))
    title = db.Column(db.String(80), nullable=False)
    slug = db.Column(db.String(21), nullable=False)
    content = db.Column(db.String(120), nullable=False)
    tagline = db.Column(db.String(120), nullable=False)
    date = db.Column(db.String(12), nullable=True)
    img_file = db.Column(db.String(12), nullable=True)
コード例 #4
0
class Contacts(db.Model):
    sno = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    phone_num = db.Column(db.String(12), nullable=False)
    msg = db.Column(db.String(120), nullable=False)
    date = db.Column(db.String(12), nullable=True)
    email = db.Column(db.String(20), nullable=False)
コード例 #5
0
ファイル: college.py プロジェクト: didenko-yv/vntudb
class College(db.Model):

    __tablename__ = 'colleges'

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.Unicode(100), nullable=False)
    accreditation = db.Column(db.Integer(), nullable=True)
    address = db.Column(db.Unicode(100), nullable=False)
    year = db.Column(db.Integer(), nullable=False, default=0)
    country = db.Column(db.Unicode(100))

    def get_data(self):
        row = {}
        for c in self.__table__.columns:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def get_by_id(_id):
        obj = College.query.filter_by(id=_id).first()
        return obj if obj is not None else []

    @staticmethod
    def update_by_id(raw):
        _id = raw['id']
        obj = College.get_by_id(_id)
        for r in raw:
            if hasattr(obj, r):
                setattr(obj, r, raw[r])
        db.session.commit()
        return obj.get_data()

    @staticmethod
    def delete_by_id(_id):
        obj = College.query.filter_by(id=_id).first()
        db.session.delete(obj)
        db.session.commit()
        return _id

    def to_dict(self):
        row = {}
        # exclude = ['schedule', 'tax']
        for c in self.__table__.columns:
            # if c.name not in exclude:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def to_dict_list(objs):
        return [o.to_dict() for o in objs]

    @staticmethod
    def get_all():
        objs = College.query.all()
        return [o.to_dict() for o in objs] if objs else []

    @staticmethod
    def add_to_db(raw):
        obj = College()
        obj.name = raw['name']
        obj.accreditation = raw['accreditation']
        obj.address = raw['address']
        obj.year = raw['year']
        obj.country = raw['country']

        db.session.add(obj)
        db.session.commit()
        return obj.to_dict()

    @staticmethod
    def get_College(schedule=None, tax=None):
        obj = None

        if schedule and tax:
            obj = College.query.filter(College.schedule == schedule, College.tax == tax).all()
        elif schedule:
            obj = College.query.filter_by(schedule=schedule).all()
        elif tax:
            obj = College.query.filter_by(tax=tax).all()
        return obj if obj is not None else []
コード例 #6
0
class Partner(db.Model):

    __tablename__ = 'partners'

    id = db.Column(db.Integer(), primary_key=True)
    company_name = db.Column(db.Unicode(100), nullable=False)
    contact_person = db.Column(db.Unicode(100), nullable=True)
    contact_phone = db.Column(db.Unicode(100), nullable=False)
    finances = db.Column(db.Integer(), nullable=False, default=0)
    activity = db.Column(db.Unicode(100), nullable=False)

    def get_data(self):
        row = {}
        for c in self.__table__.columns:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def get_by_id(_id):
        obj = Partner.query.filter_by(id=_id).first()
        return obj if obj is not None else False

    @staticmethod
    def update_by_id(raw):
        _id = raw['id']
        obj = Partner.get_by_id(_id)
        for r in raw:
            if hasattr(obj, r):
                setattr(obj, r, raw[r])
        db.session.commit()
        return obj.get_data()

    @staticmethod
    def delete_by_id(_id):
        obj = Partner.query.filter_by(id=_id).first()
        db.session.delete(obj)
        db.session.commit()
        return _id

    def to_dict(self):
        row = {}
        # exclude = ['schedule', 'tax']
        for c in self.__table__.columns:
            # if c.name not in exclude:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def to_dict_list(objs):
        return [o.to_dict() for o in objs]

    @staticmethod
    def get_all():
        objs = Partner.query.all()
        return [o.to_dict() for o in objs] if objs else []

    @staticmethod
    def add_to_db(raw):
        obj = Partner()
        obj.company_name = raw['company_name']
        obj.contact_person = raw['contact_person']
        obj.contact_phone = raw['contact_phone']
        obj.finances = raw['finances']
        obj.activity = raw['activity']

        db.session.add(obj)
        db.session.commit()
        return obj.to_dict()

    @staticmethod
    def get_Partner(schedule=None, tax=None):
        obj = None

        if schedule and tax:
            obj = Partner.query.filter(Partner.schedule == schedule,
                                       Partner.tax == tax).all()
        elif schedule:
            obj = Partner.query.filter_by(schedule=schedule).all()
        elif tax:
            obj = Partner.query.filter_by(tax=tax).all()
        return obj if obj is not None else []
コード例 #7
0
ファイル: require.py プロジェクト: didenko-yv/vntudb
class Require(db.Model):

    __tablename__ = 'requires'

    id = db.Column(db.Integer(), primary_key=True)
    college = db.Column(db.Unicode(100), nullable=False)
    program_type = db.Column(db.Unicode(100), nullable=True)
    progress = db.Column(db.Unicode(100), nullable=False)
    language = db.Column(db.Unicode(100), nullable=False)
    economy_region = db.Column(db.Unicode(100), nullable=False)
    year_study = db.Column(db.Integer(), nullable=False)

    def get_data(self):
        row = {}
        for c in self.__table__.columns:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def get_by_id(_id):
        obj = Require.query.filter_by(id=_id).first()
        return obj if obj is not None else []

    @staticmethod
    def update_by_id(raw):
        _id = raw['id']
        obj = Require.get_by_id(_id)
        for r in raw:
            if hasattr(obj, r):
                setattr(obj, r, raw[r])
        db.session.commit()
        return obj.get_data()

    @staticmethod
    def delete_by_id(_id):
        obj = Require.query.filter_by(id=_id).first()
        db.session.delete(obj)
        db.session.commit()
        return _id

    def to_dict(self):
        row = {}
        # exclude = ['schedule', 'tax']
        for c in self.__table__.columns:
            # if c.name not in exclude:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def to_dict_list(objs):
        return [o.to_dict() for o in objs]

    @staticmethod
    def get_all():
        objs = Require.query.all()
        return [o.to_dict() for o in objs] if objs else []

    @staticmethod
    def add_to_db(raw):
        obj = Require()
        obj.college = raw['college']
        obj.program_type = raw['program_type']
        obj.progress = raw['progress']
        obj.language = raw['language']
        obj.economy_region = raw['economy_region']
        obj.year_study = raw['year_study']

        db.session.add(obj)
        db.session.commit()
        return obj.to_dict()

    @staticmethod
    def get_Require(schedule=None, tax=None):
        obj = None

        if schedule and tax:
            obj = Require.query.filter(Require.schedule == schedule,
                                       Require.tax == tax).all()
        elif schedule:
            obj = Require.query.filter_by(schedule=schedule).all()
        elif tax:
            obj = Require.query.filter_by(tax=tax).all()
        return obj if obj is not None else []
コード例 #8
0
ファイル: student.py プロジェクト: didenko-yv/vntudb
class Student(db.Model):

    __tablename__ = 'students'

    id = db.Column(db.Integer(), primary_key=True)
    full_name = db.Column(db.Unicode(100), nullable=False)
    phone_number = db.Column(db.Unicode(100), nullable=True)
    program = db.Column(db.Unicode(100), nullable=False)
    college = db.Column(db.Unicode(100), nullable=False, default=0)
    specialization = db.Column(db.Unicode(100), nullable=False)
    year_study = db.Column(db.Integer(), nullable=False)
    foreign_language = db.Column(db.Unicode(100), nullable=False)
    progress = db.Column(db.Unicode(100), nullable=False)

    def get_data(self):
        row = {}
        for c in self.__table__.columns:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def get_by_id(_id):
        obj = Student.query.filter_by(id=_id).first()
        return obj if obj is not None else []

    @staticmethod
    def update_by_id(raw):
        _id = raw['id']
        obj = Student.get_by_id(_id)
        for r in raw:
            if hasattr(obj, r):
                setattr(obj, r, raw[r])
        db.session.commit()
        return obj.get_data()

    @staticmethod
    def delete_by_id(_id):
        obj = Student.query.filter_by(id=_id).first()
        db.session.delete(obj)
        db.session.commit()
        return _id

    def to_dict(self):
        row = {}
        # exclude = ['schedule', 'tax']
        for c in self.__table__.columns:
            # if c.name not in exclude:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def to_dict_list(objs):
        return [o.to_dict() for o in objs]

    @staticmethod
    def get_all():
        objs = Student.query.all()
        return [o.to_dict() for o in objs] if objs else []

    @staticmethod
    def add_to_db(raw):
        obj = Student()
        obj.full_name = raw['full_name']
        obj.phone_number = raw['phone_number']
        obj.program = raw['program']
        obj.specialization = raw['specialization']
        obj.college = raw['college']
        obj.year_study = raw['year_study']
        obj.foreign_language = raw['foreign_language']
        obj.progress = raw['progress']

        db.session.add(obj)
        db.session.commit()
        return obj.to_dict()

    @staticmethod
    def get_vacancy(schedule=None, tax=None):
        obj = None

        if schedule and tax:
            obj = Student.query.filter(Student.schedule == schedule,
                                       Student.tax == tax).all()
        elif schedule:
            obj = Student.query.filter_by(schedule=schedule).all()
        elif tax:
            obj = Student.query.filter_by(tax=tax).all()
        return obj if obj is not None else []
コード例 #9
0
ファイル: program.py プロジェクト: didenko-yv/vntudb
class Program(db.Model):

    __tablename__ = 'programs'

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.Unicode(100), nullable=False)
    num_students = db.Column(db.Integer(), nullable=True)
    organization = db.Column(db.Unicode(100), nullable=False)
    college = db.Column(db.Unicode(100), nullable=False, default=0)
    sponsor = db.Column(db.Unicode(100), nullable=False)
    chief = db.Column(db.Unicode(100), nullable=False)
    field = db.Column(db.Unicode(100), nullable=False)

    def get_data(self):
        row = {}
        for c in self.__table__.columns:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def get_by_id(_id):
        obj = Program.query.filter_by(id=_id).first()
        return obj if obj is not None else []

    @staticmethod
    def update_by_id(raw):
        _id = raw['id']
        obj = Program.get_by_id(_id)
        for r in raw:
            if hasattr(obj, r):
                setattr(obj, r, raw[r])
        db.session.commit()
        return obj.get_data()

    @staticmethod
    def delete_by_id(_id):
        obj = Program.query.filter_by(id=_id).first()
        db.session.delete(obj)
        db.session.commit()
        return _id

    def to_dict(self):
        row = {}
        # exclude = ['schedule', 'tax']
        for c in self.__table__.columns:
            # if c.name not in exclude:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def to_dict_list(objs):
        return [o.to_dict() for o in objs]

    @staticmethod
    def get_all():
        objs = Program.query.all()
        return [o.to_dict() for o in objs] if objs else []

    @staticmethod
    def add_to_db(raw):
        obj = Program()
        obj.name = raw['name']
        obj.num_students = raw['num_students']
        obj.organization = raw['organization']
        obj.college = raw['college']
        obj.sponsor = raw['sponsor']
        obj.chief = raw['chief']
        obj.field = raw['field']

        db.session.add(obj)
        db.session.commit()
        return obj.to_dict()

    @staticmethod
    def get_vacancy(schedule=None, tax=None):
        obj = None

        if schedule and tax:
            obj = Program.query.filter(Program.schedule == schedule, Program.tax == tax).all()
        elif schedule:
            obj = Program.query.filter_by(schedule=schedule).all()
        elif tax:
            obj = Program.query.filter_by(tax=tax).all()
        return obj if obj is not None else []
コード例 #10
0
ファイル: organization.py プロジェクト: didenko-yv/vntudb
class Organization(db.Model):

    __tablename__ = 'organization'

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.Unicode(100), nullable=False)
    year = db.Column(db.Integer(), nullable=True)
    web_site = db.Column(db.Unicode(127))
    chief = db.Column(db.Unicode(100), nullable=False)
    field = db.Column(db.Unicode(100), nullable=False, default=0)

    def get_data(self):
        row = {}
        for c in self.__table__.columns:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def get_by_id(_id):
        obj = Organization.query.filter_by(id=_id).first()
        return obj if obj is not None else []

    @staticmethod
    def update_by_id(raw):
        _id = raw['id']
        obj = Organization.get_by_id(_id)
        for r in raw:
            if hasattr(obj, r):
                setattr(obj, r, raw[r])
        db.session.commit()
        return obj.get_data()

    @staticmethod
    def delete_by_id(_id):
        obj = Organization.query.filter_by(id=_id).first()
        db.session.delete(obj)
        db.session.commit()
        return _id

    def to_dict(self):
        row = {}
        # exclude = ['schedule', 'tax']
        for c in self.__table__.columns:
            # if c.name not in exclude:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def to_dict_list(objs):
        return [o.to_dict() for o in objs]

    @staticmethod
    def get_all():
        objs = Organization.query.all()
        return [o.to_dict() for o in objs] if objs else []

    @staticmethod
    def add_to_db(raw):
        obj = Organization()
        obj.name = raw['name']
        obj.year = raw['year']
        obj.web_site = raw['web_site']
        obj.chief = raw['chief']
        obj.field = raw['field']

        db.session.add(obj)
        db.session.commit()
        return obj.to_dict()
コード例 #11
0
ファイル: fee.py プロジェクト: didenko-yv/vntudb
class Fee(db.Model):

    __tablename__ = 'fees'

    id = db.Column(db.Integer(), primary_key=True)
    program = db.Column(db.Unicode(100), nullable=False)
    course_price = db.Column(db.Integer(), nullable=False)
    grant = db.Column(db.Integer(), nullable=False, default=0)
    living_cost = db.Column(db.Integer(), nullable=False, default=0)
    additional_cost = db.Column(db.Integer(), nullable=False, default=0)

    def get_data(self):
        row = {}
        for c in self.__table__.columns:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def get_by_id(_id):
        obj = Fee.query.filter_by(id=_id).first()
        return obj if obj is not None else []

    @staticmethod
    def update_by_id(raw):
        _id = raw['id']
        obj = Fee.get_by_id(_id)
        for r in raw:
            if hasattr(obj, r):
                setattr(obj, r, raw[r])
        db.session.commit()
        return obj.get_data()

    @staticmethod
    def delete_by_id(_id):
        obj = Fee.query.filter_by(id=_id).first()
        db.session.delete(obj)
        db.session.commit()
        return _id

    def to_dict(self):
        row = {}
        # exclude = ['schedule', 'tax']
        for c in self.__table__.columns:
            # if c.name not in exclude:
            row[c.name] = getattr(self, c.name)
        return row

    @staticmethod
    def to_dict_list(objs):
        return [o.to_dict() for o in objs]

    @staticmethod
    def get_all():
        objs = Fee.query.all()
        return [o.to_dict() for o in objs] if objs else []

    @staticmethod
    def add_to_db(raw):
        obj = Fee()
        obj.program = raw['program']
        obj.course_price = raw['course_price']
        obj.grant = raw['grant']
        obj.living_cost = raw['living_cost']
        obj.additional_cost = raw['additional_cost']

        db.session.add(obj)
        db.session.commit()
        return obj.to_dict()

    @staticmethod
    def get_vacancy(schedule=None, tax=None):
        obj = None

        if schedule and tax:
            obj = Fee.query.filter(Fee.schedule == schedule,
                                   Fee.tax == tax).all()
        elif schedule:
            obj = Fee.query.filter_by(schedule=schedule).all()
        elif tax:
            obj = Fee.query.filter_by(tax=tax).all()
        return obj if obj is not None else []