universityAPI.py 639 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from rex.models.university import University
from rest_framework import serializers, viewsets, permissions
from rex.models.university.campus import CampusSerializer


class UniversitySerializer(serializers.ModelSerializer):
    univCampus = CampusSerializer(many=True, read_only=True)

    class Meta:
        model = University
        fields = ('name', 'acronym', 'logo', 'id', 'univCampus')


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