Commit 6f97c5d6 authored by John Red Medrano's avatar John Red Medrano

Merge pull request #507 in RMS/api-main-service from red-develop to RMSv2

* commit 'e059317a':
  testing html to pdf
parents 64bb9c4a e059317a
...@@ -37,7 +37,7 @@ from django.core.files.base import ContentFile ...@@ -37,7 +37,7 @@ from django.core.files.base import ContentFile
config = configparser.ConfigParser() config = configparser.ConfigParser()
config_file = os.path.join('./', 'env.ini') config_file = os.path.join('./', 'env.ini')
config.read(config_file) config.read(config_file)
from django.conf import settings
class BatchUploadViewSet(viewsets.ModelViewSet): class BatchUploadViewSet(viewsets.ModelViewSet):
queryset = ExtractTransformLoad.objects.all() queryset = ExtractTransformLoad.objects.all()
...@@ -98,11 +98,18 @@ class BatchUploadViewSet(viewsets.ModelViewSet): ...@@ -98,11 +98,18 @@ class BatchUploadViewSet(viewsets.ModelViewSet):
return self.get_paginated_response(message) return self.get_paginated_response(message)
@action(
detail=False, methods=['get'],
url_path='pdf-instruction', name='how to upload bulk users'
)
def testpdf(self, request, code=None):
return sender.to_pdf()
@action( @action(
detail=False, methods=['get'], detail=False, methods=['get'],
url_path='user-instruction', name='how to upload bulk users' url_path='user-instruction', name='how to upload bulk users'
) )
def UserInstruction(self, request, code=None): def UserInstruction(self, request, code=None):
sender.to_pdf()
self.serializer_class = BatchUploadSerializer self.serializer_class = BatchUploadSerializer
queryset = MasterAttachment.objects.filter( queryset = MasterAttachment.objects.filter(
url__contains=config['SETTINGS']['BATCH_UPLOAD_FORMAT_FILENAME'] url__contains=config['SETTINGS']['BATCH_UPLOAD_FORMAT_FILENAME']
......
...@@ -5,6 +5,20 @@ from app.entities import models ...@@ -5,6 +5,20 @@ from app.entities import models
from django.conf import settings from django.conf import settings
from django.core import mail as email_connection from django.core import mail as email_connection
from django.db import transaction from django.db import transaction
# from weasyprint import HTML
from io import BytesIO
from django.http import HttpResponse
from django.template.loader import get_template
from xhtml2pdf import pisa
def to_pdf():
F = open(os.path.join(settings.EMAIL_TEMPLATES_ROOT, 'RMS-NEWUSER.html'), 'r')
result = BytesIO()
pdf = pisa.pisaDocument(F, result)
if not pdf.err:
return HttpResponse(result.getvalue(), content_type='application/pdf')
return None
@transaction.atomic @transaction.atomic
......
aioredis==1.2.0 aioredis==1.2.0
asgiref==3.2.2 asgiref==3.2.2
asn1crypto==0.24.0 asn1crypto==0.24.0
astroid==2.2.5 astroid==2.2.5
async-timeout==3.0.1 async-timeout==3.0.1
attrs==19.1.0 attrs==19.1.0
autobahn==19.9.2 autobahn==19.9.2
Automat==0.7.0 Automat==0.7.0
certifi==2019.6.16 cairocffi==1.1.0
CairoSVG==2.4.2
certifi==2019.6.16
cffi==1.12.3 cffi==1.12.3
channels==2.2.0 channels==2.2.0
channels-redis==2.4.0 channels-redis==2.4.0
chardet==3.0.4 chardet==3.0.4
colorama==0.4.1 colorama==0.4.1
constantly==15.1.0 constantly==15.1.0
cryptography==2.7 cryptography==2.7
cssselect2==0.2.2
daphne==2.3.0 daphne==2.3.0
defusedxml==0.6.0
Django==2.2 Django==2.2
django-cors-headers==2.5.2 django-cors-headers==2.5.2
django-filter==2.1.0 django-filter==2.1.0
djangorestframework==3.9.2 djangorestframework==3.9.2
drf-renderer-xlsx==0.3.3
drf-writable-nested==0.5.1 drf-writable-nested==0.5.1
et-xmlfile==1.0.1 et-xmlfile==1.0.1
gevent==1.4.0 gevent==1.4.0
greenlet==0.4.15 greenlet==0.4.15
hiredis==1.0.0 hiredis==1.0.0
html5lib==1.0.1
hyperlink==19.0.0 hyperlink==19.0.0
idna==2.8 idna==2.8
incremental==17.5.0 incremental==17.5.0
...@@ -33,7 +39,6 @@ lazy-object-proxy==1.3.1 ...@@ -33,7 +39,6 @@ lazy-object-proxy==1.3.1
Markdown==3.1 Markdown==3.1
mccabe==0.6.1 mccabe==0.6.1
msgpack==0.6.1 msgpack==0.6.1
drf-renderer-xlsx==0.3.3
mysqlclient==1.4.2.post1 mysqlclient==1.4.2.post1
numpy==1.17.3 numpy==1.17.3
openpyxl==3.0.0 openpyxl==3.0.0
...@@ -44,16 +49,22 @@ pycodestyle==2.5.0 ...@@ -44,16 +49,22 @@ pycodestyle==2.5.0
pycparser==2.19 pycparser==2.19
PyHamcrest==1.9.0 PyHamcrest==1.9.0
pylint==2.3.1 pylint==2.3.1
PyPDF2==1.26.0
Pyphen==0.9.5
python-dateutil==2.8.1 python-dateutil==2.8.1
pytz==2018.9 pytz==2018.9
reportlab==3.5.32
requests==2.22.0 requests==2.22.0
six==1.12.0 six==1.12.0
sqlparse==0.3.0 sqlparse==0.3.0
tinycss2==1.0.2
Twisted==19.7.0 Twisted==19.7.0
txaio==18.8.1 txaio==18.8.1
typed-ast==1.3.1 typed-ast==1.3.1
urllib3==1.25.3 urllib3==1.25.3
webencodings==0.5.1
websocket==0.2.1 websocket==0.2.1
websocket-client==0.54.0 websocket-client==0.54.0
wrapt==1.11.1 wrapt==1.11.1
zope.interface==4.6.0 xhtml2pdf==0.2.3
\ No newline at end of file zope.interface==4.6.0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment