from django.contrib.auth.models import User
from rest_framework import serializers
from .models import Match, Club, Tournament, Team, Player


class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ['url', 'username', 'email']

class ClubSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Club
        fields = ['id', 'name', 'header', 'footer']

class TournamentSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Tournament
        fields = ['id', 'name', 'club', 'auto_scrolling', 'shortname', 'tournament_index']

class MatchSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Match
        fields = ['id', 'court', 'match_index', 'tournament', 'date', 'enddate', 'title', 'refreshrate', 'team1', 'team2', 'team3', 'team4', 'team5', 'hasWalkOutTeam',
        'team1scorecolumn1', 'team1scorecolumn2', 'team1scorecolumn3', 'team1scorecolumn4', 'team1scorecolumn5',
        'team2scorecolumn1', 'team2scorecolumn2', 'team2scorecolumn3', 'team2scorecolumn4', 'team2scorecolumn5', 'teamOne', 'teamTwo']

class TeamSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Team
        fields = ['id', 'name', 'background_color', 'rank', 'position', 'position_finale', 'bracket', 'position_label', 'date_label', 'couleur_finale', 'points_label', 'tournament']

class PlayerSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Player
        fields = ['id', 'name', 'rank', 'club_name', 'ligue_name', 'team']
