-
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.
- Loading branch information
Showing
13 changed files
with
211 additions
and
40 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
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,11 @@ | ||
from rest_framework import serializers | ||
from api.models.student import Student | ||
|
||
|
||
class StudentSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Student | ||
fields = '__all__' | ||
|
||
def create(self, validated_data): | ||
return Student.objects.create(**validated_data) |
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,43 @@ | ||
from django.http import JsonResponse | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
from rest_framework import status | ||
from ..models import Indiening | ||
from ..serializers import IndieningSerializer | ||
|
||
|
||
@api_view(['GET', 'POST']) | ||
def indiening_list(request, format=None): | ||
|
||
if request.method == 'GET': | ||
lesgevers = Indiening.objects.all() | ||
serializer = IndieningSerializer(lesgevers, many=True) | ||
return Response(serializer.data) | ||
|
||
elif request.method == 'POST': | ||
serializer = IndieningSerializer(data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data, status=status.HTTP_201_CREATED) | ||
|
||
@api_view(['GET', 'PUT', 'DELETE']) | ||
def indiening_detail(request, id, format=None): | ||
try: | ||
indiening = Indiening.objects.get(pk=id) | ||
except Indiening.DoesNotExist: | ||
return Response(status=status.HTTP_404_NOT_FOUND) | ||
|
||
if request.method == 'GET': | ||
serializer = IndieningSerializer(indiening) | ||
return Response(serializer.data) | ||
|
||
elif request.method == 'PUT': | ||
serializer = IndieningSerializer(indiening, data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
|
||
elif request.method == 'DELETE': | ||
indiening.delete() | ||
return Response(status=status.HTTP_204_NO_CONTENT) |
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,43 @@ | ||
from django.http import JsonResponse | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
from rest_framework import status | ||
from ..models import Project | ||
from ..serializers import ProjectSerializer | ||
|
||
|
||
@api_view(['GET', 'POST']) | ||
def project_list(request, format=None): | ||
|
||
if request.method == 'GET': | ||
lesgevers = Project.objects.all() | ||
serializer = ProjectSerializer(lesgevers, many=True) | ||
return Response(serializer.data) | ||
|
||
elif request.method == 'POST': | ||
serializer = ProjectSerializer(data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data, status=status.HTTP_201_CREATED) | ||
|
||
@api_view(['GET', 'PUT', 'DELETE']) | ||
def project_detail(request, id, format=None): | ||
try: | ||
project = Project.objects.get(pk=id) | ||
except Project.DoesNotExist: | ||
return Response(status=status.HTTP_404_NOT_FOUND) | ||
|
||
if request.method == 'GET': | ||
serializer = ProjectSerializer(project) | ||
return Response(serializer.data) | ||
|
||
elif request.method == 'PUT': | ||
serializer = ProjectSerializer(project, data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
|
||
elif request.method == 'DELETE': | ||
project.delete() | ||
return Response(status=status.HTTP_204_NO_CONTENT) |
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,43 @@ | ||
from django.http import JsonResponse | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
from rest_framework import status | ||
from ..models import Score | ||
from ..serializers import ScoreSerializer | ||
|
||
|
||
@api_view(['GET', 'POST']) | ||
def score_list(request, format=None): | ||
|
||
if request.method == 'GET': | ||
lesgevers = Score.objects.all() | ||
serializer = ScoreSerializer(lesgevers, many=True) | ||
return Response(serializer.data) | ||
|
||
elif request.method == 'POST': | ||
serializer = ScoreSerializer(data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data, status=status.HTTP_201_CREATED) | ||
|
||
@api_view(['GET', 'PUT', 'DELETE']) | ||
def score_detail(request, id, format=None): | ||
try: | ||
score = Score.objects.get(pk=id) | ||
except Score.DoesNotExist: | ||
return Response(status=status.HTTP_404_NOT_FOUND) | ||
|
||
if request.method == 'GET': | ||
serializer = ScoreSerializer(score) | ||
return Response(serializer.data) | ||
|
||
elif request.method == 'PUT': | ||
serializer = ScoreSerializer(score, data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
|
||
elif request.method == 'DELETE': | ||
score.delete() | ||
return Response(status=status.HTTP_204_NO_CONTENT) |
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,41 @@ | ||
from django.http import JsonResponse | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
from rest_framework import status | ||
|
||
|
||
from api.models import Student | ||
from api.serializers import StudentSerializer | ||
#from ..utils import json_error | ||
|
||
|
||
@api_view(['GET', 'POST']) | ||
def student_list(request): | ||
if request.method == 'GET': | ||
students = Student.objects.all() | ||
serializer = StudentSerializer(students, many=True) | ||
return Response(serializer.data) | ||
elif request.method == 'POST': | ||
serializer = StudentSerializer(data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data, status=status.HTTP_201_CREATED) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
|
||
|
||
@api_view(['GET', 'PUT']) | ||
def student_detail(request, id): | ||
try: | ||
student = Student.objects.get(pk=id) | ||
except Student.DoesNotExist: | ||
return Response(status=status.HTTP_404_NOT_FOUND) | ||
|
||
if request.method == 'GET': | ||
serializer = StudentSerializer(student) | ||
return Response(serializer.data) | ||
elif request.method == 'PUT': | ||
serializer = StudentSerializer(student, data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) |
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,39 +1,42 @@ | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
from rest_framework import status | ||
from api.models.vak import Vak | ||
from api.serializers.vak import VakSerializer | ||
from ..models import Vak | ||
from ..serializers import VakSerializer | ||
|
||
|
||
@api_view(['GET', 'POST']) | ||
def vak_list(request): | ||
def vak_list(request, format=None): | ||
|
||
if request.method == 'GET': | ||
lesgevers = Vak.objects.all() | ||
serializer = VakSerializer(lesgevers, many=True) | ||
return Response(serializer.data) | ||
|
||
elif request.method == 'POST': | ||
serializer = VakSerializer(data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data, status=status.HTTP_201_CREATED) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
|
||
""" | ||
@api_view(['GET', 'PUT']) | ||
def vak_detail(request, id): | ||
|
||
@api_view(['GET', 'PUT', 'DELETE']) | ||
def vak_detail(request, id, format=None): | ||
try: | ||
student = Vak.objects.get(pk=id) | ||
vak = Vak.objects.get(pk=id) | ||
except Vak.DoesNotExist: | ||
return Response(status=status.HTTP_404_NOT_FOUND) | ||
|
||
if request.method == 'GET': | ||
serializer = StudentSerializer(student) | ||
serializer = VakSerializer(vak) | ||
return Response(serializer.data) | ||
|
||
elif request.method == 'PUT': | ||
serializer = StudentSerializer(student, data=request.data) | ||
serializer = VakSerializer(vak, data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
""" | ||
|
||
elif request.method == 'DELETE': | ||
vak.delete() | ||
return Response(status=status.HTTP_204_NO_CONTENT) |