django-json-widget 2.0.1__tar.gz → 2.0.2__tar.gz

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 (29) hide show
  1. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/AUTHORS.rst +2 -0
  2. django_json_widget-2.0.2/CHANGELOG.rst +57 -0
  3. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/MANIFEST.in +1 -1
  4. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/PKG-INFO +64 -7
  5. django_json_widget-2.0.2/django_json_widget/__init__.py +1 -0
  6. django_json_widget-2.0.2/django_json_widget/widgets.py +88 -0
  7. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget.egg-info/PKG-INFO +64 -7
  8. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget.egg-info/SOURCES.txt +1 -1
  9. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/setup.cfg +1 -1
  10. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/setup.py +2 -2
  11. django-json-widget-2.0.1/HISTORY.rst +0 -9
  12. django-json-widget-2.0.1/django_json_widget/__init__.py +0 -1
  13. django-json-widget-2.0.1/django_json_widget/widgets.py +0 -45
  14. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/CONTRIBUTING.rst +0 -0
  15. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/LICENSE +0 -0
  16. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/README.rst +0 -0
  17. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget/apps.py +0 -0
  18. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget/models.py +0 -0
  19. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget/static/css/django_json_widget.css +0 -0
  20. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget/static/dist/img/jsoneditor-icons.svg +0 -0
  21. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget/static/dist/jsoneditor.min.css +0 -0
  22. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget/static/dist/jsoneditor.min.js +0 -0
  23. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget/templates/django_json_widget.html +0 -0
  24. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget/urls.py +0 -0
  25. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget/views.py +0 -0
  26. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget.egg-info/dependency_links.txt +0 -0
  27. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget.egg-info/not-zip-safe +0 -0
  28. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/django_json_widget.egg-info/top_level.txt +0 -0
  29. {django-json-widget-2.0.1 → django_json_widget-2.0.2}/tests/test_models.py +0 -0
@@ -25,3 +25,5 @@ Contributors
25
25
  * Michał Bielawski (D3X)
26
26
  * Ashok Argent-Katwala (ashokdelphia)
27
27
  * Chris Culhane (cfculhane)
28
+ * Amar Sahinovic (amarsahinovic)
29
+ * Erfan Arefmehr (erfan-rfmhr)
@@ -0,0 +1,57 @@
1
+ =========
2
+ Changelog
3
+ =========
4
+
5
+ 2.0.2 (2025-07-28)
6
+ ------------------
7
+
8
+ * Fix Version 2.0.1 causes rendering HTML scripts issue #80
9
+
10
+ 2.0.1 (2024-03-02)
11
+ ------------------=
12
+
13
+ * Fixed Version 2.0.0 causes issues with Django 4.x due to missing sourcemaps issue #83
14
+
15
+ 2.0.0 (2024-03-24)
16
+ ------------------
17
+
18
+ * Fix default paths for static files #53
19
+ * Stop declaring support for Django versions before 3.2 #65
20
+ * Avoid HTML injection via unsafe JSON injection #64
21
+ * Remove source map reference from JS bundle #70
22
+ * Add dark mode CSS support #82
23
+ * Updated documentation
24
+
25
+ 1.1.1 (2021-02-17)
26
+ ------------------
27
+
28
+ * Fix for issue #51, updates the bundled libs to 9.1.9 and additional notes for Django 3.1 changes
29
+
30
+ 1.1.0 (2021-02-05)
31
+ ------------------
32
+
33
+ * Added functionality to override version of JSONEditor to use
34
+ * update readme for django 3.1
35
+
36
+ 1.0.1 (2020-04-17)
37
+ ------------------
38
+
39
+ * Stop resolving paths to the static files
40
+
41
+ 1.0.0 (2020-01-16)
42
+ ------------------
43
+
44
+ * Update Makefile
45
+ * Make Stable the project
46
+
47
+
48
+ 0.3.0 (2020-01-16)
49
+ ------------------
50
+
51
+ * Update requirements.txt
52
+ * Fixed static to work with CDN tools like django-storages
53
+ * Make widget more configurable
54
+ * Fixed an incompatibility with Python 2.7
55
+ * update jsoneditor to latest version
56
+
57
+
@@ -1,6 +1,6 @@
1
1
  include AUTHORS.rst
