InvenTree/InvenTree/company/serializers.py

50 lines
1.1 KiB
Python
Raw Normal View History

2019-04-27 15:09:48 +00:00
"""
2019-04-27 12:18:07 +00:00
JSON serializers for Company app
"""
2017-04-14 04:45:17 +00:00
from rest_framework import serializers
from .models import Company
2017-04-14 04:45:17 +00:00
2018-04-23 11:18:35 +00:00
class CompanyBriefSerializer(serializers.ModelSerializer):
2019-04-27 12:18:07 +00:00
""" Serializer for Company object (limited detail) """
url = serializers.CharField(source='get_absolute_url', read_only=True)
class Meta:
model = Company
fields = [
'pk',
'url',
'name'
]
2019-04-13 23:30:45 +00:00
class CompanySerializer(serializers.ModelSerializer):
2019-04-27 12:18:07 +00:00
""" Serializer for Company object (full detail) """
2017-04-14 04:45:17 +00:00
2018-05-02 13:17:24 +00:00
url = serializers.CharField(source='get_absolute_url', read_only=True)
part_count = serializers.CharField(read_only=True)
2018-05-02 13:17:24 +00:00
2017-04-14 04:45:17 +00:00
class Meta:
2018-04-18 23:01:07 +00:00
model = Company
fields = [
'id',
'url',
'name',
'description',
'website',
'name',
'phone',
'address',
'email',
'contact',
'URL',
'image',
'notes',
'is_customer',
'is_supplier',
'part_count'
]