# Path: accounts/models.py
# class UserTeamRequest(models.Model):
#     user = models.ForeignKey(User, on_delete=models.CASCADE)
#     team = models.ForeignKey(Team, on_delete=models.CASCADE)
#     datetime = models.DateTimeField(auto_now=True)
#     status = models.CharField(max_length=1, default='P', choices=(
#         ('P', 'Pending'),
#         ('A', 'Accepted'),
#         ('R', 'Rejected'),
#     ))
# 
#     objects = UserTeamRequestQuerySet.as_manager()
# 
#     def clean(self):
#         if not user_without_team(self.user):
#             raise ValidationError('User is already a team member')
# 
#         if self.status == 'P' and self.user.userteamrequest_set.filter(status='P').exists():
#             raise ValidationError('Other pending request exists')
# 
#         if self.status == 'P' and self.user.userteamrequest_set.filter(status='A').exists():
#             raise ValidationError('Other accepted request exists')


from rest_framework import serializers
from .models import UserTeamRequest



class UserTeamRequestCreateSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserTeamRequest
        fields = ('team',)



class UserTeamRequestListSerializer(serializers.ModelSerializer):

    class Meta:

# Path: accounts/models.py
# class UserTeamRequest(models.Model):
#     user = models.ForeignKey(User, on_delete=models.CASCADE)
#     team = models.ForeignKey(Team, on_delete=models.CASCADE)
#     datetime = models.DateTimeField(auto_now=True)
#     status = models.CharField(max_length=1, default='P', choices=(
#         ('P', 'Pending'),
#         ('A', 'Accepted'),
#         ('R', 'Rejected'),
#     ))
# 
#     objects = UserTeamRequestQuerySet.as_manager()
# 
#     def clean(self):
#         if not user_without_team(self.user):
#             raise ValidationError('User is already a team member')
# 
#         if self.status == 'P' and self.user.userteamrequest_set.filter(status='P').exists():
#             raise ValidationError('Other pending request exists')
# 
#         if self.status == 'P' and self.user.userteamrequest_set.filter(status='A').exists():
#             raise ValidationError('Other accepted request exists')


# Path: accounts/serializers.py
from rest_framework import serializers
from .models import UserTeamRequest




class UserTeamRequestCreateSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserTeamRequest
        fields = ('team',)



class UserTeamRequestListSerializer(serializers.ModelSerializer):

    class Meta:

        model = UserTeamRequest