From e00bd72a58b61133d3e9526b7b16595db9a4b92a Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Sun, 8 Feb 2026 11:52:54 +0330 Subject: [PATCH] fix --> error of weasy priny --- apps/tag/web/api/v1/api.py | 67 +++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/apps/tag/web/api/v1/api.py b/apps/tag/web/api/v1/api.py index 55460ea..430b62b 100644 --- a/apps/tag/web/api/v1/api.py +++ b/apps/tag/web/api/v1/api.py @@ -1,15 +1,12 @@ import typing from django.db import transaction -from django.http import HttpResponse -from django.template.loader import render_to_string from rest_framework import status from rest_framework import viewsets from rest_framework.decorators import action from rest_framework.exceptions import APIException from rest_framework.filters import SearchFilter from rest_framework.response import Response -from weasyprint import HTML from apps.authentication.api.v1.api import GeneralOTPViewSet from apps.authorization import models as authorize_models @@ -32,6 +29,9 @@ from .serializers import ( ) +# from weasyprint import HTML + + class TagViewSet(BaseViewSet, TagService, SoftDeleteMixin, DynamicSearchMixin, viewsets.ModelViewSet): """ Tag View Set """ queryset = tag_models.Tag.objects.all() @@ -712,36 +712,36 @@ class TagDistributionBatchViewSet( return Response(dashboard_data, status=status.HTTP_200_OK) - @action( - methods=['get'], - detail=True, - url_path='distribution_pdf_view', - url_name='distribution_pdf_view', - name='distribution_pdf_view', - ) - def distribution_pdf_view(self, request, pk=None): - batch = tag_models.TagDistributionBatch.objects.select_related( - 'assigner_org', 'assigned_org' - ).prefetch_related('distributions').get(id=pk) - - html_string = render_to_string( - 'pdf/tag_distribution.html', # noqa - {'batch': batch} - ) - - html = HTML( - string=html_string, - base_url=request.build_absolute_uri('/') - ) - - pdf = html.write_pdf() - - response = HttpResponse(pdf, content_type='application/pdf') - response['Content-Disposition'] = ( - f'inline; filename="distribution_{batch.dist_batch_identity}.pdf"' - ) - - return response + # @action( + # methods=['get'], + # detail=True, + # url_path='distribution_pdf_view', + # url_name='distribution_pdf_view', + # name='distribution_pdf_view', + # ) + # def distribution_pdf_view(self, request, pk=None): + # batch = tag_models.TagDistributionBatch.objects.select_related( + # 'assigner_org', 'assigned_org' + # ).prefetch_related('distributions').get(id=pk) + # + # html_string = render_to_string( + # 'pdf/tag_distribution.html', # noqa + # {'batch': batch} + # ) + # + # html = HTML( + # string=html_string, + # base_url=request.build_absolute_uri('/') + # ) + # + # pdf = html.write_pdf() + # + # response = HttpResponse(pdf, content_type='application/pdf') + # response['Content-Disposition'] = ( + # f'inline; filename="distribution_{batch.dist_batch_identity}.pdf"' + # ) + # + # return response @action( methods=['post', ], @@ -770,6 +770,7 @@ class TagDistributionBatchViewSet( @action( methods=['post'], + detail=True, url_path='accept_exit_doc', url_name='accept_exit_doc', name='accept_exit_doc',