<commit_before>from django.contrib.auth import get_user_model
from rest_framework import generics, parsers, response
from rest_framework.permissions import IsAuthenticated
from rest_framework.status import HTTP_204_NO_CONTENT

from . import serializers
from user_management.api import permissions


User = get_user_model()


class ProfileAvatar(generics.RetrieveUpdateAPIView):
    """
    Retrieve and update the authenticated user's avatar. Pass get parameters to
    retrieve a thumbnail of the avatar.

    Thumbnail options are specified as get parameters. Options are:
        width: Specify the width (in pixels) to resize / crop to.
        height: Specify the height (in pixels) to resize / crop to.
        crop: Whether to crop or not [1,0]
        anchor: Where to anchor the crop [t,r,b,l]
        upscale: Whether to upscale or not [1,0]

    If no options are specified the users avatar is returned.

    To crop avatar to 100x100 anchored to the top right:
        avatar?width=100&height=100&crop=1&anchor=tr
    """
    model = User
    serializer_class = serializers.AvatarSerializer
    parser_classes = (parsers.MultiPartParser,)

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

    def delete(self, request, *args, **kwargs):
        user = self.get_object()
        # user.avatar.delete() not used due test madness it would require
        user.avatar = None
        user.save()
        return response.Response(status=HTTP_204_NO_CONTENT)
<commit_msg>Update the doc string<commit_after>from django.contrib.auth import get_user_model
from rest_framework import generics, parsers, response
from rest_framework.permissions import IsAuthenticated
from rest_framework.status import HTTP_204_NO_CONTENT

from . import serializers
from user_management.api import permissions


User = get_user_model()


class ProfileAvatar(generics.RetrieveUpdateAPIView):
    """
    Retrieve, update & delete the authenticated user's avatar. Pass get
    parameters to retrieve a thumbnail of the avatar.

    Thumbnail options are specified as get parameters. Options are:
        width: Specify the width (in pixels) to resize / crop to.
        height: Specify the height (in pixels) to resize / crop to.
        crop: Whether to crop or not [1,0]
        anchor: Where to anchor the crop [t,r,b,l]
        upscale: Whether to upscale or not [1,0]

    If no options are specified the users avatar is returned.

    To crop avatar to 100x100 anchored to the top right:
        avatar?width=100&height=100&crop=1&anchor=tr
    """
    model = User
    serializer_class = serializers.AvatarSerializer
    parser_classes = (parsers.MultiPartParser,)

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

    def delete(self, request, *args, **kwargs):
        user = self.get_object()
        # user.avatar.delete() not used due test madness it would require
        user.avatar = None
        user.save()
        return response.Response(status=HTTP_204_NO_CONTENT)

{'fraction_non_alphanumeric': 0.06961178045515395, 'fraction_numerical': 0.015394912985274432, 'mean_word_length': 3.376281112737921, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4210843', 'n_tokens_mistral': 890, 'n_tokens_neox': 828, 'n_words': 299}