This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db.session.add verwijderen + toevoegen nieuwe mock data
- Loading branch information
1 parent
4f68cea
commit a176995
Showing
3 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,54 @@ | ||
from datetime import datetime | ||
|
||
from psycopg2 import tz | ||
|
||
from app import app | ||
from db.extensions import db | ||
from db.implementation.SqlAdminDAO import SqlAdminDAO | ||
from db.implementation.SqlGroupDAO import SqlGroupDAO | ||
from db.implementation.SqlProjectDAO import SqlProjectDAO | ||
from db.implementation.SqlStudentDAO import SqlStudentDAO | ||
from db.implementation.SqlSubjectDAO import SqlSubjectDAO | ||
from db.implementation.SqlTeacherDAO import SqlTeacherDAO | ||
|
||
if __name__ == "__main__": | ||
with app.app_context(): | ||
|
||
db.create_all() | ||
|
||
admin_dao = SqlAdminDAO() | ||
student_dao = SqlStudentDAO() | ||
teacher_dao = SqlTeacherDAO() | ||
subject_dao = SqlSubjectDAO() | ||
group_dao = SqlGroupDAO() | ||
project_dao = SqlProjectDAO() | ||
|
||
# maak een vak | ||
objeprog = subject_dao.create_subject(name="OBJECTGERICHTPROGRAMMEREN") | ||
|
||
# maak een project voor dat vak | ||
objeprog_project = project_dao.create_project(subject_id=objeprog.id, | ||
name="PROJECT", | ||
archived=False, | ||
visible=True, | ||
requirements="Maak iets in javafx", | ||
max_students=2, | ||
deadline=datetime(2000, 1, 1, 0, 0, 0, tzinfo=tz.LOCAL)) | ||
|
||
# maak een groepje voor het project van objeprog | ||
groep1 = group_dao.create_group(project_id=objeprog_project.id) | ||
|
||
# maak studenten | ||
student1 = student_dao.create_student("Student1", "[email protected]") | ||
student2 = student_dao.create_student("Student2", "[email protected]") | ||
student3 = student_dao.create_student("Student3", "[email protected]") | ||
|
||
# maak teacher | ||
teacher1 = teacher_dao.create_teacher("Teacher1", "[email protected]") | ||
|
||
# voeg teacher toe aan objeprog | ||
subject_dao.add_teacher_to_subject(teacher1.id, objeprog.id) | ||
|
||
# voeg studenten toe aan de groep | ||
group_dao.add_student_to_group(student1.id, groep1.id) | ||
group_dao.add_student_to_group(student2.id, groep1.id) | ||
group_dao.add_student_to_group(student3.id, groep1.id) |