mirror of https://github.com/snachodog/mybuddy.git
Add tags field to supported models
This commit is contained in:
parent
5159e97aff
commit
fd66d3f369
|
@ -6,7 +6,7 @@ from rest_framework.exceptions import ValidationError
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from taggit.serializers import TagListSerializerField, TaggitSerializer
|
from taggit.serializers import TagListSerializerField
|
||||||
|
|
||||||
from core import models
|
from core import models
|
||||||
|
|
||||||
|
@ -92,6 +92,10 @@ class CoreModelWithDurationSerializer(CoreModelSerializer):
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
|
||||||
|
class TaggableSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
tags = TagListSerializerField(required=False)
|
||||||
|
|
||||||
|
|
||||||
class UserSerializer(serializers.ModelSerializer):
|
class UserSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
|
@ -105,13 +109,23 @@ class ChildSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
lookup_field = "slug"
|
lookup_field = "slug"
|
||||||
|
|
||||||
|
|
||||||
class DiaperChangeSerializer(CoreModelSerializer):
|
class DiaperChangeSerializer(CoreModelSerializer, TaggableSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.DiaperChange
|
model = models.DiaperChange
|
||||||
fields = ("id", "child", "time", "wet", "solid", "color", "amount", "notes")
|
fields = (
|
||||||
|
"id",
|
||||||
|
"child",
|
||||||
|
"time",
|
||||||
|
"wet",
|
||||||
|
"solid",
|
||||||
|
"color",
|
||||||
|
"amount",
|
||||||
|
"notes",
|
||||||
|
"tags",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class FeedingSerializer(CoreModelWithDurationSerializer):
|
class FeedingSerializer(CoreModelWithDurationSerializer, TaggableSerializer):
|
||||||
class Meta(CoreModelWithDurationSerializer.Meta):
|
class Meta(CoreModelWithDurationSerializer.Meta):
|
||||||
model = models.Feeding
|
model = models.Feeding
|
||||||
fields = (
|
fields = (
|
||||||
|
@ -124,27 +138,26 @@ class FeedingSerializer(CoreModelWithDurationSerializer):
|
||||||
"method",
|
"method",
|
||||||
"amount",
|
"amount",
|
||||||
"notes",
|
"notes",
|
||||||
|
"tags",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class NoteSerializer(TaggitSerializer, CoreModelSerializer):
|
class NoteSerializer(CoreModelSerializer, TaggableSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Note
|
model = models.Note
|
||||||
fields = ("id", "child", "note", "time", "tags")
|
fields = ("id", "child", "note", "time", "tags")
|
||||||
|
|
||||||
tags = TagListSerializerField(required=False)
|
|
||||||
|
|
||||||
|
class SleepSerializer(CoreModelWithDurationSerializer, TaggableSerializer):
|
||||||
class SleepSerializer(CoreModelWithDurationSerializer):
|
|
||||||
class Meta(CoreModelWithDurationSerializer.Meta):
|
class Meta(CoreModelWithDurationSerializer.Meta):
|
||||||
model = models.Sleep
|
model = models.Sleep
|
||||||
fields = ("id", "child", "start", "end", "duration", "nap", "notes")
|
fields = ("id", "child", "start", "end", "duration", "nap", "notes", "tags")
|
||||||
|
|
||||||
|
|
||||||
class TemperatureSerializer(CoreModelSerializer):
|
class TemperatureSerializer(CoreModelSerializer, TaggableSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Temperature
|
model = models.Temperature
|
||||||
fields = ("id", "child", "temperature", "time", "notes")
|
fields = ("id", "child", "temperature", "time", "notes", "tags")
|
||||||
|
|
||||||
|
|
||||||
class TimerSerializer(CoreModelSerializer):
|
class TimerSerializer(CoreModelSerializer):
|
||||||
|
@ -172,34 +185,34 @@ class TimerSerializer(CoreModelSerializer):
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
|
||||||
class TummyTimeSerializer(CoreModelWithDurationSerializer):
|
class TummyTimeSerializer(CoreModelWithDurationSerializer, TaggableSerializer):
|
||||||
class Meta(CoreModelWithDurationSerializer.Meta):
|
class Meta(CoreModelWithDurationSerializer.Meta):
|
||||||
model = models.TummyTime
|
model = models.TummyTime
|
||||||
fields = ("id", "child", "start", "end", "duration", "milestone")
|
fields = ("id", "child", "start", "end", "duration", "milestone", "tags")
|
||||||
|
|
||||||
|
|
||||||
class WeightSerializer(CoreModelSerializer):
|
class WeightSerializer(CoreModelSerializer, TaggableSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Weight
|
model = models.Weight
|
||||||
fields = ("id", "child", "weight", "date", "notes")
|
fields = ("id", "child", "weight", "date", "notes", "tags")
|
||||||
|
|
||||||
|
|
||||||
class HeightSerializer(CoreModelSerializer):
|
class HeightSerializer(CoreModelSerializer, TaggableSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Height
|
model = models.Height
|
||||||
fields = ("id", "child", "height", "date", "notes")
|
fields = ("id", "child", "height", "date", "notes", "tags")
|
||||||
|
|
||||||
|
|
||||||
class HeadCircumferenceSerializer(CoreModelSerializer):
|
class HeadCircumferenceSerializer(CoreModelSerializer, TaggableSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.HeadCircumference
|
model = models.HeadCircumference
|
||||||
fields = ("id", "child", "head_circumference", "date", "notes")
|
fields = ("id", "child", "head_circumference", "date", "notes", "tags")
|
||||||
|
|
||||||
|
|
||||||
class BMISerializer(CoreModelSerializer):
|
class BMISerializer(CoreModelSerializer, TaggableSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.BMI
|
model = models.BMI
|
||||||
fields = ("id", "child", "bmi", "date", "notes")
|
fields = ("id", "child", "bmi", "date", "notes", "tags")
|
||||||
|
|
||||||
|
|
||||||
class TagSerializer(serializers.HyperlinkedModelSerializer):
|
class TagSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
Loading…
Reference in New Issue