# Path: access/serializers.py
# class PermissionSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:
# class GroupSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:
# class UserSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:


from rest_framework import serializers
from access import serializers as access_serializers
from . import models



class OrganizationSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = models.Organization
        fields = "__all__"


class PositionSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = models.Position
        fields = "__all__"


class JobSerializer(serializers.HyperlinkedModelSerializer):
    position = PositionSerializer()
    is_current = serializers.SerializerMethodField()

    def get_is_current(self, obj):
        return obj.is_current()

    class Meta:
        model = models.Job
        exclude = ('author', 'url')


class AuthorSerializer(serializers.HyperlinkedModelSerializer):
    organization = OrganizationSerializer()

# Path: access/serializers.py
# class PermissionSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:
# class GroupSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:
# class UserSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:


# Path: authors/serializers.py
from rest_framework import serializers
from access import serializers as access_serializers
from . import models




class OrganizationSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = models.Organization
        fields = "__all__"


class PositionSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = models.Position
        fields = "__all__"


class JobSerializer(serializers.HyperlinkedModelSerializer):
    position = PositionSerializer()
    is_current = serializers.SerializerMethodField()

    def get_is_current(self, obj):
        return obj.is_current()

    class Meta:
        model = models.Job
        exclude = ('author', 'url')


class AuthorSerializer(serializers.HyperlinkedModelSerializer):
    organization = OrganizationSerializer()

    positions = JobSerializer(source='job_set', many=True)