2021-03-18 22:20:59 +00:00
|
|
|
from advlabdb import db
|
2021-03-18 13:53:55 +00:00
|
|
|
from advlabdb.models import *
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
db.drop_all()
|
|
|
|
db.create_all()
|
|
|
|
|
|
|
|
student1 = Student(student_number=123, first_name="Mo", last_name="Bit", email="m@test.com")
|
|
|
|
student2 = Student(student_number=1232, first_name="Mo2", last_name="Bit", email="m2@test.com")
|
|
|
|
student3 = Student(student_number=1233, first_name="Mo3", last_name="Bit3", email="m3@test.com")
|
|
|
|
|
|
|
|
db.session.add(student1)
|
|
|
|
db.session.add(student2)
|
|
|
|
db.session.add(student3)
|
|
|
|
|
2021-03-20 14:41:22 +00:00
|
|
|
sem1 = Semester(label="WS2021")
|
|
|
|
sem2 = Semester(label="SS21")
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-03-20 14:41:22 +00:00
|
|
|
db.session.add(sem1)
|
|
|
|
db.session.add(sem2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-03-20 14:41:22 +00:00
|
|
|
parta1 = Part(label="A/1", semester=sem2)
|
|
|
|
partb2 = Part(label="B/2", semester=sem2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
|
|
|
db.session.add(parta1)
|
|
|
|
db.session.add(partb2)
|
|
|
|
|
2021-03-19 20:15:43 +00:00
|
|
|
g1 = Group(number=1, part=parta1)
|
|
|
|
g2 = Group(number=2, part=partb2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
|
|
|
db.session.add(g1)
|
|
|
|
db.session.add(g2)
|
|
|
|
|
|
|
|
ps1 = PartStudent(student=student1, part=parta1, group=g1)
|
|
|
|
ps2 = PartStudent(student=student2, part=parta1, group=g1)
|
|
|
|
ps3 = PartStudent(student=student3, part=partb2, group=g2)
|
|
|
|
|
|
|
|
db.session.add(ps1)
|
|
|
|
db.session.add(ps2)
|
|
|
|
db.session.add(ps3)
|
|
|
|
|
2021-03-31 18:43:54 +00:00
|
|
|
ex1 = Experiment(number=1, name="exp", room="123", building="phy", responsibility="none", duration_in_days=2,
|
2021-03-18 22:20:59 +00:00
|
|
|
oral_weighting=0.5, protocol_weighting=0.5, final_weighting=1)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
2021-03-31 18:43:54 +00:00
|
|
|
ex2 = Experiment(number=2, name="exp2", room="123", building="phy", responsibility="none", duration_in_days=2,
|
2021-03-18 22:20:59 +00:00
|
|
|
oral_weighting=0.5, protocol_weighting=0.5, final_weighting=1)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
|
|
|
db.session.add(ex1)
|
|
|
|
db.session.add(ex2)
|
|
|
|
|
2021-03-31 18:43:54 +00:00
|
|
|
px1 = PartExperiment(experiment=ex1, part=parta1)
|
|
|
|
px2 = PartExperiment(experiment=ex2, part=partb2)
|
2021-03-18 13:53:55 +00:00
|
|
|
|
|
|
|
db.session.add(px1)
|
|
|
|
db.session.add(px2)
|
|
|
|
|
|
|
|
gx1 = GroupExperiment(part_experiment=px1, group=g1)
|
|
|
|
gx2 = GroupExperiment(part_experiment=px2, group=g2)
|
|
|
|
|
|
|
|
db.session.add(gx1)
|
|
|
|
db.session.add(gx2)
|
|
|
|
|
|
|
|
us1 = User(email="test@test.com", password_hash="h1")
|
|
|
|
us2 = User(email="test2@test.com", password_hash="h2")
|
|
|
|
|
|
|
|
db.session.add(us1)
|
|
|
|
db.session.add(us2)
|
|
|
|
|
2021-03-18 22:20:59 +00:00
|
|
|
as1 = Assistant(first_name="As1", last_name="l", email="test@test.com", phone_number="012333212",
|
|
|
|
mobile_phone_number="012334123", user=us1)
|
2021-03-18 13:53:55 +00:00
|
|
|
as2 = Assistant(first_name="As2", last_name="l", email="test2@test.com", user=us1)
|
|
|
|
|
2021-03-18 22:20:59 +00:00
|
|
|
as1.part_experiments.append(px1)
|
|
|
|
as2.part_experiments.append(px2)
|
|
|
|
|
2021-03-18 13:53:55 +00:00
|
|
|
db.session.add(as1)
|
|
|
|
db.session.add(as2)
|
|
|
|
|
|
|
|
ap1 = Appointment(date=datetime(2021, 3, 21), special=True, group_experiment=gx1, assistant=as1)
|
|
|
|
ap2 = Appointment(date=datetime(2021, 3, 22), special=True, group_experiment=gx2, assistant=as2)
|
|
|
|
|
|
|
|
db.session.add(ap1)
|
|
|
|
db.session.add(ap2)
|
|
|
|
|
|
|
|
em1 = ExperimentMark(oral_mark=11, protocol_mark=14, part_student=ps1, group_experiment=gx1, assistant=as1)
|
|
|
|
em2 = ExperimentMark(oral_mark=12, protocol_mark=14, part_student=ps2, group_experiment=gx1, assistant=as1)
|
|
|
|
em3 = ExperimentMark(oral_mark=13, protocol_mark=14, part_student=ps3, group_experiment=gx2, assistant=as2)
|
|
|
|
|
|
|
|
db.session.add(em1)
|
|
|
|
db.session.add(em2)
|
|
|
|
db.session.add(em3)
|
|
|
|
|
|
|
|
db.session.commit()
|