You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
from rest_framework import serializers
|
|
|
|
from service import models
|
|
from service.service import PointService
|
|
|
|
|
|
class PlacementPointSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = models.PlacementPoint
|
|
fields = '__all__'
|
|
|
|
def to_representation(self, instance):
|
|
representation = super().to_representation(instance)
|
|
min_distances = PointService.get_min_distances_to_group(instance.id)
|
|
representation['min_distance_to_group'] = min_distances
|
|
return representation
|
|
|
|
|
|
class PostAndPVZGroupSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = models.Post_and_pvzGroup
|
|
fields = '__all__'
|
|
|
|
|
|
class PostAndPVZCategorySerializer(serializers.ModelSerializer):
|
|
groups = PostAndPVZGroupSerializer(read_only=True, many=True)
|
|
|
|
class Meta:
|
|
model = models.Post_and_pvzCategory
|
|
fields = '__all__'
|
|
|
|
|
|
class OtherObjectsGroupSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = models.OtherObjectsGroup
|
|
fields = '__all__'
|
|
|
|
|
|
class OtherObjectsCategorySerializer(serializers.ModelSerializer):
|
|
groups = OtherObjectsGroupSerializer(many=True, read_only=True)
|
|
|
|
class Meta:
|
|
model = models.OtherObjectsCategory
|
|
fields = '__all__'
|
|
|
|
|
|
class RayonSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = models.AO
|
|
fields = '__all__'
|
|
|
|
|
|
class AOSerializer(serializers.ModelSerializer):
|
|
rayons = RayonSerializer(many=True, read_only=True)
|
|
|
|
class Meta:
|
|
model = models.AO
|
|
fields = '__all__'
|