2
2
  include CONTRIBUTING.rst
3
- include HISTORY.rst
3
+ include CHANGELOG.rst
4
4
  include LICENSE
5
5
  include README.rst
6
6
  recursive-include django_json_widget *.html *.png *.gif *js *.css *jpg *jpeg *svg *py
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: django-json-widget
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: Django json widget is an alternative widget that makes it easy to edit the jsonfield field of django.
5
5
  Home-page: https://github.com/jmrivas86/django-json-widget
6
6
  Author: José Manuel Rivas
@@ -25,6 +25,15 @@ Classifier: Programming Language :: Python :: 3.11
25
25
  Classifier: Programming Language :: Python :: 3.12
26
26
  License-File: LICENSE
27
27
  License-File: AUTHORS.rst
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: home-page
33
+ Dynamic: keywords
34
+ Dynamic: license
35
+ Dynamic: license-file
36
+ Dynamic: summary
28
37
 
29
38
  =============================
30
39
  django-json-widget
@@ -133,12 +142,60 @@ Tools used in rendering this package:
133
142
  .. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage
134
143
 
135
144
 
145
+ =========
146
+ Changelog
147
+ =========
136
148
 
149
+ 2.0.2 (2025-07-28)
150
+ ------------------
137
151
 
138
- History
139
- -------
152
+ * Fix Version 2.0.1 causes rendering HTML scripts issue #80
153
+
154
+ 2.0.1 (2024-03-02)
155
+ ------------------=
156
+
157
+ * Fixed Version 2.0.0 causes issues with Django 4.x due to missing sourcemaps issue #83
158
+
159
+ 2.0.0 (2024-03-24)
160
+ ------------------
161
+
162
+ * Fix default paths for static files #53
163
+ * Stop declaring support for Django versions before 3.2 #65
164
+ * Avoid HTML injection via unsafe JSON injection #64
165
+ * Remove source map reference from JS bundle #70
166
+ * Add dark mode CSS support #82
167
+ * Updated documentation
168
+
169
+ 1.1.1 (2021-02-17)
170
+ ------------------
171
+
172
+ * Fix for issue #51, updates the bundled libs to 9.1.9 and additional notes for Django 3.1 changes
173
+
174
+ 1.1.0 (2021-02-05)
175
+ ------------------
176
+
177
+ * Added functionality to override version of JSONEditor to use
178
+ * update readme for django 3.1
179
+
180
+ 1.0.1 (2020-04-17)
181
+ ------------------
182
+
183
+ * Stop resolving paths to the static files
184
+
185
+ 1.0.0 (2020-01-16)
186
+ ------------------
187
+
188
+ * Update Makefile
189
+ * Make Stable the project
190
+
191
+
192
+ 0.3.0 (2020-01-16)
193
+ ------------------
194
+
195
+ * Update requirements.txt
196
+ * Fixed static to work with CDN tools like django-storages
197
+ * Make widget more configurable
198
+ * Fixed an incompatibility with Python 2.7
199
+ * update jsoneditor to latest version
140
200
 
141
- 0.1.0 (2017-05-10)
142
- ++++++++++++++++++
143
201
 
