2021-06-30 23:02:44 +00:00
|
|
|
from datetime import date
|
2021-06-02 21:43:41 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
from flask_security import hash_password
|
2021-06-02 21:43:41 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
from advlabdb import app, db, user_datastore
|
|
|
|
from advlabdb.models import *
|
|
|
|
|
|
|
|
with app.app_context():
|
|
|
|
db.drop_all()
|
|
|
|
db.create_all()
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-07-13 23:58:35 +00:00
|
|
|
program1 = Program(label="BS")
|
|
|
|
program2 = Program(label="MS")
|
|
|
|
program3 = Program(label="BE")
|
|
|
|
|
|
|
|
db.session.add(program1)
|
|
|
|
db.session.add(program2)
|
|
|
|
db.session.add(program3)
|
|
|
|
|
2021-07-29 22:39:59 +00:00
|
|
|
sem1 = Semester(label="SS", year=22)
|
|
|
|
sem2 = Semester(label="WS", year=22)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
db.session.add(sem1)
|
|
|
|
db.session.add(sem2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-07-13 19:49:44 +00:00
|
|
|
partKwargs = [
|
2021-07-13 23:58:35 +00:00
|
|
|
{"program": program1, "number": 1},
|
|
|
|
{"program": program1, "number": 2},
|
|
|
|
{"program": program2, "number": 1},
|
|
|
|
{"program": program2, "number": 2},
|
|
|
|
{"program": program3, "number": 1},
|
2021-07-13 19:49:44 +00:00
|
|
|
]
|
|
|
|
for kwargs in partKwargs:
|
|
|
|
db.session.add(Part(semester=sem1, **kwargs))
|
|
|
|
|
2021-07-01 20:20:34 +00:00
|
|
|
sem2.transferPartsFrom(sem1)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-07-13 23:58:35 +00:00
|
|
|
part1 = sem2.parts[0]
|
|
|
|
part2 = sem2.parts[2]
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-05-14 16:53:15 +00:00
|
|
|
student1 = Student(student_number=123, first_name="Mo", last_name="Bit", uni_email="m@test.com")
|
|
|
|
student2 = Student(student_number=1232, first_name="Mo2", last_name="Bit", uni_email="m2@test.com")
|
|
|
|
student3 = Student(student_number=1233, first_name="Mo3", last_name="Bit3", uni_email="m3@test.com")
|
2021-05-02 16:11:08 +00:00
|
|
|
|
|
|
|
db.session.add(student1)
|
|
|
|
db.session.add(student2)
|
|
|
|
db.session.add(student3)
|
|
|
|
|
2021-07-14 02:24:32 +00:00
|
|
|
ps1 = PartStudent.customInit(student=student1, part=part1)
|
|
|
|
ps2 = PartStudent.customInit(student=student2, part=part1)
|
|
|
|
ps3 = PartStudent.customInit(student=student3, part=part2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
db.session.add(ps1)
|
|
|
|
db.session.add(ps2)
|
|
|
|
db.session.add(ps3)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-07-14 02:24:32 +00:00
|
|
|
g1 = Group.customInit(part_students=[ps1, ps2])
|
|
|
|
g2 = Group.customInit(part_students=[ps3])
|
|
|
|
|
|
|
|
db.session.add(g1)
|
|
|
|
db.session.add(g2)
|
|
|
|
|
2021-06-02 21:43:41 +00:00
|
|
|
ex1 = Experiment(
|
2021-07-13 23:58:35 +00:00
|
|
|
number=1,
|
|
|
|
program=program1,
|
2021-07-10 23:49:39 +00:00
|
|
|
title="exp",
|
2021-06-02 21:43:41 +00:00
|
|
|
room="123",
|
|
|
|
building="phy",
|
|
|
|
responsibility="none",
|
|
|
|
duration_in_days=2,
|
|
|
|
oral_weighting=0.5,
|
|
|
|
protocol_weighting=0.5,
|
|
|
|
final_weighting=1,
|
|
|
|
)
|
|
|
|
|
|
|
|
ex2 = Experiment(
|
2021-07-13 23:58:35 +00:00
|
|
|
number=1,
|
|
|
|
program=program2,
|
2021-07-10 23:49:39 +00:00
|
|
|
title="exp2",
|
2021-06-02 21:43:41 +00:00
|
|
|
room="123",
|
|
|
|
building="phy",
|
|
|
|
responsibility="none",
|
|
|
|
duration_in_days=2,
|
|
|
|
oral_weighting=0.5,
|
|
|
|
protocol_weighting=0.5,
|
|
|
|
final_weighting=1,
|
|
|
|
)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
db.session.add(ex1)
|
|
|
|
db.session.add(ex2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-07-01 12:41:20 +00:00
|
|
|
sx1 = SemesterExperiment(experiment=ex1, semester=sem2)
|
|
|
|
sx2 = SemesterExperiment(experiment=ex2, semester=sem2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-07-01 12:41:20 +00:00
|
|
|
db.session.add(sx1)
|
|
|
|
db.session.add(sx2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-07-14 02:24:32 +00:00
|
|
|
gx1 = GroupExperiment.customInit(semester_experiment=sx1, group=g1)
|
|
|
|
gx2 = GroupExperiment.customInit(semester_experiment=sx2, group=g2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
db.session.add(gx1)
|
|
|
|
db.session.add(gx2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
user_datastore.create_role(name="admin")
|
|
|
|
user_datastore.create_role(name="assistant")
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-08-15 23:15:19 +00:00
|
|
|
user_datastore.create_user(
|
|
|
|
email="admin@protonmail.com",
|
|
|
|
password=hash_password("admin"),
|
|
|
|
roles=["admin"],
|
|
|
|
first_name="Peter",
|
|
|
|
last_name="Blümler",
|
|
|
|
)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-08-15 23:15:19 +00:00
|
|
|
us1 = user_datastore.create_user(
|
|
|
|
email="test@protonmail.com",
|
|
|
|
password=hash_password("h1"),
|
|
|
|
roles=["assistant"],
|
2021-06-02 21:43:41 +00:00
|
|
|
first_name="As1",
|
|
|
|
last_name="l",
|
|
|
|
phone_number="012333212",
|
|
|
|
mobile_phone_number="012334123",
|
2021-08-15 23:15:19 +00:00
|
|
|
)
|
|
|
|
us2 = user_datastore.create_user(
|
|
|
|
email="test2@protonmail.com",
|
|
|
|
password=hash_password("h2"),
|
|
|
|
roles=["assistant"],
|
|
|
|
first_name="As2",
|
|
|
|
last_name="l",
|
|
|
|
)
|
|
|
|
|
|
|
|
as1 = Assistant(
|
2021-06-02 21:43:41 +00:00
|
|
|
user=us1,
|
|
|
|
)
|
2021-08-15 23:15:19 +00:00
|
|
|
as2 = Assistant(user=us2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-07-01 12:41:20 +00:00
|
|
|
as1.semester_experiments.append(sx1)
|
|
|
|
as2.semester_experiments.append(sx2)
|
2021-03-18 22:20:59 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
db.session.add(as1)
|
|
|
|
db.session.add(as2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-07-14 02:24:32 +00:00
|
|
|
ap1 = Appointment.customInit(date=date(2021, 3, 21), special=True, assistant=as1, group_experiment=gx1)
|
|
|
|
ap2 = Appointment.customInit(date=date(2021, 3, 22), special=True, assistant=as2, group_experiment=gx2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
db.session.add(ap1)
|
|
|
|
db.session.add(ap2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
db.session.commit()
|