# -*- coding: utf-8 -*-
from rest_framework import serializers
from .models import *

# import collections
# from rest_framework.fields import CurrentUserDefault
# from snippets.models import Snippet, LANGUAGE_CHOICES,STYLE_CHOICES,Category,Item
# from django.contrib.auth.models import User
# from rest_framework.relations import PKOnlyObject


class CategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Category
        fields = "__all__"


class CompanySerializer(serializers.ModelSerializer):
    # article_comments = serializers.PrimaryKeyRelatedField(many=True, required=False, read_only=True)
    # user = serializers.HiddenField(default=serializers.CurrentUserDefault())
    #parent = serializers.PrimaryKeyRelatedField(queryset=Company.objects.all(), required=True)
    #parent_id = serializers.CharField(source='parent.name', read_only=True)
    #parent = serializers.PrimaryKeyRelatedField(queryset=Company.objects.all(), required=True)

    #parent = PrimaryKeyRelatedField(queryset=Company.objects.all())
    #pname = serializers.SerializerMethodField('get_parent_name')
    class Meta:
        model = Company
        #fields = "__all__"
        fields = ['id', 'name', 'parent']

    #def get_parent_name(self,obj):
    #    return obj.parent.name

class CategoryPropSerializer(serializers.ModelSerializer):
    class Meta:
        model = CategoryProp
        fields = "__all__"
