Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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))
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
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)
Esempio n. 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())
Esempio n. 10
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)
Esempio n. 11
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"),