class User(database.Model): __tablename__ = "user" id = database.Column(database.String(50), nullable=False, primary_key=True) password = database.Column(database.String(100), nullable=False) name = database.Column(database.String(30), nullable=False) rank = database.Column(database.String(50), nullable=False) group_num = database.Column(database.Integer, nullable=False) def __init__(self, id, password, name, rank, group_num): self.id = id self.password = password self.name = name self.rank = rank self.group_num = group_num self.is_authenticated = False def is_authenticated(self): return self.is_authenticated def is_active(self): return True def is_anonymous(self): return False def get_id(self): return self.id
class Todo(database.Model): __tablename__ = "todo" no = database.Column(database.Integer, primary_key=True) name = database.Column(database.String(30), nullable=False) title = database.Column(database.String(200), nullable=False) date_y = database.Column(database.Integer, nullable=False) date_m = database.Column(database.Integer, nullable=False) date_d = database.Column(database.Integer, nullable=False) body = database.Column(database.Text, nullable=True) level = database.Column(database.Integer, nullable=False) id = database.Column(database.String(50), database.ForeignKey("user.id"), nullable=False) progress = database.Column(database.Integer, nullable=False) privacy = database.Column(database.Integer, nullable=False) group_num = database.Column(database.Integer, nullable=False) def __init__(self, id, name, title, date_y, date_m, date_d, body, level, progress, privacy, group_num): self.id = id self.name = name self.title = title self.date_y = date_y self.date_m = date_m self.date_d = date_d self.body = body self.level = level self.progress = progress self.privacy = privacy self.group_num = group_num
class Groups(database.Model): __tablename__ = "groups" group_num = database.Column(database.Integer, nullable=False, primary_key=True) group_name = database.Column(database.String(30), nullable=False) group_code = database.Column(database.String(30), nullable=False) privacy = database.Column(database.Integer, nullable=False) def __init__(self, group_num, group_name, group_code, privacy): self.group_num = group_num self.group_name = group_name self.group_code = group_code self.privacy = privacy
class Device(database.Model): __tablename__ = "device" device_id = database.Column(database.String(30), nullable=False, primary_key=True) phone_number = database.Column(database.String(30), nullable=False) carrier = database.Column(database.String(30), nullable=False) state = database.Column(database.String(3), nullable=False) description = database.Column(database.String(100), nullable=True) def __init__(self, device_id, phone_number, carrier, state, description): self.device_id = device_id self.phone_number = phone_number self.carrier = carrier self.state = state self.description = description
class User(database.Model): __tablename__ = "user" user_id = database.Column(database.String(30), nullable=False, primary_key=True) user_pw = database.Column(database.String(100), nullable=False) user_name = database.Column(database.String(30), nullable=False) phone_number = database.Column(database.String(30), nullable=False) department = database.Column(database.String(30), nullable=True) roles = database.Column(database.String(30), nullable=True) state = database.Column(database.String(5), nullable=True) def __init__(self, user_id, user_pw, user_name, phone_number, department, roles, state): self.user_id = user_id self.user_pw = user_pw, self.user_name = user_name, self.phone_number = phone_number, self.department = department, self.roles = roles, self.state = state def is_authenticated(self): return self.is_authenticated def is_active(self): return True def is_anonymous(self): return False def get_user_id(self): return self.user_id
class Rent(database.Model): __tablename__ = "rent" rent_id = database.Column(database.String(30), nullable=False, primary_key=True) user_id = database.Column(database.String(30), database.ForeignKey("user.user_id"), nullable=False) device_id = database.Column(database.String(30), database.ForeignKey("device.device_id"), nullable=False) start_date = database.Column(database.String(30), nullable=False) deadline_date = database.Column(database.String(30), nullable=False) state = database.Column(database.Integer, nullable=False) return_date = database.Column(database.String(30), nullable=True) def __init__(self, rent_id, user_id, device_id, start_date, deadline_date, state, return_date): self.rent_id = rent_id self.user_id = user_id self.device_id = device_id self.start_date = start_date self.deadline_date = deadline_date self.state = state self.return_date = return_date