universityPhoto.py 762 Bytes
Newer Older
1
from django.db import models
2
from backend.models.university import University
3
from backend.models.module import Photo, PhotoSerializer, PhotoViewSet
4
5
6
7


class UniversityPhoto(Photo):

8
    university = models.ForeignKey(
9
10
11
12
        University,
        on_delete=models.CASCADE,
        related_name='university_photos')

13
14
15
16
    @classmethod
    def get_serializer(cls):
        return UniversityPhotoSerializer

17
18
19
20
    class Meta:
        unique_together = ('university', 'photo')


21
class UniversityPhotoSerializer(PhotoSerializer):
22
23
24
25
26
27

    class Meta:
        model = UniversityPhoto
        fields = '__all__'


28
class UniversityPhotoViewSet(PhotoViewSet):
29
30
    queryset = UniversityPhoto.objects.all()  # pylint: disable=E1101
    serializer_class = UniversityPhotoSerializer