med/media/serializers.py

67 lines
1.5 KiB
Python
Raw Normal View History

2019-08-17 10:12:10 +00:00
from rest_framework import serializers
2021-10-23 16:31:03 +00:00
from .models import Author, CD, Comic, FutureMedium, Manga, Emprunt, Game, \
Novel, Review, Vinyl
2019-08-17 10:12:10 +00:00
2021-10-23 16:31:03 +00:00
class AuthorSerializer(serializers.ModelSerializer):
2019-08-17 10:12:10 +00:00
class Meta:
2021-10-23 16:31:03 +00:00
model = Author
2019-08-17 10:12:10 +00:00
fields = ['url', 'name']
2021-10-23 16:31:03 +00:00
class ComicSerializer(serializers.ModelSerializer):
2019-08-17 10:12:10 +00:00
class Meta:
2021-10-23 16:31:03 +00:00
model = Comic
2020-09-25 08:27:43 +00:00
fields = '__all__'
class MangaSerializer(serializers.ModelSerializer):
class Meta:
model = Manga
fields = '__all__'
class CDSerializer(serializers.ModelSerializer):
class Meta:
model = CD
fields = '__all__'
2021-10-23 16:31:03 +00:00
class VinylSerializer(serializers.ModelSerializer):
2020-09-25 08:27:43 +00:00
class Meta:
2021-10-23 16:31:03 +00:00
model = Vinyl
2020-09-25 08:27:43 +00:00
fields = '__all__'
2021-10-23 16:31:03 +00:00
class NovelSerializer(serializers.ModelSerializer):
2020-09-25 08:27:43 +00:00
class Meta:
2021-10-23 16:31:03 +00:00
model = Novel
2020-09-25 08:27:43 +00:00
fields = '__all__'
2021-10-23 16:31:03 +00:00
class ReviewSerializer(serializers.ModelSerializer):
2020-09-25 08:27:43 +00:00
class Meta:
2021-10-23 16:31:03 +00:00
model = Review
2020-09-25 08:27:43 +00:00
fields = '__all__'
2021-10-23 16:31:03 +00:00
class FutureMediumSerializer(serializers.ModelSerializer):
2020-09-25 08:27:43 +00:00
class Meta:
2021-10-23 16:31:03 +00:00
model = FutureMedium
2020-09-25 08:27:43 +00:00
fields = '__all__'
2019-08-17 10:12:10 +00:00
class EmpruntSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Emprunt
fields = ['url', 'media', 'user', 'date_emprunt', 'date_rendu',
'permanencier_emprunt', 'permanencier_rendu']
2021-10-23 16:31:03 +00:00
class GameSerializer(serializers.HyperlinkedModelSerializer):
2019-08-17 10:12:10 +00:00
class Meta:
2021-10-23 16:31:03 +00:00
model = Game
2019-08-17 10:12:10 +00:00
fields = ['url', 'name', 'proprietaire', 'duree', 'nombre_joueurs_min',
'nombre_joueurs_max', 'comment']