Пример #1
0
class Grade(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    number = db.Column(db.Integer, unique=False, nullable=False)
    letter = db.Column(db.String(1), unique=False, nullable=False)
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
Пример #2
0
class CallSchedule(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
    subject_number = db.Column(db.Integer, nullable=False, unique=False)
    start = db.Column(db.String(5), nullable=False, unique=False)
    end = db.Column(db.String(5), nullable=False, unique=False)
Пример #3
0
class Request(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    region = db.Column(db.String(50), unique=False, nullable=False)
    city = db.Column(db.String(50), unique=False, nullable=False)
    school = db.Column(db.String(80), unique=False, nullable=False)
    name = db.Column(db.String(30), unique=False, nullable=False)
    surname = db.Column(db.String(30), unique=False, nullable=False)
    patronymic = db.Column(db.String(30), unique=False, nullable=False)
    email = db.Column(db.String(50), unique=True, nullable=False)
    password_hash = db.Column(db.String(128), unique=True, nullable=False)
Пример #4
0
class Student(User, db.Model):
    grade_id = db.Column(db.Integer, db.ForeignKey("grade.id"), nullable=False)
    grade = db.relationship("Grade", backref=db.backref("students", lazy=True))
    parent_id = db.Column(db.Integer,
                          db.ForeignKey("parent.id"),
                          nullable=False)
    parent = db.relationship("Parent",
                             backref=db.backref("children"),
                             lazy=True)
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
    school = db.relationship("School",
                             backref=db.backref("students"),
                             lazy=True)
Пример #5
0
class Teacher(User, db.Model):
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
    school = db.relationship("School",
                             backref=db.backref("teachers"),
                             lazy=True)
    homeroom_grade_id = db.Column(db.Integer,
                                  db.ForeignKey("grade.id"),
                                  nullable=True)
    homeroom_grade = db.relationship("Grade",
                                     backref=db.backref("homeroom_teacher"),
                                     lazy=True)
    subjects = db.relationship("Subject",
                               secondary=teacher_subjects,
                               backref=db.backref("teachers", lazy=True))
Пример #6
0
class Parent(User, db.Model):
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
    school = db.relationship("School",
                             backref=db.backref("parents"),
                             lazy=True)
Пример #7
0
class User:
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), unique=False, nullable=False)
    surname = db.Column(db.String(30), unique=False, nullable=False)
    patronymic = db.Column(db.String(30), unique=False, nullable=False)
    email = db.Column(db.String(50), unique=True, nullable=False)
    login = db.Column(db.String(31), unique=True, nullable=False)
    password_hash = db.Column(db.String(128), unique=False, nullable=False)
    throwaway_password = db.Column(db.Boolean, default=True)
Пример #8
0
class Message(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    sender_id = db.Column(db.Integer, nullable=False, unique=False)
    sender_role = db.Column(db.String(11), nullable=False, unique=False)
    recipient_role = db.Column(db.String(11), nullable=False, unique=False)
    recipient_id = db.Column(db.Integer, nullable=False, unique=False)
    text = db.Column(db.Text, unique=False, nullable=False)
    date = db.Column(db.DateTime,
                     nullable=False,
                     default=lambda: datetime.now())
    read = db.Column(db.Boolean, nullable=False, default=False)
Пример #9
0
class Announcement(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
    author_id = db.Column(db.Integer, nullable=False, unique=False)
    author_role = db.Column(db.String(11), nullable=False, unique=False)
    header = db.Column(db.String(80), nullable=False, unique=False)
    text = db.Column(db.Text, unique=False, nullable=False)
    for_users = db.Column(db.String(34), unique=False, nullable=False)
    date = db.Column(db.DateTime,
                     nullable=False,
                     default=lambda: datetime.now())
Пример #10
0
class SubjectDescription(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    subject_id = db.Column(db.Integer,
                           db.ForeignKey("subject.id"),
                           nullable=False)
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
    date = db.Column(db.DateTime, nullable=False)
    grade_id = db.Column(db.Integer, db.ForeignKey("grade.id"), nullable=False)
    grade = db.relationship("Grade", backref="subject_descriptions", lazy=True)
    subject = db.relationship("Subject",
                              backref="subject_descriptions",
                              lazy=True)
    theme = db.Column(db.Text, nullable=False, unique=False)
    homework = db.Column(db.Text, nullable=False, unique=False)
Пример #11
0
class Marks(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    mark = db.Column(db.Integer, nullable=True, unique=False)
    attendance = db.Column(db.Text, nullable=True, unique=False)
    subject_id = db.Column(db.Integer,
                           db.ForeignKey("subject_description.id"),
                           nullable=False)
    student_id = db.Column(db.Integer,
                           db.ForeignKey("student.id"),
                           nullable=False)
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
    subject = db.relationship("SubjectDescription", backref="marks", lazy=True)
    student = db.relationship("Student", backref="marks", lazy=True)
Пример #12
0
class Schedule(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    day = db.Column(db.Integer, unique=False, nullable=False)
    subject_number = db.Column(db.Integer, unique=False, nullable=False)
    subject_id = db.Column(db.Integer,
                           db.ForeignKey("subject.id"),
                           nullable=False)
    subject = db.relationship("Subject", backref="schedule", lazy=True)
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
    teacher_id = db.Column(db.Integer,
                           db.ForeignKey("teacher.id"),
                           nullable=False)
    teacher = db.relationship("Teacher",
                              backref=db.backref("schedule"),
                              lazy=True)
    grade_id = db.Column(db.Integer, db.ForeignKey("grade.id"), nullable=False)
    grade = db.relationship("Grade", backref="subjects", lazy=True)
Пример #13
0
class Subject(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(25), unique=False, nullable=False)
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),
                          nullable=False)
Пример #14
0
class School(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    region = db.Column(db.String(50), unique=False, nullable=False)
    city = db.Column(db.String(50), unique=False, nullable=False)
    school = db.Column(db.String(80), unique=False, nullable=False)
Пример #15
0
from okayjournal.app import db
from datetime import datetime
from werkzeug.security import generate_password_hash

# Many-to-Many relationships

teacher_subjects = db.Table(
    "teacher_subjects",
    db.Column("teacher_id", db.Integer, db.ForeignKey("teacher.id")),
    db.Column("subject_id", db.Integer, db.ForeignKey("subject.id")),
)


class User:
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), unique=False, nullable=False)
    surname = db.Column(db.String(30), unique=False, nullable=False)
    patronymic = db.Column(db.String(30), unique=False, nullable=False)
    email = db.Column(db.String(50), unique=True, nullable=False)
    login = db.Column(db.String(31), unique=True, nullable=False)
    password_hash = db.Column(db.String(128), unique=False, nullable=False)
    throwaway_password = db.Column(db.Boolean, default=True)


class SystemAdmin(User, db.Model):
    pass


class Parent(User, db.Model):
    school_id = db.Column(db.Integer,
                          db.ForeignKey("school.id"),