Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #82

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

6 changes: 6 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ Contributors
* Jon Bolt (@epicbagel)
* @msaizar
* @SaeX


Maintainer
----------

* olksndrdevhub
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
12 changes: 11 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
++++++++++++++++++

Expand All @@ -11,4 +21,4 @@ History
0.1.0 (2014-01-24)
++++++++++++++++++

* First release
* First release
32 changes: 18 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://en.ig.ma>`_.

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
--------
Expand All @@ -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``.

Expand Down Expand Up @@ -90,25 +93,26 @@ 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``


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
Expand Down
32 changes: 0 additions & 32 deletions circle.yml

This file was deleted.

15 changes: 4 additions & 11 deletions demo.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
#!/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

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

Expand Down Expand Up @@ -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',
Expand All @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
6 changes: 1 addition & 5 deletions easy_pdf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# coding=utf-8

__version__ = '0.1.2.dev1'

default_app_config = 'easy_pdf.apps.EasyPDFConfig'
__version__ = '0.1.4'
2 changes: 0 additions & 2 deletions easy_pdf/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# coding=utf-8

from django.apps import AppConfig


Expand Down
20 changes: 5 additions & 15 deletions easy_pdf/exceptions.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion easy_pdf/models.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# coding=utf-8
17 changes: 6 additions & 11 deletions easy_pdf/rendering.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions easy_pdf/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# coding=utf-8

from django.test import RequestFactory
from django.test.testcases import TestCase

Expand Down
6 changes: 1 addition & 5 deletions easy_pdf/views.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
13 changes: 0 additions & 13 deletions requirements-dev.txt

This file was deleted.

9 changes: 0 additions & 9 deletions requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# coding=utf-8

import os
import sys
Expand Down
Loading