Пример #1
0
class RecruitStatus(db.Model):

    __tablename__ = 'etl_recruit_status'

    id = db.Column(db.String(50), db.ForeignKey(Recruit.id), primary_key=True)
    recruit = db.relationship(Recruit, uselist=False, back_populates="status")
    status = db.Column(db.String(100))
    study_id = db.Column(db.String(100))
    first_name = db.Column(db.String(100))
    last_name = db.Column(db.String(100))
    processed_by = db.Column(db.String(500))
    processed_date = db.Column(db.Date)
    invoice_year = db.Column(db.String(50))
    invoice_quarter = db.Column(db.String(50))
    reimbursed_status = db.Column(db.String(50))

    @property
    def full_name(self):
        return '{} {}'.format(self.first_name or '', self.last_name or '')

    @property
    def invoice_period(self):
        return '{} {}'.format(
            self.invoice_year or '',
            self.invoice_quarter or '')
Пример #2
0
class Tag(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Unicode(64))
    slug = db.Column(db.String(255), nullable=False)

    def __repr__(self):
        return f"{self.name}"
Пример #3
0
class PracticeStatus(db.Model):

    __tablename__ = 'practice_status'

    id = db.Column(db.Integer, primary_key=True, nullable=False)
    value = db.Column(db.Integer, nullable=False)
    name = db.Column(db.String, nullable=False)
Пример #4
0
class Subscribers(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(120), unique=True, nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)

    def __repr__(self):
        return "Hubungi('{self.email}', '{self.date_posted}')"
