Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
#200 refactoring + docs StudentTemplate
Browse files Browse the repository at this point in the history
Signed-off-by: novdamme <[email protected]>
  • Loading branch information
novdamme committed Apr 13, 2023
1 parent af0830c commit e91a27f
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 78 deletions.
4 changes: 4 additions & 0 deletions backend/planning/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class StudentTemplate(models.Model):
Al de dagplanningen van deze rondes.
"""
def __getitem__(self, item):
if item == "dag_planningen":
return self.dag_planningen

name = models.TextField()
even = models.BooleanField()
location = models.ForeignKey(LocatieEnum, on_delete=models.DO_NOTHING)
Expand Down
6 changes: 5 additions & 1 deletion backend/planning/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
path("studenttemplates/", views.student_templates_view),
path("studenttemplates/<int:template_id>/", views.student_template_view),
path("studenttemplates/<int:template_id>/rondes/", views.rondes_view),
path("studenttemplates/<int:template_id>/<int:ronde_id>/dagplanningen/", views.dagplanning_view)
path("studenttemplates/<int:template_id>/rondes/<int:ronde_id>/", views.ronde_view),
path("studenttemplates/<int:template_id>/rondes/<int:ronde_id>/dagplanningen/", views.dagplanningen_view),
path("studenttemplates/<int:template_id>/dagplanningen/<int:dag_id>/", views.dagplanning_view, {'permanent': True}),
path("studenttemplates/<int:template_id>/dagplanningen/<int:dag_id>/eenmalig/", views.dagplanning_view,
{'permanent': True})

]
22 changes: 16 additions & 6 deletions backend/planning/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ def get_current_week_planning():
return planning


def make_dag_planning(day, start_hour, end_hour, ronde, students):
def make_dag_planning(data):
"""
Maakt een nieuwe DagPlanning aan.
"""
pickup_day, _ = PickUpDay.objects.get_or_create(
day=day,
start_hour=start_hour,
end_hour=end_hour
day=data["day"],
start_hour=data["start_hour"],
end_hour=data["end_hour"]
)
dag_planning, _ = DagPlanning.objects.get_or_create(
ronde_id=ronde,
ronde_id=data["ronde"],
time=pickup_day
)
dag_planning.students.set(students)
dag_planning.students.set(data["students"])
return dag_planning


Expand Down Expand Up @@ -107,3 +107,13 @@ def delete_old_dag_planning(old_dag_planningen, day, template):
if old_dag_planning.time.day == day:
template.dag_planningen.remove(old_dag_planning)
break


def validate_student_template_data(data):
# TODO error handling
pass


def validate_dag_planning_data(data):
# TODO error handling
pass
Loading

0 comments on commit e91a27f

Please sign in to comment.