예제 #1
0
class JoinClassroom(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    user_id = db.Column(db.Integer, nullable=False)
    classroom_id = db.Column(db.Integer, nullable=False)
    join_date = db.Column(db.Date, nullable=False)

    def __repr__(self):
        return f"{self.id}, {self.user_id}, {self.classroom_id}, {self.join_date}"
예제 #2
0
class ConversationThread(db.Model):
    id = db.Column(db.String, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    created_at = db.Column(db.Date, default=datetime.datetime.utcnow)
    isClosed = db.Column(db.Boolean, default=False)

    def __repr__(self):
        return f"{self.id}, {self.user_id}, {self.created_at}"
예제 #3
0
class Quiz(db.Model):
    id = db.Column(db.String, primary_key=True)
    classroom_id = db.Column(db.Integer,
                             db.ForeignKey('classroom.classroom_id'),
                             nullable=False)
    created_at = db.Column(db.Date, default=datetime.datetime.utcnow)

    def __repr__(self):
        return f"{self.id}, {self.classroom_id}, {self.created_at}"
예제 #4
0
class User(db.Model, UserMixin):
  id = db.Column(db.Integer, primary_key = True)
  first_name = db.Column(db.String(64), nullable = False)
  last_name = db.Column(db.String(64), nullable = False)
  email = db.Column(db.String(64), unique = True, nullable = False)
  password = db.Column(db.String(60), nullable = False) # flaskApi bcrypt (60 length)
  image_file = db.Column(db.String(20), nullable = False, default = 'default.jpg')
  role = db.Column(db.String(32), nullable = False, default = 'pending')
  date_created = db.Column(db.DateTime, nullable = False, default = datetime.utcnow)

  # Setting up a timed reset password token with app['SECRET_KEY'] and expiration time
  def get_reset_password_token(self, expire_sec = 300):
    s = Serializer(app.config['SECRET_KEY'], expire_sec)
    # Returning the token with the payload of (User) 'id'
    return s.dumps({'user_id': self.id}).decode('utf-8')

  @staticmethod
  def verify_password_reset_token(token):
    s = Serializer(app.config['SECRET_KEY'])
    # Token could be invalid/timed out, causing an exception
    try:
      user_id = s.loads(token)['user_id']
      return User.query.get(user_id)
    except:
      return None

  # Object's repr print for debuging
  def __repr__(self):
    return f"User('{self.id}', '{self.first_name}', '{self.last_name}', '{self.email}', {self.role}', '{self.date_created}')"
예제 #5
0
class Message(db.Model):
    """docstring for Message."""
    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.String(64))

    def to_dict(self):
        data = {'id': self.id, 'body': self.body}
        return data

    def from_dict(self, data):
        for field in "body":
            if field in data:
                setattr(self, field, data[field])

    def __repr__(self):
        return '<{} : {}>'.format(self.body, self.body)
예제 #6
0
class Task(db.Model):
    """docstring for Task."""
    id = db.Column(db.Integer, primary_key=True)
    longDescription = db.Column(db.String(64))

    def to_dict(self):
        data = {'id': self.id, 'longDescription': self.longDescription}
        return data

    def from_dict(self, data):
        for field in "longDescription":
            if field in data:
                setattr(self, field, data[field])

    def __repr__(self):
        return '<{} : {}>'.format(self.body, self.longDescription)
예제 #7
0
class submittedAssignments(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    assignment_id = db.Column(db.Integer, nullable=False)
    file_path = db.Column(db.String, nullable=False)
    student_id = db.Column(db.Integer, nullable=False)
    grade = db.Column(db.String)
    graded_date = db.Column(db.Date)
    is_submitted = db.Column(db.Boolean, nullable=False)
    remarks = db.Column(db.String)
    is_returned = db.Column(db.Boolean)

    def __repr__(self):
        return f"{self.id}, {self.assignment_id}, {self.file_path}, {self.student_id}, {self.grade}, {self.graded_date}, {self.is_submitted}, {self.remarks}, {self.is_returned}"
예제 #8
0
class Classroom(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    classroom_name = db.Column(db.String, nullable=False)
    classroom_id = db.Column(db.String, unique=True, nullable=False)
    teacher_id = db.Column(db.Integer, nullable=False)
    classroom_link = db.Column(db.String, nullable=False)
    subject = db.Column(db.String)
    section = db.Column(db.String)
    created_date = db.Column(db.Date, nullable=False)
    classroom_desc = db.Column(db.String)
    quiz = db.relationship('Quiz', backref='creator', lazy=True)

    def __repr__(self):
        return f"{self.id}, {self.classroom_name}, {self.classroom_id}, {self.teacher_id}, {self.classroom_link}, {self.classroom_desc}"
예제 #9
0
파일: models.py 프로젝트: imTJK/Rewe-Sales
class Product(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), index=True)
    price = db.Column(db.Float)
    img_src = db.Column(db.String(120))
    category = db.Column(db.String(30), index=True)
    rewe_plz = db.Column(db.Integer, db.ForeignKey('rewe.plz'))
    on_sale = db.Column(db.Boolean, index=True, default=False)
예제 #10
0
class assignments(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    classroom_id = db.Column(db.Integer, nullable=False)
    description = db.Column(db.String, nullable=False)
    due_date = db.Column(db.Date, nullable=False)
    assigned_date = db.Column(db.Date, nullable=False)
    file_path = db.Column(db.String)

    def __repr__(self):
        return f"{self.id}, {self.classroom_id}, {self.description}, {self.due_date}, {self.assigned_date}, {self.file_path}"
예제 #11
0
파일: models.py 프로젝트: imTJK/Rewe-Sales
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    plz = db.Column(db.Integer, db.ForeignKey('zipcode.id'))
    email = db.Column(db.String(120), index=True, unique=True)
    password_hash = db.Column(db.String(128))
    created_at = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    last_login_at = db.Column(db.DateTime)
    is_admin = db.Column(db.Boolean, default=False)

    def user_to_json(self):
        return {
            "id": self.id,
            "name": self.username,
            "email": self.email,
            "plz": self.plz,
            "password_hash": self.password_hash,
            "created_at": self.created_at
        }

    def __repr__(self):
        return '<User {}>'.format(self.username)
예제 #12
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    isDisabled = db.Column(db.Boolean, nullable=False, default=False)
    isAdmin = db.Column(db.Boolean, nullable=False, default=False)
    created_date = db.Column(db.Date)
    last_login_time = db.Column(db.Date)
    threads = db.relationship('ConversationThread',
                              backref='creator',
                              lazy=True)

    rating = db.Column(db.Integer, default=0)
    threadsCreated = db.Column(db.Integer, default=0)
    threadsReplied = db.Column(db.Integer, default=0)

    def __repr__(self):
        return f"{self.id}, {self.username}, {self.email}, {self.image_file}, {self.password}, {self.isDisabled}, {self.created_date}, {self.last_login_time}"
예제 #13
0
파일: models.py 프로젝트: imTJK/Rewe-Sales
class Rewe(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True)
    adress = db.Column(db.String(100), index=True, unique=True)
    plz = db.Column(db.Integer, db.ForeignKey('zipcode.id'))
예제 #14
0
파일: models.py 프로젝트: imTJK/Rewe-Sales
class Zipcode(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    district = db.Column(db.String(50), primary_key=True)