fix - change distribution lists & inventory entry
This commit is contained in:
@@ -95,36 +95,29 @@ class QuotaDistributionViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewS
|
|||||||
def my_distributions(self, request):
|
def my_distributions(self, request):
|
||||||
""" list of my distributions """
|
""" list of my distributions """
|
||||||
|
|
||||||
queryset = self.filter_query(
|
|
||||||
self.get_queryset(visibility_by_org_scope=True)) # return by search param or all objects
|
|
||||||
organization = get_organization_by_user(request.user)
|
organization = get_organization_by_user(request.user)
|
||||||
|
if organization.free_visibility_by_scope:
|
||||||
query = self.request.query_params
|
queryset = self.filter_query(self.get_queryset(visibility_by_org_scope=True))
|
||||||
if query.get('param') == 'assigned':
|
else:
|
||||||
# paginate queryset
|
queryset = self.filter_query(self.get_queryset()) # return by search param or all objects
|
||||||
page = self.paginate_queryset(
|
query = self.request.query_params # noqa
|
||||||
queryset.filter(
|
if query.get('param') == 'assigned':
|
||||||
|
queryset = queryset.filter(
|
||||||
Q(assigned_organization=organization)
|
Q(assigned_organization=organization)
|
||||||
).order_by('-modify_date')
|
).order_by('-modify_date')
|
||||||
)
|
|
||||||
|
|
||||||
elif query.get('param') == 'assigner':
|
elif query.get('param') == 'assigner':
|
||||||
# paginate queryset
|
queryset = queryset.filter(
|
||||||
page = self.paginate_queryset(
|
|
||||||
queryset.filter(
|
|
||||||
Q(assigner_organization=organization)
|
Q(assigner_organization=organization)
|
||||||
).order_by('-modify_date')
|
).order_by('-modify_date')
|
||||||
)
|
|
||||||
|
|
||||||
elif query.get('param') == 'all':
|
elif query.get('param') == 'all':
|
||||||
# paginate queryset
|
queryset = queryset.filter(
|
||||||
page = self.paginate_queryset(
|
|
||||||
queryset.filter(
|
|
||||||
Q(assigner_organization=organization) |
|
Q(assigner_organization=organization) |
|
||||||
Q(assigned_organization=organization)
|
Q(assigned_organization=organization)
|
||||||
).order_by('-modify_date')
|
).order_by('-modify_date')
|
||||||
)
|
|
||||||
|
|
||||||
|
page = self.paginate_queryset(queryset)
|
||||||
if page is not None: # noqa
|
if page is not None: # noqa
|
||||||
serializer = self.get_serializer(page, many=True) # noqa
|
serializer = self.get_serializer(page, many=True) # noqa
|
||||||
return self.get_paginated_response(serializer.data)
|
return self.get_paginated_response(serializer.data)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from common.helpers import get_organization_by_user
|
|||||||
from common.liara_tools import upload_to_liara
|
from common.liara_tools import upload_to_liara
|
||||||
|
|
||||||
|
|
||||||
class InventoryEntryViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
class InventoryEntryViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||||
queryset = warehouse_models.InventoryEntry.objects.all()
|
queryset = warehouse_models.InventoryEntry.objects.all()
|
||||||
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
||||||
# filter_backends = [filters.SearchFilter]
|
# filter_backends = [filters.SearchFilter]
|
||||||
@@ -115,12 +115,15 @@ class InventoryEntryViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearc
|
|||||||
def my_inventory_entries(self, request):
|
def my_inventory_entries(self, request):
|
||||||
""" list of my inventory entries """
|
""" list of my inventory entries """
|
||||||
|
|
||||||
entries = self.queryset.filter(organization=get_organization_by_user(request.user))
|
org = get_organization_by_user(request.user)
|
||||||
|
entries = self.get_queryset(
|
||||||
|
visibility_by_org_scope=True
|
||||||
|
) if org.free_visibility_by_scope else self.get_queryset().filter(organization=org)
|
||||||
queryset = self.filter_query(entries) # return by search param or all objects
|
queryset = self.filter_query(entries) # return by search param or all objects
|
||||||
|
|
||||||
# paginate & response
|
# paginate & response
|
||||||
page = self.paginate_queryset(queryset)
|
page = self.paginate_queryset(queryset)
|
||||||
if page is not None:
|
if page is not None: # noqa
|
||||||
serializer = self.get_serializer(page, many=True)
|
serializer = self.get_serializer(page, many=True)
|
||||||
return self.get_paginated_response(serializer.data)
|
return self.get_paginated_response(serializer.data)
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
|||||||
'sale_unit': instance.distribution.quota.sale_unit.unit,
|
'sale_unit': instance.distribution.quota.sale_unit.unit,
|
||||||
'id': instance.distribution.id
|
'id': instance.distribution.id
|
||||||
}
|
}
|
||||||
|
representation['product'] = {
|
||||||
|
'name': instance.distribution.quota.product.name
|
||||||
|
}
|
||||||
|
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
|
|||||||
@@ -676,3 +676,8 @@ AssertionError: .validate() should return the validated data
|
|||||||
[2025-11-02 12:28:52,726] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\api.py changed, reloading.
|
[2025-11-02 12:28:52,726] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\api.py changed, reloading.
|
||||||
[2025-11-02 12:28:55,700] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
[2025-11-02 12:28:55,700] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||||
[2025-11-02 12:29:03,247] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\product\web\api\v1\viewsets\quota_distribution_api.py changed, reloading.
|
[2025-11-02 12:29:03,247] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\product\web\api\v1\viewsets\quota_distribution_api.py changed, reloading.
|
||||||
|
[2025-11-02 12:29:05,099] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||||
|
[2025-11-02 13:35:31,657] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\product\web\api\v1\viewsets\quota_distribution_api.py changed, reloading.
|
||||||
|
[2025-11-02 13:35:36,007] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||||
|
[2025-11-02 13:45:12,453] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\warehouse\web\api\v1\serializers.py changed, reloading.
|
||||||
|
[2025-11-02 13:45:15,794] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||||
|
|||||||
Reference in New Issue
Block a user