-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better academic year selector, filtering and sorting (#292)
* feat: academic year selector, better pagination and filtering composables * chore: added course pagination
- Loading branch information
Showing
15 changed files
with
171 additions
and
139 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.db.models import Min, Max | ||
from rest_framework.response import Response | ||
from api.models.course import Course | ||
from api.views.pagination.basic_pagination import BasicPagination | ||
|
||
|
||
class CoursePagination(BasicPagination): | ||
def get_paginated_response(self, schema): | ||
# Get min and max years | ||
years = Course.objects.all().aggregate( | ||
Min('academic_startyear'), Max('academic_startyear') | ||
) | ||
|
||
return Response({ | ||
'count': self.page.paginator.count, | ||
'next': self.get_next_link(), | ||
'previous': self.get_previous_link(), | ||
'min_year': years['academic_startyear__min'], | ||
'max_year': years['academic_startyear__max'], | ||
'results': schema, | ||
}) |
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
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,6 +1,13 @@ | ||
import { type Course } from '@/types/Course.ts'; | ||
|
||
export interface PaginatorResponse<T> { | ||
count: number; | ||
next: string | null; | ||
previous: string | null; | ||
results: T[]; | ||
results: T[] | null; | ||
} | ||
|
||
export interface CoursePaginatorResponse extends PaginatorResponse<Course> { | ||
min_year: number; | ||
max_year: number; | ||
} |
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
Oops, something went wrong.