Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
335f46ff
Commit
335f46ff
authored
7 years ago
by
Ingo Leindecker
Browse files
Options
Downloads
Patches
Plain Diff
Added limit/offset pagination for shows, timeslots and notes.
See
#22
parent
7a5e0ffb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/views.py
+10
-4
10 additions, 4 deletions
program/views.py
with
10 additions
and
4 deletions
program/views.py
+
10
−
4
View file @
335f46ff
...
...
@@ -13,6 +13,7 @@ from django.views.generic.list import ListView
from
rest_framework
import
permissions
,
serializers
,
status
,
viewsets
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
rest_framework.pagination
import
LimitOffsetPagination
from
program.models
import
Type
,
MusicFocus
,
Language
,
Note
,
Show
,
Category
,
RTRCategory
,
Topic
,
TimeSlot
,
Host
,
Schedule
from
program.serializers
import
TypeSerializer
,
LanguageSerializer
,
MusicFocusSerializer
,
NoteSerializer
,
ShowSerializer
,
ScheduleSerializer
,
CategorySerializer
,
RTRCategorySerializer
,
TopicSerializer
,
TimeSlotSerializer
,
HostSerializer
,
UserSerializer
...
...
@@ -426,6 +427,7 @@ class APIShowViewSet(viewsets.ModelViewSet):
queryset
=
Show
.
objects
.
none
()
serializer_class
=
ShowSerializer
permission_classes
=
[
permissions
.
DjangoModelPermissionsOrAnonReadOnly
]
pagination_class
=
LimitOffsetPagination
required_scopes
=
[
'
shows
'
]
...
...
@@ -446,13 +448,13 @@ class APIShowViewSet(viewsets.ModelViewSet):
return
Show
.
objects
.
all
()
'''
def list(self, request):
"""
List shows
"""
shows = self.get_queryset()
serializer = ShowSerializer(shows, many=True)
return Response(serializer.data)
'''
def
create
(
self
,
request
,
pk
=
None
):
"""
...
...
@@ -621,6 +623,7 @@ class APITimeSlotViewSet(viewsets.ModelViewSet):
permission_classes
=
[
permissions
.
DjangoModelPermissionsOrAnonReadOnly
]
serializer_class
=
TimeSlotSerializer
pagination_class
=
LimitOffsetPagination
queryset
=
TimeSlot
.
objects
.
none
()
required_scopes
=
[
'
timeslots
'
]
...
...
@@ -649,12 +652,13 @@ class APITimeSlotViewSet(viewsets.ModelViewSet):
return
TimeSlot
.
objects
.
filter
(
start__gte
=
start
,
end__lte
=
end
).
order_by
(
'
start
'
)
'''
def list(self, request, show_pk=None, schedule_pk=None):
"""
Lists timeslots of a show
"""
timeslots = self.get_queryset()
serializer = TimeSlotSerializer(timeslots, many=True)
return Response(serializer.data)
'''
def
retrieve
(
self
,
request
,
pk
=
None
,
schedule_pk
=
None
,
show_pk
=
None
):
...
...
@@ -726,6 +730,7 @@ class APINoteViewSet(viewsets.ModelViewSet):
queryset
=
Note
.
objects
.
none
()
serializer_class
=
NoteSerializer
permission_classes
=
[
permissions
.
DjangoModelPermissionsOrAnonReadOnly
]
pagination_class
=
LimitOffsetPagination
required_scopes
=
[
'
notes
'
]
...
...
@@ -761,12 +766,13 @@ class APINoteViewSet(viewsets.ModelViewSet):
return
notes
'''
def list(self, request, pk=None, timeslot_pk=None, schedule_pk=None, show_pk=None):
"""
Lists notes
"""
notes = self.get_queryset()
serializer = NoteSerializer(notes, many=True)
return Response(serializer.data)
'''
def
create
(
self
,
request
,
pk
=
None
,
timeslot_pk
=
None
,
schedule_pk
=
None
,
show_pk
=
None
):
"""
Create a note
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment