django-templates-pro 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. django_templates_pro-0.3.0.dist-info/METADATA +184 -0
  2. django_templates_pro-0.3.0.dist-info/RECORD +140 -0
  3. django_templates_pro-0.3.0.dist-info/WHEEL +4 -0
  4. django_templates_pro-0.3.0.dist-info/entry_points.txt +2 -0
  5. django_templates_pro-0.3.0.dist-info/licenses/LICENSE +21 -0
  6. templates_pro/__init__.py +24 -0
  7. templates_pro/admin.py +142 -0
  8. templates_pro/apps.py +19 -0
  9. templates_pro/checks.py +49 -0
  10. templates_pro/conf.py +82 -0
  11. templates_pro/core/__init__.py +0 -0
  12. templates_pro/core/compiler.py +633 -0
  13. templates_pro/core/engine.py +252 -0
  14. templates_pro/core/formatting.py +289 -0
  15. templates_pro/core/renderers/__init__.py +149 -0
  16. templates_pro/core/renderers/docx.py +625 -0
  17. templates_pro/core/renderers/html.py +13 -0
  18. templates_pro/core/renderers/pdf.py +65 -0
  19. templates_pro/core/renderers/txt.py +43 -0
  20. templates_pro/core/renderers/typst_pdf.py +590 -0
  21. templates_pro/core/schema.py +272 -0
  22. templates_pro/demo/__init__.py +69 -0
  23. templates_pro/demo/__main__.py +7 -0
  24. templates_pro/demo/project/README.md +90 -0
  25. templates_pro/demo/project/_docs/CHANGELOG.md +70 -0
  26. templates_pro/demo/project/_docs/README.md +134 -0
  27. templates_pro/demo/project/_docs/SETUP.md +591 -0
  28. templates_pro/demo/project/_docs/docs/admin.md +111 -0
  29. templates_pro/demo/project/_docs/docs/commands.md +96 -0
  30. templates_pro/demo/project/_docs/docs/concepts.md +217 -0
  31. templates_pro/demo/project/_docs/docs/development.md +82 -0
  32. templates_pro/demo/project/_docs/docs/editor.md +140 -0
  33. templates_pro/demo/project/_docs/docs/formatting.md +157 -0
  34. templates_pro/demo/project/_docs/docs/html-contract.md +43 -0
  35. templates_pro/demo/project/_docs/docs/index.md +40 -0
  36. templates_pro/demo/project/_docs/docs/installation.md +109 -0
  37. templates_pro/demo/project/_docs/docs/operations.md +78 -0
  38. templates_pro/demo/project/_docs/docs/quickstart.md +142 -0
  39. templates_pro/demo/project/_docs/docs/rendering.md +247 -0
  40. templates_pro/demo/project/_docs/docs/samples.md +319 -0
  41. templates_pro/demo/project/_docs/docs/security.md +100 -0
  42. templates_pro/demo/project/_docs/docs/settings.md +45 -0
  43. templates_pro/demo/project/_docs/docs/template-types.md +187 -0
  44. templates_pro/demo/project/_docs/docs/troubleshooting.md +92 -0
  45. templates_pro/demo/project/_docs/example/README.md +90 -0
  46. templates_pro/demo/project/_docs/frontend/README.md +16 -0
  47. templates_pro/demo/project/demo/__init__.py +0 -0
  48. templates_pro/demo/project/demo/admin.py +29 -0
  49. templates_pro/demo/project/demo/apps.py +7 -0
  50. templates_pro/demo/project/demo/constants.py +12 -0
  51. templates_pro/demo/project/demo/docs.py +132 -0
  52. templates_pro/demo/project/demo/doctemplate_types.py +211 -0
  53. templates_pro/demo/project/demo/management/__init__.py +0 -0
  54. templates_pro/demo/project/demo/management/commands/__init__.py +0 -0
  55. templates_pro/demo/project/demo/management/commands/seed_demo.py +154 -0
  56. templates_pro/demo/project/demo/markdown.py +265 -0
  57. templates_pro/demo/project/demo/migrations/0001_initial.py +184 -0
  58. templates_pro/demo/project/demo/migrations/__init__.py +0 -0
  59. templates_pro/demo/project/demo/models.py +93 -0
  60. templates_pro/demo/project/demo/samples/blocks/bank-details.html +1 -0
  61. templates_pro/demo/project/demo/samples/blocks/company-letterhead.html +2 -0
  62. templates_pro/demo/project/demo/samples/blocks/customer-details.html +2 -0
  63. templates_pro/demo/project/demo/samples/blocks/page-footer-he.html +1 -0
  64. templates_pro/demo/project/demo/samples/blocks/page-footer.html +1 -0
  65. templates_pro/demo/project/demo/samples/blocks/payment-terms.html +3 -0
  66. templates_pro/demo/project/demo/samples/blocks/signature.html +2 -0
  67. templates_pro/demo/project/demo/samples/manifest.json +197 -0
  68. templates_pro/demo/project/demo/samples/templates/employment-certificate.html +10 -0
  69. templates_pro/demo/project/demo/samples/templates/invoice-hebrew.html +16 -0
  70. templates_pro/demo/project/demo/samples/templates/invoice-modern.html +6 -0
  71. templates_pro/demo/project/demo/samples/templates/invoice-standard.html +13 -0
  72. templates_pro/demo/project/demo/samples/templates/order-confirmation.html +8 -0
  73. templates_pro/demo/project/demo/samples/templates/welcome-letter.html +11 -0
  74. templates_pro/demo/project/demo/static/demo/favicon.png +0 -0
  75. templates_pro/demo/project/demo/static/demo/favicon_OLD.svg +6 -0
  76. templates_pro/demo/project/demo/static/demo/logo.png +0 -0
  77. templates_pro/demo/project/demo/static/demo/logo_OLD.png +0 -0
  78. templates_pro/demo/project/demo/static/demo/northwind-theme.css +11 -0
  79. templates_pro/demo/project/demo/templates/demo/base.html +45 -0
  80. templates_pro/demo/project/demo/templates/demo/docs.html +79 -0
  81. templates_pro/demo/project/demo/templates/demo/gallery.html +12 -0
  82. templates_pro/demo/project/demo/templates/demo/index.html +29 -0
  83. templates_pro/demo/project/demo/templates/demo/user_letter.html +19 -0
  84. templates_pro/demo/project/demo/views.py +136 -0
  85. templates_pro/demo/project/exampleproject/__init__.py +0 -0
  86. templates_pro/demo/project/exampleproject/settings.py +85 -0
  87. templates_pro/demo/project/exampleproject/urls.py +19 -0
  88. templates_pro/demo/project/exampleproject/wsgi.py +6 -0
  89. templates_pro/demo/project/manage.py +14 -0
  90. templates_pro/demo/project/run_demo.py +100 -0
  91. templates_pro/engines.py +40 -0
  92. templates_pro/fetchers.py +124 -0
  93. templates_pro/fonts/NotoSans-Bold.ttf +0 -0
  94. templates_pro/fonts/NotoSans-BoldItalic.ttf +0 -0
  95. templates_pro/fonts/NotoSans-Italic.ttf +0 -0
  96. templates_pro/fonts/NotoSans-Regular.ttf +0 -0
  97. templates_pro/fonts/NotoSansHebrew-Bold.ttf +0 -0
  98. templates_pro/fonts/NotoSansHebrew-Regular.ttf +0 -0
  99. templates_pro/fonts/OFL.txt +93 -0
  100. templates_pro/forms.py +58 -0
  101. templates_pro/management/__init__.py +0 -0
  102. templates_pro/management/commands/__init__.py +0 -0
  103. templates_pro/management/commands/templates_pro_samples.py +49 -0
  104. templates_pro/management/commands/templates_pro_validate.py +40 -0
  105. templates_pro/migrations/0001_initial.py +406 -0
  106. templates_pro/migrations/0002_document_direction.py +28 -0
  107. templates_pro/migrations/__init__.py +0 -0
  108. templates_pro/models.py +399 -0
  109. templates_pro/registry.py +124 -0
  110. templates_pro/samples/__init__.py +13 -0
  111. templates_pro/samples/apps.py +16 -0
  112. templates_pro/samples/content/blocks/sample-bank-details.html +1 -0
  113. templates_pro/samples/content/blocks/sample-company-letterhead.html +2 -0
  114. templates_pro/samples/content/blocks/sample-customer-details.html +2 -0
  115. templates_pro/samples/content/blocks/sample-page-footer-he.html +1 -0
  116. templates_pro/samples/content/blocks/sample-page-footer.html +1 -0
  117. templates_pro/samples/content/blocks/sample-payment-terms.html +3 -0
  118. templates_pro/samples/content/blocks/sample-signature.html +2 -0
  119. templates_pro/samples/content/manifest.json +126 -0
  120. templates_pro/samples/content/templates/sample-employment-certificate.html +10 -0
  121. templates_pro/samples/content/templates/sample-invoice-hebrew.html +16 -0
  122. templates_pro/samples/content/templates/sample-invoice-modern.html +6 -0
  123. templates_pro/samples/content/templates/sample-invoice-standard.html +13 -0
  124. templates_pro/samples/content/templates/sample-order-confirmation.html +8 -0
  125. templates_pro/samples/content/templates/sample-welcome-letter.html +11 -0
  126. templates_pro/samples/doctemplate_types.py +140 -0
  127. templates_pro/samples/loader.py +134 -0
  128. templates_pro/services.py +350 -0
  129. templates_pro/signals.py +17 -0
  130. templates_pro/static/templates_pro/editor/templates-pro-editor.css +1 -0
  131. templates_pro/static/templates_pro/editor/templates-pro-editor.js +163 -0
  132. templates_pro/static/templates_pro/themes/classic.css +20 -0
  133. templates_pro/static/templates_pro/themes/corporate.css +20 -0
  134. templates_pro/static/templates_pro/themes/minimal.css +11 -0
  135. templates_pro/static/templates_pro/themes/modern.css +21 -0
  136. templates_pro/templates/templates_pro/widgets/editor.html +6 -0
  137. templates_pro/themes.py +73 -0
  138. templates_pro/urls.py +10 -0
  139. templates_pro/views.py +93 -0
  140. templates_pro/widgets.py +126 -0
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.5
2
+ Name: django-templates-pro
3
+ Version: 0.3.0
4
+ Summary: WYSIWYG document templates for Django: variables, constants, dynamic values, formatting and shared blocks, rendered to HTML, PDF, DOCX and TXT, with right-to-left (Hebrew, Arabic) support. Pure pip: no system libraries.
5
+ Project-URL: Documentation, https://github.com/latingate/django-templates-pro/tree/master/docs
6
+ Project-URL: Source, https://github.com/latingate/django-templates-pro
7
+ Project-URL: Changelog, https://github.com/latingate/django-templates-pro/blob/master/CHANGELOG.md
8
+ Author: Peltransport
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: django,docx,hebrew,jinja2,mail-merge,pdf,rtl,templates,tiptap,typst,wysiwyg
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Web Environment
14
+ Classifier: Framework :: Django
15
+ Classifier: Framework :: Django :: 4.2
16
+ Classifier: Framework :: Django :: 5.0
17
+ Classifier: Framework :: Django :: 5.1
18
+ Classifier: Framework :: Django :: 5.2
19
+ Classifier: Framework :: Django :: 6.0
20
+ Classifier: Framework :: Django :: 6.1
21
+ Classifier: Intended Audience :: Developers
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Programming Language :: Python :: 3.10
25
+ Classifier: Programming Language :: Python :: 3.11
26
+ Classifier: Programming Language :: Python :: 3.12
27
+ Classifier: Programming Language :: Python :: 3.13
28
+ Classifier: Programming Language :: Python :: 3.14
29
+ Classifier: Topic :: Office/Business
30
+ Classifier: Topic :: Text Processing :: Markup :: HTML
31
+ Requires-Python: >=3.10
32
+ Requires-Dist: babel>=2.12
33
+ Requires-Dist: django>=4.2
34
+ Requires-Dist: html2text>=2024.2.26
35
+ Requires-Dist: jinja2>=3.1
36
+ Requires-Dist: python-docx>=1.1
37
+ Requires-Dist: typst>=0.13
38
+ Provides-Extra: all
39
+ Provides-Extra: dev
40
+ Requires-Dist: nox>=2024.3; extra == 'dev'
41
+ Requires-Dist: pypdf>=4; extra == 'dev'
42
+ Requires-Dist: pytest-django>=4.8; extra == 'dev'
43
+ Requires-Dist: pytest>=8; extra == 'dev'
44
+ Requires-Dist: ruff>=0.5; extra == 'dev'
45
+ Provides-Extra: docx
46
+ Provides-Extra: pdf
47
+ Provides-Extra: weasyprint
48
+ Requires-Dist: weasyprint>=60; extra == 'weasyprint'
49
+ Description-Content-Type: text/markdown
50
+
51
+ # django-templates-pro
52
+
53
+ WYSIWYG document templates for Django. Admins and users write templates in a
54
+ rich-text editor (TipTap). The templates can contain:
55
+
56
+ - **variables** (invoice number, customer name…), declared per *template type* in code
57
+ - **constants** (website name, company address…), edited in the admin
58
+ - **dynamic values** (today, current time, year, row number, page X of Y)
59
+ - **formatting** for dates, times, numbers, money, percentages and text, chosen per chip
60
+ - **shared blocks** (header, footer, customer details…), edited once and used everywhere
61
+ - **repeat sections / repeated table rows** (invoice lines) and **conditions**
62
+ - **text direction** per template (auto from the locale, LTR or RTL), in the editor and every output
63
+
64
+ Templates render to **HTML, PDF (Typst), DOCX (python-docx) and TXT**, with
65
+ full **right-to-left** support (Hebrew, Arabic…). Everything installs with
66
+ pip alone: no system libraries, on Windows, macOS and Linux.
67
+
68
+ Users never write template syntax. The editor stores HTML with chips, and the
69
+ package compiles it to **sandboxed Jinja2**. Contexts must be plain data, so
70
+ templates can't reach your models, the ORM or Python internals.
71
+
72
+ ```python
73
+ from templates_pro.services import render_to_response
74
+
75
+ def invoice_pdf(request, pk):
76
+ invoice = get_object_or_404(Invoice, pk=pk)
77
+ return render_to_response("invoice", invoice, fmt="pdf") # the type's default template
78
+ ```
79
+
80
+ ## Install
81
+
82
+ ```bash
83
+ pip install django-templates-pro # HTML, PDF, DOCX and TXT; nothing else to install
84
+ ```
85
+
86
+ ```python
87
+ INSTALLED_APPS = [..., "django.contrib.contenttypes", "django.contrib.staticfiles", "templates_pro"]
88
+ # urls.py — preview endpoints used by the editor
89
+ path("templates-pro/", include("templates_pro.urls")),
90
+ ```
91
+
92
+ ```bash
93
+ python manage.py migrate
94
+ ```
95
+
96
+ Want something to look at first? Add `"templates_pro.samples"` to `INSTALLED_APPS` and run
97
+ `python manage.py templates_pro_samples`: six ready-made templates (one Hebrew, right-to-left),
98
+ seven shared blocks and constants appear in the admin, with working previews
99
+ ([sample content](https://github.com/latingate/django-templates-pro/blob/master/docs/quickstart.md#start-from-the-samples-optional)).
100
+
101
+ Then declare what can be templated, in any app's `doctemplate_types.py`:
102
+
103
+ ```python
104
+ from templates_pro import register, TemplateType, Var, Group, ListOf
105
+
106
+ @register
107
+ class InvoiceTemplate(TemplateType):
108
+ key = "invoice"
109
+ label = "Invoice"
110
+ filename = "invoice-{invoice.number}"
111
+ schema = {
112
+ "invoice": Group("Invoice", {
113
+ "number": Var("string", "Invoice number", sample="INV-0042"),
114
+ "date": Var("date", "Date"),
115
+ "total": Var("money", "Total"),
116
+ "lines": ListOf("Line items", {
117
+ "description": Var("string", "Description"),
118
+ "amount": Var("money", "Amount"),
119
+ }),
120
+ }),
121
+ }
122
+
123
+ def build_context(self, invoice, **kwargs):
124
+ return {"invoice": {
125
+ "number": invoice.number, "date": invoice.date, "total": invoice.total,
126
+ "lines": [{"description": l.description, "amount": l.amount} for l in invoice.lines.all()],
127
+ }}
128
+ ```
129
+
130
+ Open **Admin → Document templates**, pick the type, and write.
131
+
132
+ Requirements: Python 3.10+ and Django 4.2+ (on Python 3.14: Django 5.2.8+). That's all: PDF output uses the
133
+ `typst` wheel and bundled fonts (Latin + Hebrew). WeasyPrint is available as an
134
+ optional PDF engine ([rendering.md](https://github.com/latingate/django-templates-pro/blob/master/docs/rendering.md#pdf-engines)).
135
+
136
+ ## Try the demo
137
+
138
+ After `pip install django-templates-pro`:
139
+
140
+ ```bash
141
+ python -m templates_pro.demo # http://127.0.0.1:8000 (admin / admin)
142
+ ```
143
+
144
+ It copies the demo project into `./templates-pro-demo` (another folder: `--dir`),
145
+ migrates its own SQLite database, loads the demo content and starts the server. It
146
+ never touches your own project. Run the same command again to restart it.
147
+
148
+ From a clone of the repository, `python example/run_demo.py` does the same in place,
149
+ and also creates `.venv` and installs the package when needed. Details are in
150
+ [docs/samples.md](https://github.com/latingate/django-templates-pro/blob/master/docs/samples.md#run-it).
151
+
152
+ The demo has six templates (an English and a Hebrew right-to-left invoice, a
153
+ modern invoice, a letter, an order email and an HR certificate), seven shared
154
+ blocks (one of them nested), constants, document themes (one of them a
155
+ project theme), every editor preset and skin, and a user-facing editor page.
156
+ It also serves this documentation at <http://127.0.0.1:8000/docs/>.
157
+
158
+ ## Documentation
159
+
160
+ The full list, in reading order, is in [docs/index.md](https://github.com/latingate/django-templates-pro/blob/master/docs/index.md).
161
+
162
+ | | |
163
+ |---|---|
164
+ | [**Setup guide**](https://github.com/latingate/django-templates-pro/blob/master/SETUP.md) | step-by-step local setup, demo, PyCharm, Windows PDF, troubleshooting |
165
+ | [Installation](https://github.com/latingate/django-templates-pro/blob/master/docs/installation.md) | requirements, settings, URLs, system libraries |
166
+ | [Quickstart](https://github.com/latingate/django-templates-pro/blob/master/docs/quickstart.md) | first template type, first template, first PDF |
167
+ | [Samples, demo and examples](https://github.com/latingate/django-templates-pro/blob/master/docs/samples.md) | the packaged samples, the demo project and the sample HTML files, and how to use them |
168
+ | [Concepts](https://github.com/latingate/django-templates-pro/blob/master/docs/concepts.md) | variables, constants, dynamic values, blocks, repeats, conditions |
169
+ | [Template types](https://github.com/latingate/django-templates-pro/blob/master/docs/template-types.md) | schemas, `build_context`, samples, locale & currency hooks |
170
+ | [Formatting](https://github.com/latingate/django-templates-pro/blob/master/docs/formatting.md) | how formatting works; date/number/money/text format reference |
171
+ | [The editor](https://github.com/latingate/django-templates-pro/blob/master/docs/editor.md) | widget options, presets, skins, toolbar, JS API, styling |
172
+ | [The admin](https://github.com/latingate/django-templates-pro/blob/master/docs/admin.md) | templates, blocks, constants, generated documents, previews, permissions |
173
+ | [Rendering](https://github.com/latingate/django-templates-pro/blob/master/docs/rendering.md) | services API, formats, themes, page setup, stored documents, custom renderers |
174
+ | [Security](https://github.com/latingate/django-templates-pro/blob/master/docs/security.md) | the sandbox, sanitising, URL fetching, permissions |
175
+ | [Settings](https://github.com/latingate/django-templates-pro/blob/master/docs/settings.md) | `TEMPLATES_PRO` reference |
176
+ | [Management commands](https://github.com/latingate/django-templates-pro/blob/master/docs/commands.md) | `templates_pro_validate`, `templates_pro_samples`, `seed_demo` |
177
+ | [Operations](https://github.com/latingate/django-templates-pro/blob/master/docs/operations.md) | schema changes, caching, migrations, upgrades |
178
+ | [Troubleshooting](https://github.com/latingate/django-templates-pro/blob/master/docs/troubleshooting.md) | symptoms, causes and fixes |
179
+ | [HTML contract](https://github.com/latingate/django-templates-pro/blob/master/docs/html-contract.md) | the chip markup shared by editor and compiler |
180
+ | [Development](https://github.com/latingate/django-templates-pro/blob/master/docs/development.md) | repo layout, tests, building the editor bundle |
181
+
182
+ ## License
183
+
184
+ MIT
@@ -0,0 +1,140 @@
1
+ templates_pro/__init__.py,sha256=bYkONFNkgscdFUGF-42eQdA-7MeAQPLIrEfpv4uRJW0,760
2
+ templates_pro/admin.py,sha256=-3M66ZcRcf0jxvNBWED7gexLYhdiM2Rj6Zr8o4Cki7g,5922
3
+ templates_pro/apps.py,sha256=Hhso-7V805VndpYZGo15_77Sb4pLXKWEPsvjhrbJyJg,599
4
+ templates_pro/checks.py,sha256=NrpE7cTCdYHUEaXrIAbmfyNoiXAkT1MmcBe8WxduGFM,2316
5
+ templates_pro/conf.py,sha256=GI9706kwZgZKkSfVylWq7ZS7YOJfHLH4AhNW-Szmb7Q,2998
6
+ templates_pro/engines.py,sha256=EYWh5Zbmq-c1bHZVRLM8_vdLrGmNevBITrSD_cTBqEU,1424
7
+ templates_pro/fetchers.py,sha256=UDe8xy9eppTzrTAwDmlyPNVNhlhrgMQAi2LpYSXRk0w,4524
8
+ templates_pro/forms.py,sha256=P5-oPpT5E8S2Py_ajtkbXqK6RJyCncC3CZqte1_91tY,2414
9
+ templates_pro/models.py,sha256=j_k7LhhSN15QwWaS4Nzeci7OMaad4VRBTK79nY3mnuc,16622
10
+ templates_pro/registry.py,sha256=rp8bL8gWiZtc81Xo8kYMvYhYiHnZ9XZwTTD7iXQpl0M,4217
11
+ templates_pro/services.py,sha256=xwpRhxGyS89y60N3g2PDcrd3jk0tSuZv6w9lD-rbr0s,13479
12
+ templates_pro/signals.py,sha256=uQ0rf6VukKlWYaeA1X9fqjn0w7w-pb6KpncbYxe7On0,486
13
+ templates_pro/themes.py,sha256=_kp7qXS_OsvdcPPGpnOfIEqHURSxAdZHFjosiyUsCW0,2286
14
+ templates_pro/urls.py,sha256=B5IxNqiZC5yq-O4noKutB84-z5U1YR8UBf94IrbAnco,239
15
+ templates_pro/views.py,sha256=uahaSkvgEMwmqNS8JVM_aI1AJltZ4voHE2Gcb_diU3c,3523
16
+ templates_pro/widgets.py,sha256=jeODnK3GV9hLUpkgyKJqhmnfKew6necL_PLhXK0al4g,5562
17
+ templates_pro/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ templates_pro/core/compiler.py,sha256=wI34qX5zl6WYZBn2bnp2MbGkc-zSz74CXttFBITGOIk,25582
19
+ templates_pro/core/engine.py,sha256=QdI2AsFuJRwOdDaQPV4zc3bsE5-fr7PF7_jivoKC-jc,8366
20
+ templates_pro/core/formatting.py,sha256=zh6kaPyOx86tQkkyHW7z1l6EymUA9uxlHa9H2kP3QGw,9814
21
+ templates_pro/core/schema.py,sha256=hdLG7BWnu-0tdrF9FcqnTYDpGUEGUv6NVUFjjCivIBY,8859
22
+ templates_pro/core/renderers/__init__.py,sha256=Xq8-EPDJUIKX_Ts6fCgsRsIOFUn1uia3bNLkv61DRgw,5140
23
+ templates_pro/core/renderers/docx.py,sha256=t6XsmOwr_EH7VnwWJozQciE4-E9AdWKD3M6nPdwJxcM,22879
24
+ templates_pro/core/renderers/html.py,sha256=DpSC4AfdUHIhpg7rCUzarMGPs_-GcPqP7Ba47roLK6Y,333
25
+ templates_pro/core/renderers/pdf.py,sha256=Jp6pCS-BfzM7xV7eJwP1JszV4omxl7jaObB8lqtBewU,2352
26
+ templates_pro/core/renderers/txt.py,sha256=3l9DfCCN2dbxn48sHJ0pex4-2nYRg2OvEQf6S0qPL0E,1240
27
+ templates_pro/core/renderers/typst_pdf.py,sha256=WtNrY4P9sRlLBfwq7pD016TfFOseZ5_DxzADZ-3w_Ng,23267
28
+ templates_pro/demo/__init__.py,sha256=WHe7VYy1w-flZvDHWnUU__jdShFhiWmsD-EZi16TnWc,3134
29
+ templates_pro/demo/__main__.py,sha256=Rw7q54eI3X0S66ZrYzwdKbCMjaVk0ay7buTnu8_Hmis,85
30
+ templates_pro/fonts/NotoSans-Bold.ttf,sha256=HfB1o4D8fLiYrPZMH3s7TdeA3jyqhgF4v5Kd41gXqRM,631484
31
+ templates_pro/fonts/NotoSans-BoldItalic.ttf,sha256=G2AqnWNTvkLJHfCXpIV7afomlvJnA9ejO1ShXYfCYiw,646092
32
+ templates_pro/fonts/NotoSans-Italic.ttf,sha256=Rn4_ie7KQQi7hxCiueDPIoGsVtWwYJIRqDd20FBe7LU,639124
33
+ templates_pro/fonts/NotoSans-Regular.ttf,sha256=R4xVjqcWAzzWDANDj2KN-nVpTc9rX21QWi8F_StPOCM,621572
34
+ templates_pro/fonts/NotoSansHebrew-Bold.ttf,sha256=2pIm6IbCRafhFnPCTeyCve1k2FdMHh8DmDv4kpfSqqg,26860
35
+ templates_pro/fonts/NotoSansHebrew-Regular.ttf,sha256=ze-vjv1HBF9oIJKOuoTbW-11V1OTKJUrX4KDFUheAu4,26860
36
+ templates_pro/fonts/OFL.txt,sha256=zumJL58MyP6ILJ6VN-5qiWIdhu586vcLAuKyscJcBho,4396
37
+ templates_pro/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ templates_pro/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
+ templates_pro/management/commands/templates_pro_samples.py,sha256=ft6_THtNyE0LDu0T-IdZzMDvI-kdeiXY16ONTZ7_b20,2421
40
+ templates_pro/management/commands/templates_pro_validate.py,sha256=ga0cYFjgk-SUT0zuMhHnVcgPYTM3y-MBd3VZB2YxJxw,1656
41
+ templates_pro/migrations/0001_initial.py,sha256=cvf0ml0qmLfumOrELoFikOfUdhttVt3KP95GfIzNFS8,15604
42
+ templates_pro/migrations/0002_document_direction.py,sha256=hwZuqyTrx9V9E5BNsbioMTW1AuyYjFcD0Z-r2sTvzOI,790
43
+ templates_pro/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
+ templates_pro/samples/__init__.py,sha256=cHPXBpieLFdJ2rTlEO2WWCigQZpxJuddjyZUwDkEOnQ,533
45
+ templates_pro/samples/apps.py,sha256=0CurHJHHLDO1jeVqTdZlwkSdl7bLjV7eRJtLHwgWzNQ,482
46
+ templates_pro/samples/doctemplate_types.py,sha256=Gs2CuN838HXOX1JF1xclzlIYKHY5_ZnKTNrkjupWqsc,6574
47
+ templates_pro/samples/loader.py,sha256=kpgWeTh7VY8gNlJjfSw9T_R8qA1r0aWQWXr6LiafxkQ,5221
48
+ templates_pro/samples/content/manifest.json,sha256=25JNdEgz62mTUlpnIsAFOWOgr074QYB936M1uCQsOVU,4288
49
+ templates_pro/samples/content/blocks/sample-bank-details.html,sha256=EORsCFceHmZk7i7f7TScmj5Yx2kULYCWMdLmld1H9RI,232
50
+ templates_pro/samples/content/blocks/sample-company-letterhead.html,sha256=3hr0KBcB2VWCaMNd1rV4J9X6MzBWBX-3vh_dQr08l08,115746
51
+ templates_pro/samples/content/blocks/sample-customer-details.html,sha256=4_h-2ZyE-P4kOBjjC9Ppa44_R-IuOCM8AESUcr_9hqY,595
52
+ templates_pro/samples/content/blocks/sample-page-footer-he.html,sha256=8c4NlmA0DPd6OpVPdA0DejhcOM3BnlWScRCC_ZE-tCk,372
53
+ templates_pro/samples/content/blocks/sample-page-footer.html,sha256=9g81PJBKd8bHie8F12i3YkOWi-fDEoBpYYSUxBhQJVs,346
54
+ templates_pro/samples/content/blocks/sample-payment-terms.html,sha256=5-YBM0nfUqBwU3qlT_w2iZKTC6ogvcFZAnJSXD9qEcY,656
55
+ templates_pro/samples/content/blocks/sample-signature.html,sha256=40RcOqNLWy4aY405HgsPF5PCkalufJSpiRJ20sKkq8A,186
56
+ templates_pro/samples/content/templates/sample-employment-certificate.html,sha256=kJmW9LFmQ4VYFv9zMCl3Y0bee9T-9thK4Yemk29h878,2533
57
+ templates_pro/samples/content/templates/sample-invoice-hebrew.html,sha256=_gvt3Lh5w1vTQ0BX8rIsv2h724gmi5MwBcna7XPEFBo,3764
58
+ templates_pro/samples/content/templates/sample-invoice-modern.html,sha256=GVIDgjzDkhD3wTv5SzcXn3KnjqhoGj6EJu0yLaBVJRY,1815
59
+ templates_pro/samples/content/templates/sample-invoice-standard.html,sha256=aMcGorGfT9y7SiRygYkJq1vBMm_6aL1UGv9zvob66AY,2300
60
+ templates_pro/samples/content/templates/sample-order-confirmation.html,sha256=hqk-BsIhw0n62HQGkAJmrrZ5Mn77UmFYsxZQqALzQcA,1406
61
+ templates_pro/samples/content/templates/sample-welcome-letter.html,sha256=vv3TIHezaMltv6pWSTc3RynEDbqMZLDjSe61Nh0NRv8,1808
62
+ templates_pro/static/templates_pro/editor/templates-pro-editor.css,sha256=oTOtzEJv7MIzhDcCERxO8ezf7237_grwN96rPC_NMMw,12335
63
+ templates_pro/static/templates_pro/editor/templates-pro-editor.js,sha256=sTtcvy4LSFazdxQZZXlA-S8ug6yPQbpCeyzkuCqsRP0,530671
64
+ templates_pro/static/templates_pro/themes/classic.css,sha256=W3lEs6yFZ4cMGDgiTRIubWMYflInTxtkG4TeVV3bK58,1316
65
+ templates_pro/static/templates_pro/themes/corporate.css,sha256=rsMWUlA5kc8bWRQ0T39o1U66LMFspKvXQ7qk_3zs16Q,1425
66
+ templates_pro/static/templates_pro/themes/minimal.css,sha256=pTMEiz9fRnHsHNkwL4O1_upNC8q13YVBMbcJE91KVPY,778
67
+ templates_pro/static/templates_pro/themes/modern.css,sha256=4v-H2G1IezQ309icTo47VgFTC6kEGkUtd4nGPkmLLe0,1438
68
+ templates_pro/templates/templates_pro/widgets/editor.html,sha256=_VOxLJEisRqZcMHycOHypr655C1-p0Jxk8TB9Yke0B0,367
69
+ templates_pro/demo/project/README.md,sha256=W_KeyiKEdyER4RpQfGsX469E9A4olpGITtpQbczRE-0,4415
70
+ templates_pro/demo/project/manage.py,sha256=hHF4BPYgXwGeOEk2vwMA5H87j_XkLfevHYZKQElh6tg,490
71
+ templates_pro/demo/project/run_demo.py,sha256=DmYBxFrHwOs1IP4UKx-OMYQoKk6O08ziREiCrsOrzjQ,3494
72
+ templates_pro/demo/project/demo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
+ templates_pro/demo/project/demo/admin.py,sha256=DCZrHULWoUyfTKkmxUXq6YUfhGHB6eDswUOb-Ppi2pQ,648
74
+ templates_pro/demo/project/demo/apps.py,sha256=VkT86abJohALRnLnAfuQZweqa3Q0Tol3ZY6fF_0ttKY,171
75
+ templates_pro/demo/project/demo/constants.py,sha256=dfLH7HDiyhRE6fL3mvp-P-FHFbBWucQd_ozJ81bfEHA,377
76
+ templates_pro/demo/project/demo/docs.py,sha256=X9-3FoOuNEL3WWxT97Qc5F_BW63MaPp7I9uASDHZn60,4205
77
+ templates_pro/demo/project/demo/doctemplate_types.py,sha256=gi3xmV4U7vOJTnQTCm9Qr6KFOgM2nVr0OHI7x_GBU5M,9660
78
+ templates_pro/demo/project/demo/markdown.py,sha256=myGe8an21Ty8ookJqa6jjCEfjiHgAbndVQVcBiFAQ1k,11032
79
+ templates_pro/demo/project/demo/models.py,sha256=zke2_QZu0wdSOPOdSKqXpGNplRlSsU-xZe9dQFP03mE,3358
80
+ templates_pro/demo/project/demo/views.py,sha256=ffdzkl1JlPZeCgEAduSjLbtAkf_KQibHsmju1YXGsHw,6180
81
+ templates_pro/demo/project/demo/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
+ templates_pro/demo/project/demo/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
+ templates_pro/demo/project/demo/management/commands/seed_demo.py,sha256=xWWM5cEbesru190brWa8iP-RYyGsAIISVtcIHo1yxRM,8455
84
+ templates_pro/demo/project/demo/migrations/0001_initial.py,sha256=GdNIJZwk871bic0hkHkBbFGLsx9XHewgDXTvsitta_A,6548
85
+ templates_pro/demo/project/demo/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
+ templates_pro/demo/project/demo/samples/manifest.json,sha256=1ZboY9b3QvT8DwzDxMxmxE5xvICmqw7v0favUcIs_Zw,4533
87
+ templates_pro/demo/project/demo/samples/blocks/bank-details.html,sha256=EORsCFceHmZk7i7f7TScmj5Yx2kULYCWMdLmld1H9RI,232
88
+ templates_pro/demo/project/demo/samples/blocks/company-letterhead.html,sha256=xxO03fy1adBKUh6dkAfafu8RJ0m0g8rgfq8ty0_LKBA,393
89
+ templates_pro/demo/project/demo/samples/blocks/customer-details.html,sha256=4_h-2ZyE-P4kOBjjC9Ppa44_R-IuOCM8AESUcr_9hqY,595
90
+ templates_pro/demo/project/demo/samples/blocks/page-footer-he.html,sha256=8c4NlmA0DPd6OpVPdA0DejhcOM3BnlWScRCC_ZE-tCk,372
91
+ templates_pro/demo/project/demo/samples/blocks/page-footer.html,sha256=9g81PJBKd8bHie8F12i3YkOWi-fDEoBpYYSUxBhQJVs,346
92
+ templates_pro/demo/project/demo/samples/blocks/payment-terms.html,sha256=Ekxn0V46LLatZnl0MxHEwlfVBPutCG2SqfY0K5VpXrI,649
93
+ templates_pro/demo/project/demo/samples/blocks/signature.html,sha256=40RcOqNLWy4aY405HgsPF5PCkalufJSpiRJ20sKkq8A,186
94
+ templates_pro/demo/project/demo/samples/templates/employment-certificate.html,sha256=ejg6-uaOVPmwZygDV_qhFbAwTutlhiu4uxA_4KWo7sw,2526
95
+ templates_pro/demo/project/demo/samples/templates/invoice-hebrew.html,sha256=HHAgvBFSVLLb6f079IZdzDv9Hfbywg8ufWd0TN003A0,3757
96
+ templates_pro/demo/project/demo/samples/templates/invoice-modern.html,sha256=JE1vinNzpIiyKrnYha5lL7md7VR_X6QGrZCuYia_9lY,1808
97
+ templates_pro/demo/project/demo/samples/templates/invoice-standard.html,sha256=WM_fXCgf1aD3vLh5zwjTgMzFRf_DcO0NURhJC06P1is,2272
98
+ templates_pro/demo/project/demo/samples/templates/order-confirmation.html,sha256=hqk-BsIhw0n62HQGkAJmrrZ5Mn77UmFYsxZQqALzQcA,1406
99
+ templates_pro/demo/project/demo/samples/templates/welcome-letter.html,sha256=-ChDkIRkSViB8SCE3TCNpy5-tB5eujikQQAV7JvZal0,1787
100
+ templates_pro/demo/project/demo/static/demo/favicon.png,sha256=9NqMPqChL0dSETLTBtiF81N76lgqWegnAbGek4VXefU,2212
101
+ templates_pro/demo/project/demo/static/demo/favicon_OLD.svg,sha256=ge-ZUMTIyPAYHDrnloLZn5LIiF5ncgeNxEoZUolMGrM,278
102
+ templates_pro/demo/project/demo/static/demo/logo.png,sha256=sFjm4rdBxA-ivofDDVb6iBNeEZLRCl7YBURgbXyDZ4E,86513
103
+ templates_pro/demo/project/demo/static/demo/logo_OLD.png,sha256=uV0n4iWK1ttyhbYYkmgIypBLvcD34RGUQuZa22rdZQY,7805
104
+ templates_pro/demo/project/demo/static/demo/northwind-theme.css,sha256=Je1MePS2aOFa1xH2hFZ2QZvVdrUpJvUa0jxcaiLuwk4,938
105
+ templates_pro/demo/project/demo/templates/demo/base.html,sha256=FPnEsDVX5sE0m-Z9W2Ve07yt8JKKNllpIah3PUs0RqU,2859
106
+ templates_pro/demo/project/demo/templates/demo/docs.html,sha256=bSV8EJUaqnr90B2vntU50MJ-kgEfciHlYj3Kc8J12S8,4487
107
+ templates_pro/demo/project/demo/templates/demo/gallery.html,sha256=bcbpVj3qthQreONoM2_ETo3TOX98eWs0e3eC4wPxoLI,516
108
+ templates_pro/demo/project/demo/templates/demo/index.html,sha256=VH_FEpMu5DXGAOTW_IUDn8_O2-u9FLd6a36GjAmGAMc,1223
109
+ templates_pro/demo/project/demo/templates/demo/user_letter.html,sha256=6PM-b8L9A7FCyPnwYjt5U_ChlDIKlihvUJ7V9MEhxDc,873
110
+ templates_pro/demo/project/exampleproject/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
111
+ templates_pro/demo/project/exampleproject/settings.py,sha256=W8ORIOxMAp_EeZI5pv563qmZLKeaYGOcRjo-K8vNa3I,2898
112
+ templates_pro/demo/project/exampleproject/urls.py,sha256=aLA74FyWUeL7NyChfxazb5WXuso46j9TjGVlVxyUuxs,917
113
+ templates_pro/demo/project/exampleproject/wsgi.py,sha256=xNWzGIqy7d-UUi8JgcyqFXpKCZ0QtsFkGvnR9R2HBk0,174
114
+ templates_pro/demo/project/_docs/CHANGELOG.md,sha256=pKOh0GmYPdN74zMdEjmGxOqTM3SbtCR5oO40KeNCd04,4407
115
+ templates_pro/demo/project/_docs/README.md,sha256=zaCza9O9FzW2ez4lFVKORB1iOKlN_WMJLVVy9tJP8FQ,7458
116
+ templates_pro/demo/project/_docs/SETUP.md,sha256=AC9HX4qw64ExeolNIoH90Xx1gHgnKjqrgMHNiDCGE9g,22268
117
+ templates_pro/demo/project/_docs/docs/admin.md,sha256=M_7O13DwLSmQjjRptLzap9qhpZcjv5FnUiJGbp5XlS0,5534
118
+ templates_pro/demo/project/_docs/docs/commands.md,sha256=hQkGdoXT1B4ASUVdshXRqdu-YcUYRIvfKYy79f7T20Q,3753
119
+ templates_pro/demo/project/_docs/docs/concepts.md,sha256=AuCzTY5KCL_b0K_tw0d0tQ-M59JXfG2i-h0DMGp2jZY,10022
120
+ templates_pro/demo/project/_docs/docs/development.md,sha256=L_efSF2hW2zJwYD0zszo7CZfJRdYcOIHsZUW2OTOpJM,3307
121
+ templates_pro/demo/project/_docs/docs/editor.md,sha256=gv1sg0JW1TbXA2do-9eWhfPbja2PmyHog42D6vuMPuI,5522
122
+ templates_pro/demo/project/_docs/docs/formatting.md,sha256=QiZhdrIzKwlItNnzGHNfoZgEyluNzdDGw0T60kRdyrM,6970
123
+ templates_pro/demo/project/_docs/docs/html-contract.md,sha256=aBerZU_HjeDmpWfD1QWZv97wcxjL1nPgFHYK3NWck3s,2529
124
+ templates_pro/demo/project/_docs/docs/index.md,sha256=_Z4t2UZMH5CHkYPrXcplLXEn7KdahXUB05sqd-IQcPw,1979
125
+ templates_pro/demo/project/_docs/docs/installation.md,sha256=dSJJlMpYqL48DV3cVcFBNYPgr2NrqOukQi63Ikpj00E,3097
126
+ templates_pro/demo/project/_docs/docs/operations.md,sha256=b3QZKQgwuIIGDsK2y4bPIfwYlxfyBE0ofvis-knBdCY,3386
127
+ templates_pro/demo/project/_docs/docs/quickstart.md,sha256=9DkESMp9rD2-LL_FhdZOZgVDBOacUa0bvTsCb0UOYxQ,5427
128
+ templates_pro/demo/project/_docs/docs/rendering.md,sha256=-V_Mim4Fb-TGXXMUojMCEp4XVZz0WKs9yTz1OMnwBw8,10478
129
+ templates_pro/demo/project/_docs/docs/samples.md,sha256=yfLEd0ginDvkjc4YrDYF7YHpv3I4WGUcZw8I_Xou5no,13878
130
+ templates_pro/demo/project/_docs/docs/security.md,sha256=GJWWBKETAZ_ODJj2pJusZQ4_7iaHYuD0H_TpxUNB7Mw,4411
131
+ templates_pro/demo/project/_docs/docs/settings.md,sha256=5L20JQ4WnHGoIGXsOZNlpWNRpOZN1yK7kdLjdhquers,2774
132
+ templates_pro/demo/project/_docs/docs/template-types.md,sha256=ZTZcZ6jfekqNj3GxYvQf-PDytJgTo6MkLtMk8td3bSk,7259
133
+ templates_pro/demo/project/_docs/docs/troubleshooting.md,sha256=NX5BbQ2i3G9mhI3ery_tllweGzq0S4cf7zveZwzjZVs,8335
134
+ templates_pro/demo/project/_docs/example/README.md,sha256=W_KeyiKEdyER4RpQfGsX469E9A4olpGITtpQbczRE-0,4415
135
+ templates_pro/demo/project/_docs/frontend/README.md,sha256=u6GwzdFMnXEYJ44pd8hDQ98ZnSFaWjxXWzvZSTycooA,705
136
+ django_templates_pro-0.3.0.dist-info/METADATA,sha256=Jppe8KMUntvG0CJH_mBi7drI3XXL1oyWluKkAs2Lgvc,9625
137
+ django_templates_pro-0.3.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
138
+ django_templates_pro-0.3.0.dist-info/entry_points.txt,sha256=VStV13EoDM7__C2_vPrYR-YH_0BJEJJrnQnueF6Z_DA,63
139
+ django_templates_pro-0.3.0.dist-info/licenses/LICENSE,sha256=Dv2476UNzcXFNz6gsr0CrewmnoeMvuqcexUtvkcaLkY,1069
140
+ django_templates_pro-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ templates-pro-demo = templates_pro.demo:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Peltransport
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ """django-templates-pro: WYSIWYG document templates for Django.
2
+
3
+ Public API (import from here or from :mod:`templates_pro.services`)::
4
+
5
+ from templates_pro import register, TemplateType, Var, Group, ListOf
6
+ from templates_pro.services import render, render_to_response, generate
7
+ """
8
+
9
+ __version__ = "0.3.0"
10
+
11
+ __all__ = ["register", "TemplateType", "Var", "Group", "ListOf", "__version__"]
12
+
13
+
14
+ def __getattr__(name):
15
+ # Lazy re-exports so ``import templates_pro`` never touches Django settings.
16
+ if name in ("register", "TemplateType"):
17
+ from . import registry
18
+
19
+ return getattr(registry, name)
20
+ if name in ("Var", "Group", "ListOf"):
21
+ from .core import schema
22
+
23
+ return getattr(schema, name)
24
+ raise AttributeError(name)
templates_pro/admin.py ADDED
@@ -0,0 +1,142 @@
1
+ from __future__ import annotations
2
+
3
+ from django.contrib import admin, messages
4
+ from django.urls import NoReverseMatch, reverse
5
+ from django.utils.html import format_html, format_html_join
6
+ from django.utils.translation import gettext_lazy as _
7
+
8
+ from .forms import DocumentTemplateForm, TemplateBlockForm
9
+ from .models import DocumentTemplate, GeneratedDocument, SiteConstant, TemplateBlock
10
+
11
+
12
+ def _preview_url(obj, fmt):
13
+ try:
14
+ return reverse("templates_pro:saved_preview", args=[obj.pk, fmt])
15
+ except NoReverseMatch:
16
+ return None
17
+
18
+
19
+ @admin.register(DocumentTemplate)
20
+ class DocumentTemplateAdmin(admin.ModelAdmin):
21
+ form = DocumentTemplateForm
22
+ list_display = ("name", "type_label", "theme", "formats", "is_default", "is_active",
23
+ "version", "updated_at", "preview_links")
24
+ list_filter = ("template_type", "theme", "is_active", "is_default")
25
+ search_fields = ("name", "slug", "description")
26
+ prepopulated_fields = {"slug": ("name",)}
27
+ readonly_fields = ("version", "variables_list", "blocks_list", "updated_at")
28
+ actions = ["duplicate"]
29
+ fieldsets = (
30
+ (None, {"fields": ("name", "slug", "template_type", "description",
31
+ ("is_active", "is_default"))}),
32
+ (_("Content"), {"fields": ("body",)}),
33
+ (_("Output"), {"fields": ("output_formats", "theme", ("locale", "direction"),
34
+ "filename_pattern")}),
35
+ (_("Page"), {"fields": (("page_size", "orientation", "margin"),
36
+ ("header_block", "footer_block"), "extra_css"),
37
+ "classes": ("collapse",)}),
38
+ (_("Info"), {"fields": ("version", "updated_at", "variables_list", "blocks_list"),
39
+ "classes": ("collapse",)}),
40
+ )
41
+
42
+ @admin.display(description=_("Type"), ordering="template_type")
43
+ def type_label(self, obj):
44
+ return obj.type_label
45
+
46
+ @admin.display(description=_("Formats"))
47
+ def formats(self, obj):
48
+ return ", ".join(f.upper() for f in obj.output_formats or [])
49
+
50
+ @admin.display(description=_("Preview"))
51
+ def preview_links(self, obj):
52
+ links = [(u, f.upper()) for f in obj.output_formats or [] if (u := _preview_url(obj, f))]
53
+ return format_html_join(" · ", '<a href="{}" target="_blank">{}</a>', links) or "-"
54
+
55
+ @admin.display(description=_("Variables used"))
56
+ def variables_list(self, obj):
57
+ return ", ".join(v.replace("[]", "[*]") for v in obj.variables or []) or "-"
58
+
59
+ @admin.display(description=_("Blocks used"))
60
+ def blocks_list(self, obj):
61
+ return ", ".join(sorted(obj.all_block_slugs())) or "-"
62
+
63
+ @admin.action(description=_("Duplicate selected templates"))
64
+ def duplicate(self, request, queryset):
65
+ for tpl in queryset:
66
+ base = f"{tpl.slug}-copy"
67
+ slug, n = base, 2
68
+ while DocumentTemplate.objects.filter(slug=slug).exists():
69
+ slug, n = f"{base}-{n}", n + 1
70
+ tpl.pk, tpl.slug, tpl.is_default = None, slug, False
71
+ tpl.name = f"{tpl.name} (copy)"
72
+ tpl.version = 1
73
+ tpl.save()
74
+ self.message_user(request, _("Duplicated %(n)d template(s).") % {"n": queryset.count()},
75
+ messages.SUCCESS)
76
+
77
+
78
+ @admin.register(TemplateBlock)
79
+ class TemplateBlockAdmin(admin.ModelAdmin):
80
+ form = TemplateBlockForm
81
+ list_display = ("name", "slug", "category", "types", "used_count", "is_active", "updated_at")
82
+ list_filter = ("category", "is_active")
83
+ search_fields = ("name", "slug", "description")
84
+ prepopulated_fields = {"slug": ("name",)}
85
+ readonly_fields = ("used_in_list", "updated_at")
86
+ fieldsets = (
87
+ (None, {"fields": ("name", "slug", "category", "description", "is_active")}),
88
+ (_("Content"), {"fields": ("template_types", "body")}),
89
+ (_("Usage"), {"fields": ("used_in_list", "updated_at")}),
90
+ )
91
+
92
+ @admin.display(description=_("Types"))
93
+ def types(self, obj):
94
+ return ", ".join(obj.template_types or []) or _("all")
95
+
96
+ @admin.display(description=_("Used by"))
97
+ def used_count(self, obj):
98
+ used = TemplateBlock.used_in(obj.slug)
99
+ return len(used.get("templates", [])) + len(used.get("blocks", [])) if used else 0
100
+
101
+ @admin.display(description=_("Used by"))
102
+ def used_in_list(self, obj):
103
+ if not obj.pk:
104
+ return "-"
105
+ used = TemplateBlock.used_in(obj.slug)
106
+ if not used:
107
+ return _("Not used yet")
108
+ items = []
109
+ for t in used.get("templates", []):
110
+ url = reverse("admin:templates_pro_documenttemplate_change", args=[t.pk])
111
+ items.append((url, t.name, _("template")))
112
+ for b in used.get("blocks", []):
113
+ url = reverse("admin:templates_pro_templateblock_change", args=[b.pk])
114
+ items.append((url, b.name, _("block")))
115
+ return format_html("<ul>{}</ul>", format_html_join(
116
+ "", '<li><a href="{}">{}</a> ({})</li>', items))
117
+
118
+
119
+ @admin.register(SiteConstant)
120
+ class SiteConstantAdmin(admin.ModelAdmin):
121
+ list_display = ("label", "key", "value", "is_active")
122
+ list_editable = ("value", "is_active")
123
+ search_fields = ("key", "label", "value")
124
+
125
+
126
+ @admin.register(GeneratedDocument)
127
+ class GeneratedDocumentAdmin(admin.ModelAdmin):
128
+ list_display = ("filename", "template", "format", "size", "created_by", "created_at",
129
+ "download")
130
+ list_filter = ("format", "template_type")
131
+ search_fields = ("filename", "object_id", "checksum")
132
+ readonly_fields = [f.name for f in GeneratedDocument._meta.fields] + ["download"]
133
+
134
+ def has_add_permission(self, request):
135
+ return False
136
+
137
+ def has_change_permission(self, request, obj=None):
138
+ return False
139
+
140
+ @admin.display(description=_("File"))
141
+ def download(self, obj):
142
+ return format_html('<a href="{}">{}</a>', obj.file.url, _("Download")) if obj.file else "-"
templates_pro/apps.py ADDED
@@ -0,0 +1,19 @@
1
+ from django.apps import AppConfig
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+
5
+ class TemplatesProConfig(AppConfig):
6
+ name = "templates_pro"
7
+ label = "templates_pro"
8
+ verbose_name = _("Document templates")
9
+ default_auto_field = "django.db.models.BigAutoField"
10
+
11
+ def ready(self):
12
+ from django.utils.module_loading import autodiscover_modules
13
+
14
+ from . import checks, engines, signals # noqa: F401
15
+
16
+ engines.configure()
17
+
18
+ # Each installed app may define its template types in doctemplate_types.py
19
+ autodiscover_modules("doctemplate_types")
@@ -0,0 +1,49 @@
1
+ """System checks: run with ``manage.py check``."""
2
+
3
+ from django.core.checks import Error, Tags, Warning, register
4
+
5
+ from .conf import tp_settings
6
+
7
+
8
+ @register(Tags.compatibility)
9
+ def check_templates_pro(app_configs=None, **kwargs):
10
+ from .core.renderers import all_renderers
11
+ from .registry import all_types
12
+ from .themes import all_themes, theme_exists
13
+
14
+ messages = []
15
+ renderers = all_renderers()
16
+ for fmt in tp_settings.OUTPUT_FORMATS:
17
+ renderer = renderers.get(fmt)
18
+ if renderer is None:
19
+ messages.append(Error(
20
+ f"TEMPLATES_PRO['OUTPUT_FORMATS'] contains {fmt!r} but no renderer is registered.",
21
+ id="templates_pro.E001"))
22
+ elif not renderer.is_available():
23
+ if fmt == "pdf" and getattr(renderer, "engine", "") == "weasyprint":
24
+ hint = ("WeasyPrint needs its Pango system library (see docs/installation.md), or "
25
+ "remove PDF_ENGINE to use the default Typst engine (no system libraries).")
26
+ elif fmt == "pdf":
27
+ hint = "pip install typst"
28
+ else:
29
+ hint = f"pip install python-docx, or remove {fmt!r} from TEMPLATES_PRO['OUTPUT_FORMATS']."
30
+ messages.append(Warning(
31
+ f"Output format {fmt!r} is enabled but its library is not available.",
32
+ hint=hint, id="templates_pro.W001"))
33
+ for fmt in tp_settings.DEFAULT_OUTPUT_FORMATS:
34
+ if fmt not in tp_settings.OUTPUT_FORMATS:
35
+ messages.append(Error(
36
+ f"DEFAULT_OUTPUT_FORMATS contains {fmt!r}, which is not in OUTPUT_FORMATS.",
37
+ id="templates_pro.E002"))
38
+ for key in all_themes():
39
+ if not theme_exists(key):
40
+ messages.append(Error(f"Theme {key!r}: CSS file not found.", id="templates_pro.E003"))
41
+ if tp_settings.DEFAULT_THEME not in all_themes():
42
+ messages.append(Error(f"DEFAULT_THEME {tp_settings.DEFAULT_THEME!r} is not a known theme.",
43
+ id="templates_pro.E004"))
44
+ if not all_types():
45
+ messages.append(Warning(
46
+ "No document template types are registered.",
47
+ hint="Create a doctemplate_types.py module in one of your apps; see docs/quickstart.md.",
48
+ id="templates_pro.W002"))
49
+ return messages