svthalia/concrexit

View on GitHub
website/thaliawebsite/api/v2/fields/current_member.py

Summary

Maintainability
A
0 mins
Test Coverage
class CurrentMemberDefault:
    """A default class that can be used to represent the current member.

    In order to use this, the 'request' must have been provided as part
    of the context dictionary when instantiating the serializer.
    """

    requires_context = True

    def __call__(self, serializer_field):
        return serializer_field.context["request"].member

    def __repr__(self):
        return f"{self.__class__.__name__}()"