universityAPI.py 581 Bytes
Newer Older
1
from backend.models.university import University
2
from rest_framework import permissions
3
from backend.models.tools import NoDeleteIfNotAdmin
4
from backend.models.my_model import MyModelSerializer, MyModelViewSet
5
6


7
class UniversitySerializer(MyModelSerializer):
8
9
10

    class Meta:
        model = University
11
        fields = '__all__'
12
13


14
class UniversityViewSet(MyModelViewSet):
15
16
    serializer_class = UniversitySerializer

17
18
19
20
    permission_classes = (
        permissions.IsAuthenticated,
        NoDeleteIfNotAdmin,
    )
21
    queryset = University.objects.all()  # pylint: disable=E1101