Skip to content

Commit

Permalink
fix: logic error when fetching collection
Browse files Browse the repository at this point in the history
  • Loading branch information
hrideshmg committed Aug 26, 2024
1 parent 84f296e commit 3342a47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def create(self, validated_data):
table_data = validated_data.pop("courses_data")
collection = Collection.objects.create(**validated_data)

# First nested list will have first period of each day
course_list = defaultdict(list)
for order, periods in enumerate(table_data, 1):
for day, period in enumerate(periods, 1):
Expand Down
3 changes: 2 additions & 1 deletion api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def get(self, request):

schedules = Schedule.objects.filter(course__collection__user=request.user)
max_order = schedules.aggregate(Max("order", default=1))["order__max"]
template = [[None] * max_order for i in range(5)]
# First nested list is the first period of each day, second nested list is second period of each day
template = [[""] * 5 for i in range(max_order)]

for day in range(0, 5):
schedules_on_day = schedules.filter(day_of_week=day + 1).order_by("order")
Expand Down

0 comments on commit 3342a47

Please sign in to comment.