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


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

    @classmethod
    def get_serializer(cls):
        return CampusTaggedItemSerializer

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


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


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

    queryset = CampusTaggedItem.objects.all()  # pylint: disable=E1101
    serializer_class = CampusTaggedItemSerializer