Skip to content
Snippets Groups Projects
Commit 00aa36e7 authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

Changed StudentSelfApieViewSet to RetrieveApiView

The extra functionality offered by the ViewSet is not needed in this place and caused unexpected behavior (it returned an array containing an object, breaking the StudentView). For this very simple View imo explicit is better than implicit.
parent 54474602
No related branches found
No related tags found
2 merge requests!23Resolve "Logout of tutors after inactivity",!22WIP: Started work on navigation and layout
......@@ -12,11 +12,15 @@ router.register(r'student', views.StudentReviewerApiViewSet)
router.register(r'examtype', views.ExamApiViewSet)
router.register(r'submissiontype', views.SubmissionTypeApiView)
router.register(r'tutor', views.TutorApiViewSet)
router.register(r'student-page', views.StudentSelfApiViewSet,
base_name='student_page')
# regular views that are not viewsets
regular_views_urlpatterns = [
url(r'student-page', views.StudentSelfApiView.as_view())
]
urlpatterns = [
url(r'^api/', include(router.urls)),
url(r'^api/', include(regular_views_urlpatterns)),
url(r'^api-token-auth/', obtain_jwt_token),
url(r'^api-token-refresh', refresh_jwt_token),
url(r'^$', TemplateView.as_view(template_name='index.html')),
......
""" All API views that are used to retrieve data from the database. They
can be categorized by the permissions they require. All views require a
user to be authenticated and most are only accessible by one user group """
from rest_framework import mixins, viewsets
from rest_framework import mixins, viewsets, generics
from core.models import ExamType, Student, SubmissionType, Tutor
from core.permissions import IsReviewer, IsStudent
......@@ -10,10 +10,9 @@ from core.serializers import (ExamSerializer, StudentSerializer,
SubmissionTypeSerializer, TutorSerializer)
class StudentSelfApiViewSet(viewsets.ReadOnlyModelViewSet):
class StudentSelfApiView(generics.RetrieveAPIView):
""" Gets all data that belongs to one student """
permission_classes = (IsStudent,)
queryset = Student.objects.all()
serializer_class = StudentSerializer
def get_object(self) -> Student:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment