Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oser-backend
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamza Touizrat
oser-backend
Commits
1c6f1983
Commit
1c6f1983
authored
Dec 28, 2017
by
florimondmanca
Browse files
Options
Downloads
Patches
Plain Diff
add tutoringgroups view to tutor api
parent
29c3c041
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
oser_cs/tests/test_api/test_tutor_api.py
+17
-3
17 additions, 3 deletions
oser_cs/tests/test_api/test_tutor_api.py
oser_cs/users/views.py
+9
-0
9 additions, 0 deletions
oser_cs/users/views.py
with
26 additions
and
3 deletions
oser_cs/tests/test_api/test_tutor_api.py
+
17
−
3
View file @
1c6f1983
"""
Tutor API tests.
"""
"""
Tutor API tests.
"""
from
users.serializers
import
TutorSerializer
from
rest_framework
import
status
from
tests.factory
import
TutorFactory
from
tests.factory
import
TutorFactory
,
TutorTutoringGroupFactory
from
tests.utils.api
import
HyperlinkedAPITestCase
from
tests.test_api.mixins
import
ProfileEndpointsTestMixin
from
tests.test_api.mixins
import
ProfileEndpointsTestMixin
from
tests.utils.api
import
HyperlinkedAPITestCase
from
users.serializers
import
TutorSerializer
class
TutorEndpointsTest
(
ProfileEndpointsTestMixin
,
HyperlinkedAPITestCase
):
class
TutorEndpointsTest
(
ProfileEndpointsTestMixin
,
HyperlinkedAPITestCase
):
...
@@ -54,3 +56,15 @@ class TutorEndpointsTest(ProfileEndpointsTestMixin, HyperlinkedAPITestCase):
...
@@ -54,3 +56,15 @@ class TutorEndpointsTest(ProfileEndpointsTestMixin, HyperlinkedAPITestCase):
url
=
'
/api/tutors/{obj.pk}/
'
.
format
(
obj
=
obj
)
url
=
'
/api/tutors/{obj.pk}/
'
.
format
(
obj
=
obj
)
response
=
self
.
client
.
delete
(
url
)
response
=
self
.
client
.
delete
(
url
)
return
response
return
response
def
test_list_tutoring_groups
(
self
):
def
perform_list_tutoring_groups
():
obj
=
self
.
factory
.
create
()
# add tutor to several tutoring groups
TutorTutoringGroupFactory
.
create_batch
(
3
,
tutor
=
obj
)
url
=
'
/api/tutors/{}/tutoringgroups/
'
.
format
(
obj
.
pk
)
response
=
self
.
client
.
get
(
url
)
return
response
self
.
assertRequiresAuth
(
perform_list_tutoring_groups
,
expected_status_code
=
status
.
HTTP_200_OK
)
This diff is collapsed.
Click to expand it.
oser_cs/users/views.py
+
9
−
0
View file @
1c6f1983
...
@@ -98,6 +98,15 @@ class TutorViewSet(ProfileViewSet):
...
@@ -98,6 +98,15 @@ class TutorViewSet(ProfileViewSet):
queryset
=
Tutor
.
objects
.
all
()
queryset
=
Tutor
.
objects
.
all
()
serializer_class
=
TutorSerializer
serializer_class
=
TutorSerializer
@detail_route
()
def
tutoringgroups
(
self
,
request
,
pk
=
None
):
"""
Retrieve the tutoring groups of a tutor.
"""
tutor
=
self
.
get_object
()
tutoring_groups
=
tutor
.
tutoring_groups
.
all
()
serializer
=
TutoringGroupSerializer
(
tutoring_groups
,
many
=
True
,
context
=
{
'
request
'
:
request
})
return
Response
(
serializer
.
data
)
class
StudentViewSet
(
ProfileViewSet
):
class
StudentViewSet
(
ProfileViewSet
):
"""
API endpoint that allows students to be viewed or edited.
"""
"""
API endpoint that allows students to be viewed or edited.
"""
...
...
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