2022-10-08 13:52:49 +03:00
|
|
|
from rest_framework import serializers
|
2022-10-08 17:14:19 +03:00
|
|
|
from ..service import create_season
|
2022-10-08 13:52:49 +03:00
|
|
|
from users.models import User
|
|
|
|
|
|
|
|
|
|
|
|
class UserSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = [
|
|
|
|
"about",
|
|
|
|
"name",
|
|
|
|
"type",
|
|
|
|
"telegram",
|
|
|
|
"password",
|
|
|
|
"salary",
|
|
|
|
"respect",
|
|
|
|
"wallet_public_key",
|
|
|
|
]
|
|
|
|
extra_kwargs = {
|
|
|
|
"password": {"write_only": True},
|
|
|
|
"wallet_public_key": {"read_only": True},
|
|
|
|
}
|
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
user = User.objects.create(
|
|
|
|
**validated_data, username=validated_data["telegram"]
|
|
|
|
)
|
|
|
|
return user
|
2022-10-08 17:14:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
class CreateSeasonSerializer(serializers.Serializer):
|
|
|
|
created = serializers.BooleanField(read_only=True)
|
|
|
|
def create(self, *args, **kwargs):
|
|
|
|
create_season()
|
|
|
|
return {'created': True}
|