cityTaggedItem.py 785 Bytes
Newer Older
1
from django.db import models
2

3
4
5
6
7
from backend_app.models.abstract.taggedItem import (
    TaggedItem,
    TaggedItemSerializer,
    TaggedItemViewSet,
)
Florent Chehab's avatar
Florent Chehab committed
8
from backend_app.models.city import City
9
10


Florent Chehab's avatar
Florent Chehab committed
11
class CityTaggedItem(TaggedItem):
12
    city = models.ForeignKey(
13
14
        City, on_delete=models.PROTECT, related_name="city_tagged_items"
    )
15
16

    class Meta:
17
        unique_together = ("city", "tag", "importance_level")
18
19


Florent Chehab's avatar
Florent Chehab committed
20
class CityTaggedItemSerializer(TaggedItemSerializer):
21
22
    class Meta:
        model = CityTaggedItem
23
        fields = "__all__"
24
25


Florent Chehab's avatar
Florent Chehab committed
26
class CityTaggedItemViewSet(TaggedItemViewSet):
27
28
    queryset = CityTaggedItem.objects.all()  # pylint: disable=E1101
    serializer_class = CityTaggedItemSerializer
29
30
    end_point_route = "cityTaggedItems"
    filterset_fields = ("city",)