universityTaggedItem.py 819 Bytes
Newer Older
1
from django.db import models
Florent Chehab's avatar
Florent Chehab committed
2
from backend.models.tag import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
3
4
5
from backend.models.university import University


Florent Chehab's avatar
Florent Chehab committed
6
class UniversityTaggedItem(TaggedItem):
7
8
9
10
11
12
13
14
15
16
17
    university = models.OneToOneField(
        University, on_delete=models.PROTECT, related_name='city_items', primary_key=True)

    @classmethod
    def get_serializer(cls):
        return UniversityTaggedItemSerializer

    class Meta:
        unique_together = ('university', 'tag')


Florent Chehab's avatar
Florent Chehab committed
18
class UniversityTaggedItemSerializer(TaggedItemSerializer):
19
20
21
22
23
    class Meta:
        model = UniversityTaggedItem
        fields = '__all__'


Florent Chehab's avatar
Florent Chehab committed
24
class UniversityTaggedItemViewSet(TaggedItemViewSet):
25
26
27

    queryset = UniversityTaggedItem.objects.all()  # pylint: disable=E1101
    serializer_class = UniversityTaggedItemSerializer