Skip to main content

doc_manager is a django library for publishing documents in pdf and html format like privacy policy or term of use.

Project description

License MIT PyPI - Python Version PyPI - Django Version

doc_manager is a django library for publishing documents in pdf and html format like privacy policy or term of use. It allows you to easily publish new versions of documents while preserving historical documents.

Installation

You can install module from pypi with pip:

pip install doc-manager

or install it directly from the repository with pip:

pip install git+ssh://git@github.com/impicode/doc_manager.git

for a specific branch:

pip install git+ssh://git@github.com/impicode/doc_manager.git@branchname

Requirements

  • django>=3.2.17

Setup

Add doc-manager to INSTALLED_APPS in settings.py file:

INSTALLED_APPS = [
    ...
    'doc_manager',
    ...
]

Define the model in our_app/models.py:

from doc_manager.models import DocumentModel

class OurModel(DocumentModel):
    pass

Register the model in django admin, where the documents are published. our_app/admin.py changes:

from doc_manager.admin import DocumentAdmin
from .models import OurModel

@admin.register(OurModel)
class OurAdmin(DocumentAdmin):
    model = OurModel

Create a view responsible for displaying the pdf or html document and assign a specific url to it.

our_app/views.py changes:

from doc_manager.views import DocumentView
from .models import OurModel


class OurView(DocumentView):
    model = OurModel

Adding path to urls.py:

from our_app.views import OurView

urlpatterns = [
    ...
    path('see_document/', OurView.as_view(), name = 'see_document'),
]

To add a link to the view of a published document, just:

<a  href="{% url 'see_document' %}" target="_blank">See document</a>

Don’t forget to migrate after adding a new model:

python manage.py makemigrations
python manage.py migrate

Usage

  • log in to the admin page

  • head to app_name section

  • add document

  • publish document

Published document is now visible at the URL you previously specified in urls.py

Translations

We provide translations only to Polish. If you need any other language run in doc_manager directory:

django-admin makemessages -l <language code>

then in created file /locale/<language code>/LC_MESSAGES/django.po enter your translations and run:

django-admin compilemessages

Now you have doc-manager app with your custom transltions ready to use in your project.

Example

In main directory run:

python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

Then:

pre-commit Installation

In case of developing doc_manager itself please install pre-commit before your first commit. You can do it with the following commands:

pip install pre-commit

Then in main directory:

pre-commit install

Testing

To run tests in main directory run:

python runtests.py

You can also run tests with tox. In main directory run:

tox

That command will run tests discribed above, pre-commit style checks against all files and build a test package with poetry.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doc_manager-1.0.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

doc_manager-1.0.2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file doc_manager-1.0.2.tar.gz.

File metadata

  • Download URL: doc_manager-1.0.2.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for doc_manager-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c888ac58257456772c893b56eda5b89d6e3bf816d252bf99f5de6f2d171bd81c
MD5 337b90960842d767e1e773cb6707d36f
BLAKE2b-256 a580a2bf31c9f2b18bb3d3fbdd7c0be6787ff31c2627779940afa862f4447903

See more details on using hashes here.

File details

Details for the file doc_manager-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: doc_manager-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for doc_manager-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 69ddaf3e4d3fad369749ae12539ee91d7514838e01d56a76ed057020b2087501
MD5 80556e59e9d2dad0de218f96af9c63a4
BLAKE2b-256 c19971c992bb2fe4b2d53a60c53afc576710e785824de7e5ff802c629aed8b3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page