Skip to content
Snippets Groups Projects
Verified Commit e7d1a09e authored by Jan Maximilian Michal's avatar Jan Maximilian Michal
Browse files

Ran isort on core (only few changes).

* Also added docstrings to classes and module in views.py
* Removed a logging statement from StudentApiView
parent 048f1167
No related branches found
No related tags found
1 merge request!16Backend tests
Pipeline #
This commit is part of merge request !16. Comments created here will be created in the context of that merge request.
......@@ -52,7 +52,7 @@ test_frontend:
- yarn install
- yarn test --single-run
# ============================ Gitlab pages section =========================== #
# =========================== Gitlab pages section =========================== #
test_coverage:
<<: *test_definition_backend
stage:
......
......@@ -2,9 +2,10 @@
# Generated by Django 1.11.7 on 2017-11-10 21:46
from __future__ import unicode_literals
import core.models
from django.db import migrations, models
import core.models
class Migration(migrations.Migration):
......
from rest_framework import permissions
from core.models import Student, Reviewer, Tutor
from core.models import Reviewer, Student, Tutor
class IsUserGenericPermission(permissions.BasePermission):
......
import logging
from rest_framework import serializers
from core.models import ExamType, Feedback, Student, Submission, Tutor
from util.factories import GradyUserFactory
import logging
log = logging.getLogger(__name__)
user_factory = GradyUserFactory()
......
......@@ -7,14 +7,13 @@
import logging as log
from unittest import skip
from django.urls import reverse
from rest_framework import status
from rest_framework.test import (APIRequestFactory, APITestCase,
force_authenticate, APIClient)
from rest_framework.test import (APIClient, APIRequestFactory, APITestCase,
force_authenticate)
from core.models import Feedback, Tutor, Reviewer
from core.views import TutorCreateView, TutorListApiView, TutorDetailView
from core.models import Feedback, Reviewer, Tutor
from core.views import TutorCreateView, TutorDetailView, TutorListApiView
from util.factories import GradyUserFactory
NUMBER_OF_TUTORS = 7
......
""" 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 """
import logging
from rest_framework import generics
from core.permissions import IsStudent, IsReviewer
from core.serializers import StudentSerializer, TutorSerializer, ExamSerializer
from core.models import Tutor, ExamType
from core.models import ExamType, Tutor
from core.permissions import IsReviewer, IsStudent
from core.serializers import ExamSerializer, StudentSerializer, TutorSerializer
log = logging.getLogger(__name__)
class StudentApiView(generics.RetrieveAPIView):
""" Gets all data that belongs to one student """
permission_classes = (IsStudent,)
serializer_class = StudentSerializer
def get_object(self):
log.debug("Serializing student of user '%s'",
self.request.user.username)
""" The object in question is the student associated with the requests
user. Since the permission IsStudent is satisfied the member exists """
return self.request.user.student
class TutorListApiView(generics.ListAPIView):
""" A list of all tutors with informationi about what they corrected """
""" A list of all tutors with information about what they corrected """
permission_classes = (IsReviewer,)
queryset = Tutor.objects.all()
serializer_class = TutorSerializer
class TutorCreateView(generics.CreateAPIView):
""" Creates a Tutor instance currently without a password """
permission_classes = (IsReviewer,)
serializer_class = TutorSerializer
class ExamListView(generics.ListAPIView):
""" Gets a list of all exams available. List might be empty """
queryset = ExamType.objects.all()
serializer_class = ExamSerializer
class TutorDetailView(generics.RetrieveAPIView):
""" Gets information of a single tutor by their username """
permissions_classes = (IsReviewer,)
serializer_class = TutorSerializer
lookup_field = 'user__username'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment