update excel
This commit is contained in:
16
app/views.py
16
app/views.py
@@ -4510,10 +4510,8 @@ class AllProductsTransportViewSet(viewsets.ModelViewSet):
|
||||
pagination_class = CustomPagination
|
||||
filterset_class = AllProductsTransportFilterSet
|
||||
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
transports = self.filter_queryset(self.get_queryset())
|
||||
|
||||
filters = {"trash": False}
|
||||
product_type = request.GET.get('product_type')
|
||||
destination_province = request.GET.get('destination_province')
|
||||
date1 = request.GET.get('date1')
|
||||
@@ -4521,21 +4519,23 @@ class AllProductsTransportViewSet(viewsets.ModelViewSet):
|
||||
search = request.GET.get('search')
|
||||
|
||||
if product_type and product_type != 'undefined':
|
||||
transports = transports.filter(product=product_type)
|
||||
filters['product'] = product_type
|
||||
|
||||
if destination_province and destination_province != 'undefined':
|
||||
transports = transports.filter(destination_province=destination_province)
|
||||
filters['destination_province'] = destination_province
|
||||
|
||||
if date1 and date2 and date1 != 'undefined' and date2 != 'undefined':
|
||||
try:
|
||||
start_date = datetime.datetime.strptime(str(date1), '%Y-%m-%d')
|
||||
end_date = datetime.datetime.strptime(str(date2), '%Y-%m-%d')
|
||||
transports = transports.filter(date__gte=start_date, date__lte=end_date)
|
||||
filters['date__gte'] = start_date
|
||||
filters['date__lte'] = end_date
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if search:
|
||||
if search != 'undefined' and search.strip():
|
||||
transports = AllProductsTransport.objects.filter(**filters).order_by('-date', '-create_date')
|
||||
|
||||
if search and search != 'undefined' and search.strip():
|
||||
transports = transports.filter(
|
||||
build_query(self.filterset_class.Meta.fields, search)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user