universityAPI.py 649 Bytes
Newer Older
1
from backend.models.university import University
2
from rest_framework import serializers, viewsets, permissions
3
from backend.models.university.campus import CampusSerializer
4
5
6


class UniversitySerializer(serializers.ModelSerializer):
7
    univ_campus = CampusSerializer(many=True, read_only=True)
8
9
10

    class Meta:
        model = University
11
        fields = ('name', 'acronym', 'logo', 'id', 'univ_campus')
12
13
14
15
16
17


class UniversityViewSet(viewsets.ModelViewSet):  # TODO switch to dict
    permission_classes = (permissions.DjangoModelPermissions,)
    queryset = University.objects.all()  # pylint: disable=E1101
    serializer_class = UniversitySerializer