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):
|
||||
""" 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)
|
||||
|
||||
query = self.request.query_params
|
||||
if organization.free_visibility_by_scope:
|
||||
queryset = self.filter_query(self.get_queryset(visibility_by_org_scope=True))
|
||||
else:
|
||||
queryset = self.filter_query(self.get_queryset()) # return by search param or all objects
|
||||
query = self.request.query_params # noqa
|
||||
if query.get('param') == 'assigned':
|
||||
# paginate queryset
|
||||
page = self.paginate_queryset(
|
||||
queryset.filter(
|
||||
queryset = queryset.filter(
|
||||
Q(assigned_organization=organization)
|
||||
).order_by('-modify_date')
|
||||
)
|
||||
|
||||
elif query.get('param') == 'assigner':
|
||||
# paginate queryset
|
||||
page = self.paginate_queryset(
|
||||
queryset.filter(
|
||||
queryset = queryset.filter(
|
||||
Q(assigner_organization=organization)
|
||||
).order_by('-modify_date')
|
||||
)
|
||||
|
||||
elif query.get('param') == 'all':
|
||||
# paginate queryset
|
||||
page = self.paginate_queryset(
|
||||
queryset.filter(
|
||||
queryset = queryset.filter(
|
||||
Q(assigner_organization=organization) |
|
||||
Q(assigned_organization=organization)
|
||||
).order_by('-modify_date')
|
||||
)
|
||||
|
||||
page = self.paginate_queryset(queryset)
|
||||
if page is not None: # noqa
|
||||
serializer = self.get_serializer(page, many=True) # noqa
|
||||
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
|
||||
|
||||
|
||||
class InventoryEntryViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
class InventoryEntryViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
queryset = warehouse_models.InventoryEntry.objects.all()
|
||||
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
||||
# filter_backends = [filters.SearchFilter]
|
||||
@@ -115,12 +115,15 @@ class InventoryEntryViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearc
|
||||
def my_inventory_entries(self, request):
|
||||
""" 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
|
||||
|
||||
# paginate & response
|
||||
page = self.paginate_queryset(queryset)
|
||||
if page is not None:
|
||||
if page is not None: # noqa
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
||||
'sale_unit': instance.distribution.quota.sale_unit.unit,
|
||||
'id': instance.distribution.id
|
||||
}
|
||||
representation['product'] = {
|
||||
'name': instance.distribution.quota.product.name
|
||||
}
|
||||
|
||||
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: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: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