old_contents: """
  General project models used.
  These may get moved to a blueprint/package at any time
  """
  from school.extensions import db
  from sqlalchemy import Column, Integer, String, ForeignKey, Boolean, PrimaryKeyConstraint
  
  
  class Course(db.Model):
      __tablename__ = "courses"
  
      id = Column(Integer, primary_key=True)
      name = Column(String(64), nullable=False)
      is_optional = Column(Boolean, default=False)  # is course optional
  
  
  class Semester(db.Model):
      __tablename__ = "semesters"
  
      id = Column(Integer, primary_key=True)
      name = Column(String(64), nullable=False)
      year = Column(Integer)
  
  # keep track of each student in what group, could just keep a column in users table
  # but it would complicate things with roles, as teachers, admins do not have groups associated with it
  group_students = db.Table(
      "group_students",
      Column("group_id", Integer, ForeignKey("groups.id"), nullable=False),
      Column("student_id", Integer, ForeignKey("users.id"), nullable=False, unique=True),
      PrimaryKeyConstraint('group_id', 'student_id')  # a student can be in only one group at a time
  )
  
  
  class Group(db.Model):
      __tablename__ = "groups"
  
      id = Column(Integer, primary_key=True)
      name = Column(String(64), nullable=False)  # 911, G922
      students = db.relationship("User",
                                 secondary=group_students,
                                 backref=db.backref("group", lazy="dynamic"))
  
  
  
new_contents: """
  General project models used.
  These may get moved to a blueprint/package at any time
  """
  from school.extensions import db
  from sqlalchemy import Column, Integer, String, ForeignKey, \
      Date, SmallInteger, Boolean, PrimaryKeyConstraint
  
  
  class Course(db.Model):
      __tablename__ = "courses"
  
      id = Column(Integer, primary_key=True)
      name = Column(String(64), nullable=False)
      is_optional = Column(Boolean, default=False)  # is course optional
  
  
  class Semester(db.Model):
      __tablename__ = "semesters"
  
      id = Column(Integer, primary_key=True)
      name = Column(String(64), nullable=False)  # human readable semester name
      year = Column(Integer)  # the semester year, 2014, 2015
      date_start = Column(Date)  # september 2014
      date_end = Column(Date)    # june 2015
  
  # keep track of each student in what group, could just keep a column in users table
  # but it would complicate things with roles, as teachers, admins do not have groups associated with it
  group_students = db.Table(
      "group_students",
      Column("group_id", Integer, ForeignKey("groups.id"), nullable=False),
      Column("student_id", Integer, ForeignKey("users.id"), nullable=False, unique=True),
      PrimaryKeyConstraint('group_id', 'student_id')  # a student can be in only one group at a time
  )
  
  
  class Group(db.Model):
      __tablename__ = "groups"
  
      id = Column(Integer, primary_key=True)
      name = Column(String(64), nullable=False)  # 911, G922
      students = db.relationship("User",
                                 secondary=group_students,
                                 backref=db.backref("group", lazy="dynamic"))
  
  
  # every department can have multiple degrees
  # example: Math and Computer Science department can Have Computer Science in English, Math in Romanian
  department_degrees = db.Table(
      "departments_degrees",
      Column("department_id", Integer, ForeignKey("departments.id"), nullable=False),
      Column("degree_id", Integer, ForeignKey("degrees.id"), nullable=False),
      PrimaryKeyConstraint('department_id', 'degree_id')
  )
  
  
  class Department(db.Model):
      __tablename__ = "departments"
  
      id = Column(Integer, primary_key=True)
      name = Column(String(64), nullable=False)
      degrees = db.relationship("Degree",
                                secondary=department_degrees,
                                backref=db.backref("departments", lazy="dynamic"))
  
  
  class DegreeType:
      UNDERGRADUATE = 1
      GRADUATE = 2
  
  # study_languages = db.Table(
  #     "degree_languages",
  #     Column("degree_id", Integer, ForeignKey("degrees.id"), nullable=False),
  #     Column("semester_id", Integer, ForeignKey("semesters.id"), nullable=False),
  # )
  
  
  class Degree(db.Model):
      __tablename__ = "degrees"
  
      id = Column(Integer, primary_key=True)
      name = Column(String(64), nullable=False)
      type_id = Column(SmallInteger, default=DegreeType.UNDERGRADUATE)
  
      def is_undergraduate(self):
          return self.type_id == DegreeType.UNDERGRADUATE
  
      def is_graduate(self):
          return self.type_id == DegreeType.GRADUATE
  
  
  class Language(db.Model):
      __tablename__ = "languages"
  
      id = Column(Integer, primary_key=True)
      name = Column(String(64), nullable=False)
  
subject: Add Department, Degree, Language Model.