class User(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80)) password = db.Column(db.String(40)) email = db.Column(db.String(255), unique=True) committees = db.relationship('Committee', secondary=users_committees_table, backref=db.backref('members', lazy='dynamic')) def __init__(self, name, password, email): self.name = name self.set_password(password) self.email = email def is_authenticated(self): return True def is_active(self): return True def is_anonymous(self): return False def get_id(self): return self.id def set_password(self, password): self.password = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password, password)
class Committee(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80)) admin = db.Column(db.Boolean) def __init__(self, name, admin=False): self.name = name self.admin = admin
class Todo(db.Model): id = db.Column(db.Integer, primary_key=True) content = db.Column(db.String(200), nullable=False) details = db.Column(db.String(1000), nullable=False) complete = db.Column(db.Boolean) date_created = db.Column(db.DateTime, default=datetime.utcnow()) def __repr__(self): return '<Task %r>' % self.id
class Entry(db.Model): id = db.Column(db.Integer, primary_key=True) form_id = db.Column(db.Integer, db.ForeignKey('form.id')) timestamp = db.Column(db.DateTime) values = db.relationship('EntryValue') def __init__(self, form_id): self.form_id = form_id self.timestamp = datetime.utcnow()
class Form(db.Model): id = db.Column(db.Integer, primary_key=True) activity_id = db.Column(db.Integer, db.ForeignKey('activity.id')) deadline = db.Column(db.DateTime, nullable=True) fields = db.relationship('Field', backref='form', lazy='dynamic') entries = db.relationship('Entry', backref='form', lazy='dynamic') def __init__(self, activity_id, deadline=None): self.activity_id = activity_id self.deadline = deadline
class EntryValue(db.Model): id = db.Column(db.Integer, primary_key=True) entry_id = db.Column(db.Integer, db.ForeignKey('entry.id')) field_id = db.Column(db.Integer, db.ForeignKey('field.id')) value = db.Column(db.String) def __init__(self, field, value, entry): self.entry = entry_id self.field = field_id self.value = value
class ElectronicApplicant(Applicant): __tablename__ = 'ElectronicApplicants' altium_designer = db.Column(db.Boolean, nullable=True, default=False) arduino = db.Column(db.Boolean, nullable=True, default=False) code_vision = db.Column(db.Boolean, nullable=True, default=False) proteus = db.Column(db.Boolean, nullable=True, default=False) atmel_studio = db.Column(db.Boolean, nullable=True, default=False) microcontroller = db.Column(db.Boolean, nullable=True, default=False) power = db.Column(db.Boolean, nullable=True, default=False) others = db.Column(db.Text, nullable=True) resume = db.Column(db.LargeBinary, nullable=True) expected_salary = db.Column(db.String(7), nullable=True)
class Activity(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80)) description = db.Column(db.String) committee_id = db.Column(db.Integer, db.ForeignKey('committee.id')) location = db.Column(db.String(80)) start_time = db.Column(db.DateTime) end_time = db.Column(db.DateTime, nullable=True) def __init__(self, name, description, committee_id, location, start_time, end_time=None): self.name = name self.description = description self.committee_id = committee_id self.location = location self.start_time = start_time self.end_time = end_time
class Field(db.Model): id = db.Column(db.Integer, primary_key=True) form_id = db.Column(db.Integer, db.ForeignKey('form.id')) label = db.Column(db.String(80)) display_index = db.Column(db.Integer) data_type = db.Column(db.Integer) required = db.Column(db.Boolean) __table_args__ = (db.UniqueConstraint('form_id', 'display_index'), ) def __init__(self, form_id, label, display_index, data_type, required=True): self.form_id = form_id self.label = label self.display_index = display_index self.data_type = data_type self.required = required
from forms import db from datetime import datetime from werkzeug.security import generate_password_hash, check_password_hash users_committees_table = db.Table( 'users_committees', db.Column('user', db.Integer, db.ForeignKey('user.id')), db.Column('committee', db.Integer, db.ForeignKey('committee.id'))) class User(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80)) password = db.Column(db.String(40)) email = db.Column(db.String(255), unique=True) committees = db.relationship('Committee', secondary=users_committees_table, backref=db.backref('members', lazy='dynamic')) def __init__(self, name, password, email): self.name = name self.set_password(password) self.email = email def is_authenticated(self): return True def is_active(self): return True def is_anonymous(self):
class Applicant(db.Model): __tablename__ = 'applicants' pk = db.Column(db.Integer, primary_key=True) first_name = db.Column(db.String(30), nullable=False) last_name = db.Column(db.String(45), nullable=False) national_id = db.Column(db.String(10), unique=True, nullable=False) age = db.Column(db.Integer, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) mobile_phone = db.Column(db.String(11), unique=True, nullable=False) Address = db.Column(db.Text) university = db.Column(db.String(80), nullable=False) university_subject = db.Column(db.String(50), nullable=False) university_degree = db.Column(db.Enum(UniversityDegreeEnum), default=UniversityDegreeEnum.diploma, nullable=True ) work_reputations = db.Column(db.Text, nullable=True) def __repr__(self): return f'{self.first_name} {self.last_name}'