144
- * First release on PyPI.
@@ -0,0 +1 @@
1
+ __version__ = '2.0.2'
@@ -0,0 +1,88 @@
1
+ import html
2
+ import json
3
+ from builtins import super
4
+
5
+ from django import forms
6
+ from django.conf import settings
7
+
8
+
9
+ class JSONEditorWidget(forms.Widget):
10
+ class Media:
11
+ js = (
12
+ getattr(settings, "JSON_EDITOR_JS", 'dist/jsoneditor.min.js'),
13
+ )
14
+ css = {
15
+ 'all': (
16
+ getattr(settings, "JSON_EDITOR_CSS", 'dist/jsoneditor.min.css'),
17
+ )
18
+ }
19
+
20
+ template_name = 'django_json_widget.html'
21
+
22
+ def __init__(self, attrs=None, mode='code', options=None, width=None, height=None):
23
+ default_options = {
24
+ 'modes': ['text', 'code', 'tree', 'form', 'view'],
25
+ 'mode': mode,
26
+ 'search': True,
27
+ }
28
+ if options:
29
+ default_options.update(options)
30
+
31
+ self.options = default_options
32
+ self.width = width
33
+ self.height = height
34
+
35
+ super(JSONEditorWidget, self).__init__(attrs=attrs)
36
+
37
+ def get_context(self, name, value, attrs):
38
+ context = super().get_context(name, value, attrs)
39
+ context['widget']['options'] = json.dumps(self.options)
40
+ context['widget']['width'] = self.width
41
+ context['widget']['height'] = self.height
42
+
43
+ if value:
44
+ if isinstance(value, str):
45
+ try:
46
+ value = json.loads(value)
47
+ except json.JSONDecodeError:
48
+ pass
49
+
50
+ def escape_html_in_json(obj):
51
+ if isinstance(obj, str):
52
+ return html.escape(obj)
53
+ elif isinstance(obj, dict):
54
+ return {k: escape_html_in_json(v) for k, v in obj.items()}
55
+ elif isinstance(obj, (list, tuple)):
56
+ return [escape_html_in_json(item) for item in obj]
57
+ return obj
58
+
59
+ # Escape HTML in the value
60
+ safe_value = escape_html_in_json(value)
61
+ # Convert back to JSON string
62
+ context["widget"]["value"] = json.dumps(safe_value)
63
+
64
+ return context
65
+
66
+ def format_value(self, value):
67
+ """
68
+ When form is submitted, unescape the HTML entities in the JSON data
69
+ """
70
+ value = json.loads(value)
71
+ if value:
72
+ try:
73
+ json_value = json.loads(value)
74
+
75
+ def unescape_html_in_json(obj):
76
+ if isinstance(obj, str):
77
+ return html.unescape(obj)
78
+ elif isinstance(obj, dict):
79
+ return {k: unescape_html_in_json(v) for k, v in obj.items()}
80
+ elif isinstance(obj, (list, tuple)):
81
+ return [unescape_html_in_json(item) for item in obj]
82
+ return obj
83
+
84
+ unescaped_value = unescape_html_in_json(json_value)
85
+ return json.dumps(unescaped_value)
86
+ except json.JSONDecodeError:
87
+ return value
88
+ return value
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: django-json-widget
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: Django json widget is an alternative widget that makes it easy to edit the jsonfield field of django.
5
5
  Home-page: https://github.com/jmrivas86/django-json-widget
6
6
  Author: José Manuel Rivas
@@ -25,6 +25,15 @@ Classifier: Programming Language :: Python :: 3.11
25
25
  Classifier: Programming Language :: Python :: 3.12
26
26
  License-File: LICENSE
27
27
  License-File: AUTHORS.rst
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: home-page
33
+ Dynamic: keywords
34
+ Dynamic: license
35
+ Dynamic: license-file
36
+ Dynamic: summary
28
37
 
29
38
  =============================
30
39
  django-json-widget
@@ -133,12 +142,60 @@ Tools used in rendering this package:
133
142
  .. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage
134
143
 
135
144
 
145
+ =========
146
+ Changelog
147
+ =========
136
148
 
149
+ 2.0.2 (2025-07-28)
150
+ ------------------
137
151
 
