import --> first steps of tag distribution
This commit is contained in:
@@ -11,6 +11,7 @@ VISIBILITY_MAP = {
|
|||||||
'rancher': 'organization',
|
'rancher': 'organization',
|
||||||
'rancherorganizationlink': 'organization', # noqa
|
'rancherorganizationlink': 'organization', # noqa
|
||||||
'tagbatch': 'organization', # noqa
|
'tagbatch': 'organization', # noqa
|
||||||
|
'tagdistribution': ['assigner_org', 'assigned_org']
|
||||||
|
|
||||||
# 'deviceactivationcode': 'organization',
|
# 'deviceactivationcode': 'organization',
|
||||||
# 'deviceversion': 'organization',
|
# 'deviceversion': 'organization',
|
||||||
|
|||||||
6
apps/tag/services/tag_distribution_services.py
Normal file
6
apps/tag/services/tag_distribution_services.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
class TagDistributionService:
|
||||||
|
"""
|
||||||
|
service of distribute tags in organizations
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
@@ -347,3 +347,25 @@ class TagBatchViewSet(BaseViewSet, SoftDeleteMixin, DynamicSearchMixin, viewsets
|
|||||||
class TagDistributionViewSet(BaseViewSet, SoftDeleteMixin, DynamicSearchMixin, viewsets.ModelViewSet):
|
class TagDistributionViewSet(BaseViewSet, SoftDeleteMixin, DynamicSearchMixin, viewsets.ModelViewSet):
|
||||||
queryset = tag_models.TagDistribution.objects.all()
|
queryset = tag_models.TagDistribution.objects.all()
|
||||||
serializer_class = TagDistributionSerializer
|
serializer_class = TagDistributionSerializer
|
||||||
|
filter_backends = [SearchFilter]
|
||||||
|
search_fields = [
|
||||||
|
'batch__batch_identity',
|
||||||
|
'tag__tag_code',
|
||||||
|
'assigner_org__name',
|
||||||
|
'assigned_org__name',
|
||||||
|
'species_code',
|
||||||
|
]
|
||||||
|
|
||||||
|
def list(self, request, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
list of tag distributions
|
||||||
|
"""
|
||||||
|
queryset = self.get_queryset(visibility_by_org_scope=True).order_by('-create_date')
|
||||||
|
|
||||||
|
queryset = self.filter_queryset(self.filter_query(queryset))
|
||||||
|
|
||||||
|
page = self.paginate_queryset(queryset)
|
||||||
|
if page is not None: # noqa
|
||||||
|
serializer = self.get_serializer(page, many=True)
|
||||||
|
return self.get_paginated_response(serializer.data)
|
||||||
|
return Response(self.serializer_class(queryset).data)
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ class TagDistributionSerializer(serializers.ModelSerializer):
|
|||||||
representation = super().to_representation(instance)
|
representation = super().to_representation(instance)
|
||||||
|
|
||||||
representation['batch'] = {
|
representation['batch'] = {
|
||||||
|
'id': instance.batch.id,
|
||||||
'batch_creator': instance.batch.organization.name,
|
'batch_creator': instance.batch.organization.name,
|
||||||
'batch_identity': instance.batch.batch_identity
|
'batch_identity': instance.batch.batch_identity
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user