update excel warehouse

This commit is contained in:
7nimor
2025-07-31 11:34:26 +03:30
parent 3073e2b54a
commit f443c195d8
3 changed files with 100 additions and 243 deletions

View File

@@ -34,22 +34,27 @@ class QuotaDistributionExcelViewSet(viewsets.ModelViewSet):
product = self.queryset
query = request.query_params
organization = get_organization_by_user(request.user)
description_name = ''
if query.get('param') == 'assigned':
product = product.filter(
Q(assigned_organization=organization)
).order_by('-modify_date')
description_name='سهمیه'
elif query.get('param') == 'assigner':
product = product.filter(
Q(assigner_organization=organization)
).order_by('-modify_date')
description_name = 'توزیع'
elif query.get('param') == 'all':
product = product.filter(
Q(assigner_organization=organization) |
Q(assigned_organization=organization)
).order_by('-modify_date')
description_name = ''
ser_data = distribution_serializers.QuotaDistributionSerializer(product, many=True).data
excel_options = [
@@ -80,7 +85,7 @@ class QuotaDistributionExcelViewSet(viewsets.ModelViewSet):
create_header(worksheet, header_list, 5, 2, height=20, border_style='thin')
excel_description(worksheet, 'B1', f'سهمیه', row2='C3')
excel_description(worksheet, 'B1', f'{description_name}', row2='C3')
create_header_freez(worksheet, excel_options, 1, 6, 7, height=22, width=20)
@@ -152,7 +157,7 @@ class QuotaDistributionExcelViewSet(viewsets.ModelViewSet):
response = HttpResponse(
content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
response[
'Content-Disposition'] = f'attachment; filename="اختلاف کشتار.xlsx"'.encode(
'Content-Disposition'] = f'attachment; filename="سهمیه.xlsx"'.encode(
'utf-8')
response.write(output.getvalue())
return response