138
- History
139
- -------
152
+ * Fix Version 2.0.1 causes rendering HTML scripts issue #80
153
+
154
+ 2.0.1 (2024-03-02)
155
+ ------------------=
156
+
157
+ * Fixed Version 2.0.0 causes issues with Django 4.x due to missing sourcemaps issue #83
158
+
159
+ 2.0.0 (2024-03-24)
160
+ ------------------
161
+
162
+ * Fix default paths for static files #53
163
+ * Stop declaring support for Django versions before 3.2 #65
164
+ * Avoid HTML injection via unsafe JSON injection #64
165
+ * Remove source map reference from JS bundle #70
166
+ * Add dark mode CSS support #82
167
+ * Updated documentation
168
+
169
+ 1.1.1 (2021-02-17)
170
+ ------------------
171
+
172
+ * Fix for issue #51, updates the bundled libs to 9.1.9 and additional notes for Django 3.1 changes
173
+
174
+ 1.1.0 (2021-02-05)
175
+ ------------------
176
+
177
+ * Added functionality to override version of JSONEditor to use
178
+ * update readme for django 3.1
179
+
180
+ 1.0.1 (2020-04-17)
181
+ ------------------
182
+
183
+ * Stop resolving paths to the static files
184
+
185
+ 1.0.0 (2020-01-16)
186
+ ------------------
187
+
188
+ * Update Makefile
189
+ * Make Stable the project
190
+
191
+
192
+ 0.3.0 (2020-01-16)
193
+ ------------------
194
+
195
+ * Update requirements.txt
196
+ * Fixed static to work with CDN tools like django-storages
197
+ * Make widget more configurable
198
+ * Fixed an incompatibility with Python 2.7
199
+ * update jsoneditor to latest version
140
200
 
141
- 0.1.0 (2017-05-10)
142
- ++++++++++++++++++
143
201
 
144
- * First release on PyPI.
@@ -1,6 +1,6 @@
1
1
  AUTHORS.rst
2
+ CHANGELOG.rst
2
3
  CONTRIBUTING.rst
3
- HISTORY.rst
4
4
  LICENSE
5
5
  MANIFEST.in
6
6
  README.rst
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 2.0.1
2
+ current_version = 2.0.2
3
3
  commit = True
4
4
  tag = True
5
5
 
@@ -42,11 +42,11 @@ if sys.argv[-1] == 'tag':
42
42
  sys.exit()
43
43
 
44
44
  readme = open('README.rst').read()
45
- history = open('HISTORY.rst').read().replace('.. :changelog:', '')
45
+ history = open('CHANGELOG.rst').read().replace('.. :changelog:', '')
46
46
 
47
47
  setup(
48
48
  name='django-json-widget',
49
- version='2.0.1',
49
+ version='2.0.2',
50
50
  description="""Django json widget is an alternative widget that makes it easy to edit the jsonfield field of django.""",
51
51
  long_description=readme + '\n\n' + history,
52
52
  author='José Manuel Rivas',
@@ -1,9 +0,0 @@
1
- .. :changelog:
2
-
3
- History
4
- -------
5
-
6
- 0.1.0 (2017-05-10)
7
- ++++++++++++++++++
8
-
9
- * First release on PyPI.
@@ -1 +0,0 @@
1
- __version__ = '2.0.1'
@@ -1,45 +0,0 @@
1
- import json
2
- from builtins import super
3
-
4
- from django import forms
5
- from django.conf import settings
6
-
7
-
8
- class JSONEditorWidget(forms.Widget):
9
- class Media:
10
- js = (
11
- getattr(settings, "JSON_EDITOR_JS", 'dist/jsoneditor.min.js'),
12
- )
13
- css = {
14
- 'all': (
15
- getattr(settings, "JSON_EDITOR_CSS", 'dist/jsoneditor.min.css'),
16
- )
17
- }
18
-
19
- template_name = 'django_json_widget.html'
20
-
21
- def __init__(self, attrs=None, mode='code', options=None, width=None, height=None):
22
- default_options = {
23
- 'modes': ['text', 'code', 'tree', 'form', 'view'],
24
- 'mode': mode,
25
- 'search': True,
26
- }
27
- if options:
28
- default_options.update(options)
29
-
30
- self.options = default_options
31
- self.width = width
32
- self.height = height
33
-
34
- super(JSONEditorWidget, self).__init__(attrs=attrs)
35
-
36
- def get_context(self, name, value, attrs):
37
- context = super().get_context(name, value, attrs)
38
- context['widget']['options'] = json.dumps(self.options)
39
- context['widget']['width'] = self.width
40
- context['widget']['height'] = self.height
41
-
42
- return context
43
-
44
- def format_value(self, value):
45
- return json.loads(value)