diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index de76a59..0000000 --- a/.editorconfig +++ /dev/null @@ -1,21 +0,0 @@ -# http://EditorConfig.org - -root = true - -[*] -end_of_line = lf -insert_final_newline = true - -[*.{py,rst,yml}] -charset = utf-8 - -[*.py] -indent_style = space -indent_size = 4 - -[*.yml] -indent_style = space -indent_size = 2 - -[Makefile] -indent_style = tab diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 176a458..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto diff --git a/AUTHORS.rst b/AUTHORS.rst index 9860f9e..a28aae8 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -13,3 +13,9 @@ Contributors * Jon Bolt (@epicbagel) * @msaizar * @SaeX + + +Maintainer +---------- + +* olksndrdevhub \ No newline at end of file diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index a84d6d1..0afc77f 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -13,7 +13,7 @@ Types of Contributions Report Bugs ----------- -Report bugs at https://github.com/nigma/django-easy-pdf/issues. +Report bugs at https://github.com/olksndrdevhub/django-easy-pdf3/issues. If you are reporting a bug, please include: diff --git a/HISTORY.rst b/HISTORY.rst index 1abdd17..d608a01 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,16 @@ History ------- +0.1.4 (2021-01-30) +++++++++++++++++++ + +* Add Django 4 support + +0.1.2 (2021-01-30) +++++++++++++++++++ + +* Update for Django >= 2.0 <= 3.1 + 0.1.1 (2017-04-19) ++++++++++++++++++ @@ -11,4 +21,4 @@ History 0.1.0 (2014-01-24) ++++++++++++++++++ -* First release \ No newline at end of file +* First release diff --git a/README.rst b/README.rst index 221a4ce..8fe9f95 100644 --- a/README.rst +++ b/README.rst @@ -6,25 +6,26 @@ Django PDF rendering, the easy way. .. image:: https://circleci.com/gh/nigma/django-easy-pdf/tree/master.svg?style=svg :target: https://circleci.com/gh/nigma/django-easy-pdf/tree/master :alt: Build Status -.. image:: https://img.shields.io/pypi/v/django-easy-pdf.svg - :target: https://pypi.python.org/pypi/django-easy-pdf/ +.. image:: https://img.shields.io/pypi/v/django-easy-pdf3 + :target: https://pypi.python.org/pypi/django-easy-pdf3/ :alt: Latest Version .. image:: https://img.shields.io/badge/wheel-yes-green.svg - :target: https://pypi.python.org/pypi/django-easy-pdf/ + :target: https://pypi.python.org/pypi/django-easy-pdf3/ :alt: Wheel -.. image:: https://img.shields.io/pypi/l/django-easy-pdf.svg - :target: https://pypi.python.org/pypi/django-easy-pdf/ +.. image:: https://img.shields.io/pypi/l/django-easy-pdf3 + :target: https://pypi.python.org/pypi/django-easy-pdf3/ :alt: License Developed at `en.ig.ma software shop `_. Development Version ------------------- +Info: Add support for Django 4 in 0.1.4 version +Note: This fork support Django>=2.0 with "xhtml2pdf" as rendering backend! Support with WeasyPrint is not tested! Note: A new PDF rendering backend using WeasyPrint for more accurate rendering is in development under the develop branch. See https://github.com/nigma/django-easy-pdf/pull/34 for changes, testing and discussion. -If you rely on the ``xhtml2pdf`` rendering backend and templates pin the package version to ``django-easy-pdf>=0.1.1<0.2.0``. Overview -------- @@ -43,10 +44,12 @@ to render PDFs in the backend outside the request scope Quickstart ---------- -1. Include ``django-easy-pdf``, ``xhtml2pdf`` in your ``requirements.txt`` file. - If you are on Python 3 you need to install the latest version of Reportlab and the beta version of xhtml2pdf:: - $ pip install xhtml2pdf>=0.2b1 +1. Install django-easy-pdf3 package: + + $ pip install django-easy-pdf3 + + or add ``django-easy-pdf3`` to your requirements.txt 2. Add ``easy_pdf`` to ``INSTALLED_APPS``. @@ -90,9 +93,9 @@ script from the cloned repository or through Docker with ``make demo``. Dependencies ------------ -``django-easy-pdf`` depends on: +``django-easy-pdf3`` depends on: - - ``django>=1.10`` + - ``django>=2.0`` - ``xhtml2pdf>=0.2b1`` - ``reportlab`` @@ -100,15 +103,16 @@ Dependencies License ------- -``django-easy-pdf`` is released under the MIT license. +``django-easy-pdf3`` is released under the MIT license. Other Resources --------------- -- GitHub repository - https://github.com/nigma/django-easy-pdf -- PyPi Package site - https://pypi.python.org/pypi/django-easy-pdf +- GitHub repository - https://github.com/olksndrdevhub/django-easy-pdf3 +- PyPi Package site - https://pypi.python.org/pypi/django-easy-pdf3 - Docs - https://django-easy-pdf.readthedocs.io/ +- Bug Tracker - https://github.com/olksndrdevhub/django-easy-pdf3/issues Commercial Support diff --git a/circle.yml b/circle.yml deleted file mode 100644 index d5b0de8..0000000 --- a/circle.yml +++ /dev/null @@ -1,32 +0,0 @@ -machine: - services: - - docker - -general: - artifacts: - - "./dist" - - "./artifacts" - -dependencies: - pre: - - docker --version - override: - - pip install tox tox-pyenv - - pyenv local 2.7.12 3.4.4 3.5.3 3.6.1 - - make docker-build - -test: - override: - - make test-all - - make ci-docker-test - - make ci-docker-docs - -deployment: - master: - branch: master - commands: - - make ci-docker-dist - develop: - branch: develop - commands: - - make ci-docker-dist diff --git a/demo.py b/demo.py index 5ec710f..69f1f5e 100644 --- a/demo.py +++ b/demo.py @@ -1,13 +1,5 @@ #!/bin/env python -# coding=utf-8 - -""" -Demo script. Run: - -python.exe demo.py -""" - -from __future__ import absolute_import, division, print_function, unicode_literals +"""Demo script. Run: python.exe demo.py""" import logging import os @@ -15,7 +7,7 @@ logging.basicConfig(level=logging.DEBUG) from django.conf import settings -from django.conf.urls import url +from django.urls import re_path from django.core.wsgi import get_wsgi_application from django.utils.timezone import now as tznow @@ -49,6 +41,7 @@ def rel(*path): STATIC_ROOT=os.path.abspath(rel('tests', 'static')), STATIC_URL='/static/', ROOT_URLCONF=basename, + SECRET_KEY='foo', WSGI_APPLICATION='{}.application'.format(basename), ALLOWED_HOSTS=[ '127.0.0.1', @@ -73,7 +66,7 @@ def get_context_data(self, **kwargs): urlpatterns = [ - url(r'^$', DemoPDFView.as_view()) + re_path(r'^$', DemoPDFView.as_view()) ] application = get_wsgi_application() diff --git a/docs/conf.py b/docs/conf.py index f512d59..446f409 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # django-easy-pdf documentation build configuration file, created by # sphinx-quickstart on Sun Jan 12 20:56:38 2014. # diff --git a/docs/usage.rst b/docs/usage.rst index 835f336..151252a 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -72,7 +72,7 @@ rendered from the HTML template. .. code-block:: python urlpatterns = [ - url(r'^hello.pdf$', HelloPDFView.as_view()) + re_path(r'^hello.pdf$', HelloPDFView.as_view()) ] You can also use a mixin to output PDF from Django generic views:: diff --git a/easy_pdf/__init__.py b/easy_pdf/__init__.py index 47d5252..7525d19 100644 --- a/easy_pdf/__init__.py +++ b/easy_pdf/__init__.py @@ -1,5 +1 @@ -# coding=utf-8 - -__version__ = '0.1.2.dev1' - -default_app_config = 'easy_pdf.apps.EasyPDFConfig' +__version__ = '0.1.4' diff --git a/easy_pdf/apps.py b/easy_pdf/apps.py index 3178a81..dff60e2 100644 --- a/easy_pdf/apps.py +++ b/easy_pdf/apps.py @@ -1,5 +1,3 @@ -# coding=utf-8 - from django.apps import AppConfig diff --git a/easy_pdf/exceptions.py b/easy_pdf/exceptions.py index 5e5f9ad..8d9f74a 100644 --- a/easy_pdf/exceptions.py +++ b/easy_pdf/exceptions.py @@ -1,26 +1,16 @@ -# coding=utf-8 - -from __future__ import absolute_import, division, print_function, unicode_literals - - -class EasyPDFError(Exception): - """ - Base error class +class EasyPDFError(BaseException): + """Base error class """ class UnsupportedMediaPathException(EasyPDFError): - """ - Resource not found or unavailable - """ + """Resource not found or unavailable""" class PDFRenderingError(EasyPDFError): - """ - PDF Rendering error. Check HTML template for errors. - """ + """PDF Rendering error. Check HTML template for errors""" def __init__(self, message, content, log, *args, **kwargs): - super(PDFRenderingError, self).__init__(message, *args, **kwargs) + super().__init__(message, *args, **kwargs) self.content = content self.log = log diff --git a/easy_pdf/models.py b/easy_pdf/models.py index 9bad579..e69de29 100644 --- a/easy_pdf/models.py +++ b/easy_pdf/models.py @@ -1 +0,0 @@ -# coding=utf-8 diff --git a/easy_pdf/rendering.py b/easy_pdf/rendering.py index 53aa3f0..7e13f78 100644 --- a/easy_pdf/rendering.py +++ b/easy_pdf/rendering.py @@ -1,20 +1,15 @@ -# coding=utf-8 - -from __future__ import absolute_import, division, print_function, unicode_literals - import logging import os +from io import BytesIO +import xhtml2pdf.default from django.conf import settings -from django.template import loader from django.http import HttpResponse -from django.utils.http import urlquote -from django.utils.six import BytesIO - -import xhtml2pdf.default +from django.template import loader +from django.utils.html import smart_urlquote from xhtml2pdf import pisa -from .exceptions import UnsupportedMediaPathException, PDFRenderingError +from .exceptions import PDFRenderingError, UnsupportedMediaPathException logger = logging.getLogger("app.pdf") logger_x2p = logging.getLogger("app.pdf.xhtml2pdf") @@ -92,7 +87,7 @@ def encode_filename(filename): # TODO: http://greenbytes.de/tech/webdav/rfc6266.html # TODO: http://greenbytes.de/tech/tc2231/ - quoted = urlquote(filename) + quoted = smart_urlquote(filename) if quoted == filename: return "filename=%s" % filename else: diff --git a/easy_pdf/tests.py b/easy_pdf/tests.py index a159ad0..d2f2d44 100644 --- a/easy_pdf/tests.py +++ b/easy_pdf/tests.py @@ -1,5 +1,3 @@ -# coding=utf-8 - from django.test import RequestFactory from django.test.testcases import TestCase diff --git a/easy_pdf/views.py b/easy_pdf/views.py index 26daeb0..5cfb020 100644 --- a/easy_pdf/views.py +++ b/easy_pdf/views.py @@ -1,10 +1,6 @@ -# coding=utf-8 - -from __future__ import absolute_import, division, print_function, unicode_literals - import copy -from django.views.generic.base import TemplateResponseMixin, ContextMixin, View +from django.views.generic.base import ContextMixin, TemplateResponseMixin, View from .rendering import render_to_pdf_response diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 45173a8..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,13 +0,0 @@ -pip>=9.0.1 -setuptools>=34.3.3 -wheel>=0.29.0 -django-nose -coverage -gunicorn -flake8>=3.3.0 -mccabe>=0.6.1 -pycodestyle>=2.3.1 -pyflakes>=1.5.0 -mypy>=0.501 -tox -twine>=1.8.1 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index f1f283e..0000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -django>=1.10 -xhtml2pdf>=0.2b1 - -# Dependencies of xhtml2pdf -html5lib>=1.0b10 -httplib2>=0.8 -pyPdf2>=1.26 -Pillow>=2.4.0 -reportlab>=3 diff --git a/runtests.py b/runtests.py index ed27485..5da7bba 100644 --- a/runtests.py +++ b/runtests.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# coding=utf-8 import os import sys diff --git a/setup.py b/setup.py index 48c6c46..2e27856 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import os import sys @@ -9,7 +8,9 @@ except ImportError: from distutils.core import setup -version = "0.1.2.dev1" +import setuptools + +version = "0.1.4" if sys.argv[-1] == "publish": os.system("python setup.py sdist bdist_wheel upload") @@ -21,40 +22,58 @@ readme = open("README.rst").read() history = open("HISTORY.rst").read().replace(".. :changelog:", "") -setup( - name="django-easy-pdf", +setuptools.setup( + name="django-easy-pdf3", version=version, description="""Django PDF views, the easy way""", license="MIT", author="Filip Wasilewski", author_email="en@ig.ma", - url="https://github.com/nigma/django-easy-pdf", + maintainer='Romaniuk Oleksandr', + maintainer_email='oleksandr.romaniuk@protonmail.com', + url="https://github.com/olksndrdevhub/django-easy-pdf3", + project_urls={ + "Bug Tracker": "https://github.com/olksndrdevhub/django-easy-pdf3/issues", + }, long_description=readme + "\n\n" + history, packages=[ "easy_pdf", ], include_package_data=True, install_requires=[ - "django>=1.8", - "xhtml2pdf>=0.2b1", - "reportlab>=3" + "django", + "xhtml2pdf", + "reportlab" ], + extras_require={ + 'test': ( + 'django-nose', + 'coverage', + 'flake8', + 'isort', + 'mccabe', + 'pycodestyle', + 'pyflakes', + 'mypy', + 'tox', + 'twine', + ) + }, zip_safe=False, - keywords="django-easy-pdf", + keywords="django-easy-pdf3", classifiers=[ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Natural Language :: English", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.0", "Topic :: Software Development :: Libraries :: Python Modules" ], ) diff --git a/tests/__init__.py b/tests/__init__.py index 9bad579..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +0,0 @@ -# coding=utf-8 diff --git a/tests/models.py b/tests/models.py index 9bad579..e69de29 100644 --- a/tests/models.py +++ b/tests/models.py @@ -1 +0,0 @@ -# coding=utf-8 diff --git a/tests/test_settings.py b/tests/test_settings.py index 19e8eb0..fa26a37 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,5 +1,3 @@ -# coding=utf-8 - import logging import os import sys diff --git a/tests/tests.py b/tests/tests.py index 1140b2a..8f22811 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,5 +1,3 @@ -# coding=utf-8 - from django.contrib.auth import get_user_model from django.test.testcases import TestCase diff --git a/tests/urls.py b/tests/urls.py index 366854a..8d73a0a 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,12 +1,11 @@ -# coding=utf-8 - -from django.conf.urls import url +from django.urls import re_path from easy_pdf.views import PDFTemplateView + from .views import DemoPDFView, PDFUserDetailView urlpatterns = [ - url(r'^demo/$', DemoPDFView.as_view()), - url(r'^simple/$', PDFTemplateView.as_view(template_name='simple.html')), - url(r'^user/(?P\d+)/$', PDFUserDetailView.as_view()), + re_path(r'^demo/$', DemoPDFView.as_view()), + re_path(r'^simple/$', PDFTemplateView.as_view(template_name='simple.html')), + re_path(r'^user/(?P\d+)/$', PDFUserDetailView.as_view()), ] diff --git a/tests/views.py b/tests/views.py index b2ebe54..79a50ac 100644 --- a/tests/views.py +++ b/tests/views.py @@ -1,5 +1,3 @@ -# coding=utf-8 - from django.contrib.auth import get_user_model from django.utils.timezone import now from django.views.generic import DetailView diff --git a/tox.ini b/tox.ini index 22e88c4..3eba4f2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,29 +1,15 @@ [tox] envlist = - py{2.7,3.4,3.5,3.6}-dj{1.10,1.11} - develop + py{38,39}-d{32,40} [testenv] -basepython = - py2.7: python2.7 - py3.4: python3.4 - py3.5: python3.5 - py3.6: python3.6 commands = {envpython} -c "from django import VERSION; print('%s %s' % ('Django Version', VERSION))" + flake8 easy_pdf + isort -rc easy_pdf {envpython} runtests.py deps = - xhtml2pdf>=0.2b1 - django-nose - coverage - dj1.10: django>=1.10,<1.11 - dj1.11: django>=1.11,<1.12 - -[testenv:develop] -basepython = - python3.6 -deps = - -rrequirements.txt - -rrequirements-dev.txt -commands = - flake8 easy_pdf tests + d32: django==3.2.* + d40: django==4.0.* +extras = + test \ No newline at end of file