from rest_framework.generics import UpdateAPIView

from core.http.models import User
from core.http.serializers.user import (
    UserAvatarUpdateSerializer,
    UserUpdateSerializer,
)


class UserUpdateView(UpdateAPIView):
    serializer_class = UserUpdateSerializer
    queryset = User.objects.all()

    def get_object(self):
        return self.request.user

    def perform_update(self, serializer):
        serializer.save(user=self.request.user)


class UserAvatarUpdateView(UpdateAPIView):
    serializer_class = UserAvatarUpdateSerializer
    queryset = User.objects.all()

    def get_object(self):
        return self.request.user

    def perform_update(self, serializer):
        serializer.save(user=self.request.user)