Пример #5
0
class Kelas(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nama = db.Column(db.String(255), nullable=False)
    siswas = db.relationship('Siswa', backref='kelas_siswa', lazy=True)
    jadwal_kelas = db.relationship('JadwalMapel',
                                   backref='jadwal_kelas',
                                   lazy=True)
Пример #6
0
class Mapel(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nama = db.Column(db.String(255), nullable=False)
    absen_mapel = db.relationship('Absen', secondary='kehadiran')
    jadwal_mapel = db.relationship('JadwalMapel',
                                   backref='jadwal_mapel',
                                   lazy=True)
Пример #7
0
class JenisKelamin(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    kelamin = db.Column(db.String(255), nullable=False)
    siswas = db.relationship('Siswa', backref='kelamin', lazy=True)
    guru = db.relationship('Guru', backref='kelamin_guru', lazy=True)

    def __repr__(self):
        return "Post('{self.kelamin}')"
Пример #8
0
class Agama(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    agama = db.Column(db.String(255), nullable=False)
    siswas = db.relationship('Siswa', backref='agama_siswa', lazy=True)
    guru = db.relationship('Guru', backref='agama_guru', lazy=True)

    def __repr__(self):
        return "Post('{self.agama}')"
Пример #9
0
class Hubungi(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nama = db.Column(db.String(255), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    pesan = db.Column(db.TEXT, nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)

    def __repr__(self):
        return "Hubungi('{self.nama}', '{self.date_posted}')"
Пример #10
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    content = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f"Post('{self.title}', '{self.date_posted}')"
Пример #11
0
class Role(db.Model, RoleMixin):
    ADMIN_ROLENAME = 'admin'

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))

    def __str__(self):
        return self.name
Пример #12
0
class Kategori(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    slug = db.Column(db.String(255), nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    posts = db.relationship('Post', backref='category', lazy=True)

    def __repr__(self):
        return "Post('{self.nama_kategori}', '{self.date_posted}')"
Пример #13
0
class Role(db.Model, RoleMixin):
    ADMIN_ROLENAME = 'admin'

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))

    def __init__(self, *args, **kwargs):
        self.name = kwargs.get('name')
        self.description = kwargs.get('description')
Пример #14
0
class NilaiUjian(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    siswa_id = db.Column(db.Integer, db.ForeignKey('siswa.id'), nullable=False)
    jadwal_ujian_id = db.Column(db.Integer,
                                db.ForeignKey('jadwal_ujian.id'),
                                nullable=False)
    nilai = db.Column(db.Float)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
Пример #15
0
class PracticeRegistration(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String, db.ForeignKey(Practice.code))
    date_created = db.Column(db.DateTime, nullable=False)
    practice = db.relationship(Practice)

    def __init__(self, *args, **kwargs):
        self.code = kwargs.get('code')
        self.date_created = datetime.datetime.now()
Пример #16
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20), nullable=False, default='default.png')
    password = db.Column(db.String(60), nullable=False)
    last_seen = db.Column(db.DateTime, default=datetime.utcnow)
    is_admin = db.Column(db.Boolean, default=False)
    is_manager = db.Column(db.Boolean, default=False)
    is_active = db.Column(db.Boolean, default=False)
    posts = db.relationship('Post', backref='author', lazy=True)
    def get_reset_token(self,expires_sec=1800):
        s = Serializer(app.config['SECRET_KEY'],expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id) 

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Пример #17
0
class Practice(db.Model):

    __tablename__ = 'etl_practice'

    code = db.Column(db.String, primary_key=True)
    name = db.Column(db.String, nullable=False)
    ccg_name = db.Column(db.String, nullable=True)
    address = db.Column(db.String, nullable=True)
    delegates = db.relationship(
        "Delegate",
        back_populates="practice")
Пример #18
0
class UangSpp(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nilai = db.Column(
        db.Numeric(precision=8, asdecimal=False, decimal_return_scale=None))
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    edit_posted = db.Column(db.DateTime)
    pembayaran_spp = db.relationship('PembayaranSpp',
                                     backref='pembayaran_spp',
                                     lazy=True)
Пример #19
0
class Tag(db.Model):
    __tablename__ = 'tag'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), unique=True, index=True)

    @staticmethod
    def insert_tags():
        default_tags = ['diagram', 'uml', 'flow_chat']
        for strTag in default_tags:
            tag = Tag(name=strTag)
            db.session.add(tag)
        db.session.commit()
Пример #20
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    register_on = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    activate_on = db.Column(db.DateTime)
    roles_id = db.Column(db.Integer,
                         db.ForeignKey('role.id'),
                         nullable=False,
                         default=1)
    guru = db.relationship('Kehadiran', lazy='dynamic', backref='guru')

    def get_reset_token(self, expires_sec=1800):
        s = Serializer(app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id)

    def __repr__(self):
        return "User('{self.username}', '{self.email}', '{self.image_file}')"
Пример #21
0
class Role(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20), nullable=False)
    users = db.relationship('User', backref='role', lazy=True)

    @staticmethod
    def insert_roles():
        roles = ['admin', 'moderator', 'writer']
        for r in roles:
            role = Role.query.filter_by(name=r).first()
            if role is None:
                role = Role(name=r)
            db.session.add(role)
        db.session.commit()
Пример #22
0
class TargetSet(db.Model): 
    __tablename__ = 'targetset'
    id = db.Column(db.Integer, primary_key=True) 
    name = db.Column(db.String(255)) 
    target = db.relationship('Target', backref='ts', lazy='dynamic') # to establish .targetset attribute on child Target which will refer to parent TargetSet as target.targetset (backref can not be the same as the child column name)
    
    def __init__(self, name): 
        self.name = name 
 
    def __repr__(self): 
        #return '<Target Sets %d>'.format(self.id)
        return f'{self.name}'
     
    def __str__(self):
        return f'{self.name}'    
Пример #23
0
class Target(db.Model): 
    __tablename__ = 'target'
    id = db.Column(db.Integer, primary_key=True) 
    target = db.Column(db.String(255)) 
    targetset_id = db.Column(db.Integer, db.ForeignKey('targetset.id')) 
     
    def __init__(self, target, targetset_id): 
        self.target = target
        self.targetset_id = targetset_id 
 
    def __repr__(self): 
        #return '<Targets %d>'.format(self.id)
        return f'{self.targetset_id}: {self.target}'

    def __str__(self):
        return f'{self.target}'
Пример #24
0
class JadwalMapel(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    mapel_id = db.Column(db.Integer, db.ForeignKey('mapel.id'), nullable=False)
    kelas_id = db.Column(db.Integer, db.ForeignKey('kelas.id'), nullable=False)
    guru_id = db.Column(db.Integer, db.ForeignKey('guru.id'), nullable=False)
    hari = db.Column(db.String(8), nullable=False)
    mulai = db.Column(db.Time, nullable=False)
    akhir = db.Column(db.Time, nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
Пример #25
0
class Page(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(255), nullable=False)
    content = db.Column(db.Text, nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    on_update = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
    slug = db.Column(db.String(255), nullable=False)
    publish = db.Column(db.Boolean(), nullable=False, server_default='1')
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return "Post('{self.title}', '{self.date_posted}')"
Пример #26
0
class Guru(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nama = db.Column(db.String(255), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    tgl_lahir = db.Column(db.DateTime, nullable=False)
    agama_id = db.Column(db.Integer, db.ForeignKey('agama.id'), nullable=False)
    jenis_kelamin_id = db.Column(db.Integer,
                                 db.ForeignKey('jenis_kelamin.id'),
                                 nullable=False)
    alamat = db.Column(db.Text, nullable=False)
    image_thumb = db.Column(db.String(255),
                            nullable=False,
                            default='default.jpg')
    slug = db.Column(db.String(255), nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    jadwal_mapel = db.relationship('JadwalMapel',
                                   backref='jadwal_guru',
                                   lazy=True)
Пример #27
0
class Diagram(db.Model):
    __tablename__ = 'diagram'
    diagram_id = db.Column(db.Integer, primary_key=True)
    diagram_name = db.Column(db.String(256), unique=True)
    diagram_type = db.Column(db.String)

    diagram_script = db.Column(db.Text)

    script_path = db.Column(db.String)
    image_path = db.Column(db.String)
    author_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    tag_id = db.Column(db.Integer, db.ForeignKey('tag.id'))

    create_time = db.Column(db.DateTime, default=datetime.utcnow)
    update_time = db.Column(db.DateTime, default=datetime.utcnow)

    def __repr__(self):
        return "<Diagram diagram_name={}, diagram_script={}, image_path={}".format(
                                                self.diagram_name,
                                                self.diagram_script,
                                                self.image_path)
Пример #28
0
class StaffMember(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    practice_registration_id = db.Column(
        db.Integer,
        db.ForeignKey(PracticeRegistration.id))
    first_name = db.Column(db.String, nullable=False)
    last_name = db.Column(db.String, nullable=False)
    date_created = db.Column(db.DateTime, nullable=False)
    practice_registration = db.relationship(
        PracticeRegistration,
        backref=db.backref('staff', cascade="all, delete-orphan"))

    def __init__(self, *args, **kwargs):
        self.practice_registration_id = kwargs.get('practice_registration').id
        self.first_name = kwargs.get('first_name')
        self.last_name = kwargs.get('last_name')
        self.date_created = datetime.datetime.now()

    def full_name(self):
        return '{} {}'.format(self.first_name or '', self.last_name or '')
Пример #29
0
class Comments(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    email = db.Column(db.String(120))
    website = db.Column(db.String(255))
    comment = db.Column(db.Text, nullable=False)
    reply_id = db.Column(db.Integer, db.ForeignKey('comments.id'))
    date_comment = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    publish = db.Column(db.Boolean())
    post_id = db.Column(db.Integer, db.ForeignKey('post.id'), nullable=False)
    children = db.relationship('Comments', backref=db.backref('reply', remote_side=[id]))

    def avatar(self, size):
        digest = md5(self.email.lower().encode('utf-8')).hexdigest()
        return f'https://www.gravatar.com/avatar/{digest}?d=identicon&s={size}'

    def __repr__(self):
        return "Comments('{self.comment}', '{self.date_comment}')"
Пример #30
0
class PracticeGroup(db.Model):

    __tablename__ = 'etl_practice_group'
    project_id = db.Column(db.Integer, primary_key=True, nullable=False)
    identifier = db.Column(db.String, primary_key=True, nullable=False)
    type = db.Column(db.String, primary_key=True, nullable=False)
    name = db.Column(db.String, nullable=False)

    practices = db.relationship(
        'Practice',
        secondary=practice_groups_practices,
        backref=db.backref('groups', lazy='dynamic'),
        collection_class=set,
    )

    def __str__(self):
        return f"{self.type}: {self.name}"

    __mapper_args__ = {
        "polymorphic_identity": "PracticeGroup",
        "polymorphic_on": type,
    }