diff --git a/ref-test/admin/models/entries.py b/ref-test/admin/models/entries.py new file mode 100644 index 0000000..71ca3c5 --- /dev/null +++ b/ref-test/admin/models/entries.py @@ -0,0 +1,51 @@ +from database import db +from common.security import encrypt, decrypt +from . import JsonEncodedDict + +class Entry(db.Model): + + id = db.Column(db.String(36), primary_key=True) + first_name = db.Column(db.String(128), nullable=False) + surname = db.Column(db.String(128), nullable=False) + email = db.Column(db.String(128), nullable=False) + club = db.Column(db.String(128), nullable=True) + test_id = db.Column(db.String(36), db.ForeignKey('test.id')) + test_code = db.Column(db.String(36), db.ForeignKey('test.test_code')) + user_code = db.Column(db.String(6), nullable=True) + start_time = db.Column(db.DateTime, nullable=False) + end_time = db.Column(db.DateTime, nullable=True) + status = db.Column(db.String(16), nullable=True) + late_ignore = db.Column(db.Boolean, default=False, nullable=True) + answers = db.Column(JsonEncodedDict, nullable=True) + + @property + def set_first_name(self): raise AttributeError('set_first_name is not a readable attribute.') + + set_first_name.setter + def set_first_name(self, name:str): self.first_name = encrypt(name) + + def get_first_name(self): return decrypt(self.first_name) + + @property + def set_surname(self): raise AttributeError('set_first_name is not a readable attribute.') + + set_surname.setter + def set_surname(self, name:str): self.surname = encrypt(name) + + def get_surname(self): return decrypt(self.surname) + + @property + def set_email(self): raise AttributeError('set_email is not a readable attribute.') + + set_name.setter + def set_email(self, email:str): self.email = encrypt(email) + + def get_email(self): return decrypt(self.email) + + @property + def set_club(self): raise AttributeError('set_club is not a readable attribute.') + + set_name.setter + def set_club(self, club:str): self.club = encrypt(club) + + def get_club(self): return decrypt(self.club) \ No newline at end of file diff --git a/ref-test/database.py b/ref-test/database.py new file mode 100644 index 0000000..2e1eeb6 --- /dev/null +++ b/ref-test/database.py @@ -0,0 +1,3 @@ +from flask_sqlalchemy import SQLAlchemy + +db = SQLAlchemy() \ No newline at end of file diff --git a/ref-test/mail.py b/ref-test/mail.py new file mode 100644 index 0000000..3d1d121 --- /dev/null +++ b/ref-test/mail.py @@ -0,0 +1,3 @@ +from flask_mail import Mail + +mail = Mail() \ No newline at end of file