django-mptt-admin 2.5.1__py3.11.egg

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 (60) hide show
  1. EGG-INFO/PKG-INFO +39 -0
  2. EGG-INFO/SOURCES.txt +65 -0
  3. EGG-INFO/dependency_links.txt +1 -0
  4. EGG-INFO/not-zip-safe +1 -0
  5. EGG-INFO/requires.txt +1 -0
  6. EGG-INFO/top_level.txt +1 -0
  7. django_mptt_admin/__init__.py +0 -0
  8. django_mptt_admin/admin.py +11 -0
  9. django_mptt_admin/django_mptt_admin_mixin.py +337 -0
  10. django_mptt_admin/locale/ca/LC_MESSAGES/django.mo +0 -0
  11. django_mptt_admin/locale/ca/LC_MESSAGES/django.po +30 -0
  12. django_mptt_admin/locale/ca/LC_MESSAGES/djangojs.mo +0 -0
  13. django_mptt_admin/locale/ca/LC_MESSAGES/djangojs.po +34 -0
  14. django_mptt_admin/locale/de/LC_MESSAGES/django.mo +0 -0
  15. django_mptt_admin/locale/de/LC_MESSAGES/django.po +31 -0
  16. django_mptt_admin/locale/de/LC_MESSAGES/djangojs.mo +0 -0
  17. django_mptt_admin/locale/de/LC_MESSAGES/djangojs.po +35 -0
  18. django_mptt_admin/locale/es/LC_MESSAGES/django.mo +0 -0
  19. django_mptt_admin/locale/es/LC_MESSAGES/django.po +30 -0
  20. django_mptt_admin/locale/es/LC_MESSAGES/djangojs.mo +0 -0
  21. django_mptt_admin/locale/es/LC_MESSAGES/djangojs.po +34 -0
  22. django_mptt_admin/locale/fr/LC_MESSAGES/django.mo +0 -0
  23. django_mptt_admin/locale/fr/LC_MESSAGES/django.po +30 -0
  24. django_mptt_admin/locale/fr/LC_MESSAGES/djangojs.mo +0 -0
  25. django_mptt_admin/locale/fr/LC_MESSAGES/djangojs.po +35 -0
  26. django_mptt_admin/locale/he/LC_MESSAGES/django.mo +0 -0
  27. django_mptt_admin/locale/he/LC_MESSAGES/django.po +19 -0
  28. django_mptt_admin/locale/he/LC_MESSAGES/djangojs.mo +0 -0
  29. django_mptt_admin/locale/he/LC_MESSAGES/djangojs.po +25 -0
  30. django_mptt_admin/locale/hu/LC_MESSAGES/django.mo +0 -0
  31. django_mptt_admin/locale/hu/LC_MESSAGES/django.po +24 -0
  32. django_mptt_admin/locale/hu/LC_MESSAGES/djangojs.mo +0 -0
  33. django_mptt_admin/locale/hu/LC_MESSAGES/djangojs.po +24 -0
  34. django_mptt_admin/locale/pl/LC_MESSAGES/django.mo +0 -0
  35. django_mptt_admin/locale/pl/LC_MESSAGES/django.po +31 -0
  36. django_mptt_admin/locale/pl/LC_MESSAGES/djangojs.mo +0 -0
  37. django_mptt_admin/locale/pl/LC_MESSAGES/djangojs.po +35 -0
  38. django_mptt_admin/locale/ru/LC_MESSAGES/django.mo +0 -0
  39. django_mptt_admin/locale/ru/LC_MESSAGES/django.po +20 -0
  40. django_mptt_admin/locale/ru/LC_MESSAGES/djangojs.mo +0 -0
  41. django_mptt_admin/locale/ru/LC_MESSAGES/djangojs.po +32 -0
  42. django_mptt_admin/locale/tr/LC_MESSAGES/django.mo +0 -0
  43. django_mptt_admin/locale/tr/LC_MESSAGES/django.po +19 -0
  44. django_mptt_admin/locale/tr/LC_MESSAGES/djangojs.mo +0 -0
  45. django_mptt_admin/locale/tr/LC_MESSAGES/djangojs.po +25 -0
  46. django_mptt_admin/static/django_mptt_admin/django_mptt_admin.css +260 -0
  47. django_mptt_admin/static/django_mptt_admin/django_mptt_admin.css.map +1 -0
  48. django_mptt_admin/static/django_mptt_admin/django_mptt_admin.debug.js +5014 -0
  49. django_mptt_admin/static/django_mptt_admin/django_mptt_admin.debug.js.map +1 -0
  50. django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js +3 -0
  51. django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js.LICENSE.txt +6 -0
  52. django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js.map +1 -0
  53. django_mptt_admin/static/django_mptt_admin/jqtree-circle.png +0 -0
  54. django_mptt_admin/static/django_mptt_admin/jquery_namespace.js +2 -0
  55. django_mptt_admin/templates/django_mptt_admin/change_list.html +53 -0
  56. django_mptt_admin/templates/django_mptt_admin/grid_view.html +9 -0
  57. django_mptt_admin/templatetags/__init__.py +0 -0
  58. django_mptt_admin/templatetags/javascript_value.py +21 -0
  59. django_mptt_admin/tree_change_list.py +67 -0
  60. django_mptt_admin/util.py +111 -0
EGG-INFO/PKG-INFO ADDED
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.1
2
+ Name: django-mptt-admin
3
+ Version: 2.5.1
4
+ Summary: Django-mptt-admin provides a nice Django Admin interface for Mptt models
5
+ Home-page: https://github.com/mbraak/django-mptt-admin
6
+ Author: Marco Braak
7
+ Author-email: marco.braak@planet.nl
8
+ License: Apache License, Version 2.0
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Framework :: Django
11
+ Classifier: Framework :: Django :: 3.2
12
+ Classifier: Framework :: Django :: 4.0
13
+ Classifier: Framework :: Django :: 4.1
14
+ Classifier: Framework :: Django :: 4.2
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3.7
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: Implementation :: CPython
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE.rst
25
+
26
+ ![Continuous integration](https://github.com/mbraak/django-mptt-admin/workflows/Continuous%20integration/badge.svg) [![Version](https://badge.fury.io/py/django-mptt-admin.svg)](https://pypi.python.org/pypi/django-mptt-admin/)
27
+
28
+ [![codecov](https://codecov.io/gh/mbraak/django-mptt-admin/branch/master/graph/badge.svg?token=YGojePND2M)](https://codecov.io/gh/mbraak/django-mptt-admin)
29
+
30
+ [![License](https://img.shields.io/pypi/l/django-mptt-admin.svg)](https://pypi.python.org/pypi/django-mptt-admin/)
31
+
32
+ # Django Mptt Admin
33
+
34
+ _Django-mptt-admin_ provides a nice Django Admin interface for [django-mptt models](https://django-mptt.readthedocs.io/).
35
+
36
+ - The source is available on [https://github.com/mbraak/django-mptt-admin](https://github.com/mbraak/django-mptt-admin).
37
+ - Documentation is available on [https://mbraak.github.io/django-mptt-admin/](https://mbraak.github.io/django-mptt-admin/).
38
+
39
+ ![Screenshot](https://raw.github.com/mbraak/django-mptt-admin/master/screenshot.png)
EGG-INFO/SOURCES.txt ADDED
@@ -0,0 +1,65 @@
1
+ LICENSE.rst
2
+ MANIFEST.in
3
+ README.md
4
+ setup.cfg
5
+ setup.py
6
+ django_mptt_admin/__init__.py
7
+ django_mptt_admin/admin.py
8
+ django_mptt_admin/django_mptt_admin_mixin.py
9
+ django_mptt_admin/tree_change_list.py
10
+ django_mptt_admin/util.py
11
+ django_mptt_admin.egg-info/PKG-INFO
12
+ django_mptt_admin.egg-info/SOURCES.txt
13
+ django_mptt_admin.egg-info/dependency_links.txt
14
+ django_mptt_admin.egg-info/not-zip-safe
15
+ django_mptt_admin.egg-info/requires.txt
16
+ django_mptt_admin.egg-info/top_level.txt
17
+ django_mptt_admin/locale/ca/LC_MESSAGES/django.mo
18
+ django_mptt_admin/locale/ca/LC_MESSAGES/django.po
19
+ django_mptt_admin/locale/ca/LC_MESSAGES/djangojs.mo
20
+ django_mptt_admin/locale/ca/LC_MESSAGES/djangojs.po
21
+ django_mptt_admin/locale/de/LC_MESSAGES/django.mo
22
+ django_mptt_admin/locale/de/LC_MESSAGES/django.po
23
+ django_mptt_admin/locale/de/LC_MESSAGES/djangojs.mo
24
+ django_mptt_admin/locale/de/LC_MESSAGES/djangojs.po
25
+ django_mptt_admin/locale/es/LC_MESSAGES/django.mo
26
+ django_mptt_admin/locale/es/LC_MESSAGES/django.po
27
+ django_mptt_admin/locale/es/LC_MESSAGES/djangojs.mo
28
+ django_mptt_admin/locale/es/LC_MESSAGES/djangojs.po
29
+ django_mptt_admin/locale/fr/LC_MESSAGES/django.mo
30
+ django_mptt_admin/locale/fr/LC_MESSAGES/django.po
31
+ django_mptt_admin/locale/fr/LC_MESSAGES/djangojs.mo
32
+ django_mptt_admin/locale/fr/LC_MESSAGES/djangojs.po
33
+ django_mptt_admin/locale/he/LC_MESSAGES/django.mo
34
+ django_mptt_admin/locale/he/LC_MESSAGES/django.po
35
+ django_mptt_admin/locale/he/LC_MESSAGES/djangojs.mo
36
+ django_mptt_admin/locale/he/LC_MESSAGES/djangojs.po
37
+ django_mptt_admin/locale/hu/LC_MESSAGES/django.mo
38
+ django_mptt_admin/locale/hu/LC_MESSAGES/django.po
39
+ django_mptt_admin/locale/hu/LC_MESSAGES/djangojs.mo
40
+ django_mptt_admin/locale/hu/LC_MESSAGES/djangojs.po
41
+ django_mptt_admin/locale/pl/LC_MESSAGES/django.mo
42
+ django_mptt_admin/locale/pl/LC_MESSAGES/django.po
43
+ django_mptt_admin/locale/pl/LC_MESSAGES/djangojs.mo
44
+ django_mptt_admin/locale/pl/LC_MESSAGES/djangojs.po
45
+ django_mptt_admin/locale/ru/LC_MESSAGES/django.mo
46
+ django_mptt_admin/locale/ru/LC_MESSAGES/django.po
47
+ django_mptt_admin/locale/ru/LC_MESSAGES/djangojs.mo
48
+ django_mptt_admin/locale/ru/LC_MESSAGES/djangojs.po
49
+ django_mptt_admin/locale/tr/LC_MESSAGES/django.mo
50
+ django_mptt_admin/locale/tr/LC_MESSAGES/django.po
51
+ django_mptt_admin/locale/tr/LC_MESSAGES/djangojs.mo
52
+ django_mptt_admin/locale/tr/LC_MESSAGES/djangojs.po
53
+ django_mptt_admin/static/django_mptt_admin/django_mptt_admin.css
54
+ django_mptt_admin/static/django_mptt_admin/django_mptt_admin.css.map
55
+ django_mptt_admin/static/django_mptt_admin/django_mptt_admin.debug.js
56
+ django_mptt_admin/static/django_mptt_admin/django_mptt_admin.debug.js.map
57
+ django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js
58
+ django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js.LICENSE.txt
59
+ django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js.map
60
+ django_mptt_admin/static/django_mptt_admin/jqtree-circle.png
61
+ django_mptt_admin/static/django_mptt_admin/jquery_namespace.js
62
+ django_mptt_admin/templates/django_mptt_admin/change_list.html
63
+ django_mptt_admin/templates/django_mptt_admin/grid_view.html
64
+ django_mptt_admin/templatetags/__init__.py
65
+ django_mptt_admin/templatetags/javascript_value.py
@@ -0,0 +1 @@
1
+
EGG-INFO/not-zip-safe ADDED
@@ -0,0 +1 @@
1
+
EGG-INFO/requires.txt ADDED
@@ -0,0 +1 @@
1
+ django-mptt
EGG-INFO/top_level.txt ADDED
@@ -0,0 +1 @@
1
+ django_mptt_admin
File without changes
@@ -0,0 +1,11 @@
1
+ from mptt.admin import MPTTModelAdmin
2
+
3
+ from .django_mptt_admin_mixin import DjangoMpttAdminMixin
4
+
5
+
6
+ class DjangoMpttAdmin(DjangoMpttAdminMixin, MPTTModelAdmin):
7
+ pass
8
+
9
+
10
+ class FilterableDjangoMpttAdmin(DjangoMpttAdmin):
11
+ pass
@@ -0,0 +1,337 @@
1
+ from functools import update_wrapper
2
+ from typing import Union
3
+
4
+ from django.conf import settings
5
+ from django.templatetags.static import static
6
+ from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
7
+ from django.core.exceptions import PermissionDenied, SuspiciousOperation
8
+ from django.http import JsonResponse
9
+ from django.template.response import TemplateResponse
10
+ from django.contrib.admin.options import csrf_protect_m, ModelAdmin
11
+ from django.contrib.admin.utils import unquote, quote
12
+ from django.contrib.admin.options import IS_POPUP_VAR
13
+ from django.db import transaction
14
+ from django.utils.http import urlencode
15
+ from django.forms import Media
16
+ from django.urls import re_path, reverse
17
+ from django.views.i18n import JavaScriptCatalog
18
+
19
+ from . import util
20
+ from .tree_change_list import TreeChangeList
21
+
22
+
23
+ class DjangoMpttAdminMixin:
24
+ tree_animation_speed = None
25
+ tree_auto_open = 1
26
+ tree_load_on_demand = 1
27
+ tree_mouse_delay = None
28
+ trigger_save_after_move = False
29
+
30
+ # Autoescape the tree data; default is True
31
+ autoescape = True
32
+
33
+ # useContextMenu option for the tree; default is False
34
+ use_context_menu = False
35
+
36
+ change_list_template = "django_mptt_admin/grid_view.html"
37
+ change_tree_template = "django_mptt_admin/change_list.html"
38
+
39
+ # define which field of the model should be the label for tree items
40
+ item_label_field_name = None
41
+
42
+ # list and tree filter
43
+ list_filter = ()
44
+
45
+ change_list_tree_class = TreeChangeList
46
+
47
+ @csrf_protect_m
48
+ def changelist_view(self: Union[ModelAdmin, 'DjangoMpttAdminMixin'], request, extra_context=None):
49
+ request.current_app = self.admin_site.name
50
+ is_popup = IS_POPUP_VAR in request.GET
51
+ if is_popup:
52
+ return super(DjangoMpttAdminMixin, self).changelist_view(request, extra_context=extra_context)
53
+
54
+ if not self.has_view_permission(request, None):
55
+ raise PermissionDenied()
56
+
57
+ change_list = self.get_change_list_for_tree(request)
58
+
59
+ preserved_filters = self.get_preserved_filters(request)
60
+
61
+ def get_admin_url_with_filters(name):
62
+ admin_url = self.get_admin_url(name)
63
+
64
+ if change_list.params:
65
+ return admin_url + change_list.get_query_string()
66
+ else:
67
+ return admin_url
68
+
69
+ def get_admin_url_with_preserved_filters(name):
70
+ return add_preserved_filters(
71
+ {"preserved_filters": preserved_filters, "opts": self.opts},
72
+ self.get_admin_url(name),
73
+ )
74
+
75
+ def get_csrf_cookie_name():
76
+ if settings.CSRF_USE_SESSIONS:
77
+ return ""
78
+ else:
79
+ return settings.CSRF_COOKIE_NAME
80
+
81
+ grid_url = get_admin_url_with_filters("grid")
82
+ tree_json_url = get_admin_url_with_filters("tree_json")
83
+ insert_at_url = get_admin_url_with_preserved_filters("add")
84
+
85
+ context = dict(
86
+ app_label=self.opts.app_label,
87
+ autoescape=self.autoescape,
88
+ cl=change_list,
89
+ csrf_cookie_name=get_csrf_cookie_name(),
90
+ drag_and_drop=self.is_drag_and_drop_enabled(),
91
+ grid_url=grid_url,
92
+ has_add_permission=self.has_add_permission(request),
93
+ has_change_permission=self.has_change_permission(request),
94
+ insert_at_url=insert_at_url,
95
+ jsi18n_url=self.get_admin_url("jsi18n"),
96
+ media=self.get_tree_media(),
97
+ model_name=util.get_model_name(self.model),
98
+ opts=change_list.opts,
99
+ preserved_filters=preserved_filters,
100
+ title=change_list.title,
101
+ tree_animation_speed=self.tree_animation_speed,
102
+ tree_auto_open=self.tree_auto_open,
103
+ tree_json_url=tree_json_url,
104
+ tree_mouse_delay=self.get_tree_mouse_delay(),
105
+ use_context_menu=self.use_context_menu,
106
+ )
107
+ if extra_context:
108
+ context.update(extra_context)
109
+
110
+ context.update(self.admin_site.each_context(request))
111
+
112
+ return TemplateResponse(request, self.change_tree_template, context)
113
+
114
+ def get_urls(self: Union[ModelAdmin, 'DjangoMpttAdminMixin']):
115
+ def wrap(view, cacheable=False):
116
+ def wrapper(*args, **kwargs):
117
+ return self.admin_site.admin_view(view, cacheable)(*args, **kwargs)
118
+
119
+ return update_wrapper(wrapper, view)
120
+
121
+ def create_url(regex, url_name, view, kwargs=None, cacheable=False):
122
+ return re_path(
123
+ regex,
124
+ wrap(view, cacheable),
125
+ kwargs=kwargs,
126
+ name="{0!s}_{1!s}_{2!s}".format(
127
+ self.opts.app_label,
128
+ util.get_model_name(self.model),
129
+ url_name,
130
+ ),
131
+ )
132
+
133
+ def create_js_catalog_url():
134
+ packages = ["django_mptt_admin"]
135
+ url_pattern = r"^jsi18n/$"
136
+
137
+ return create_url(
138
+ url_pattern,
139
+ "jsi18n",
140
+ JavaScriptCatalog.as_view(packages=packages),
141
+ cacheable=True,
142
+ )
143
+
144
+ # prepend new urls to existing urls
145
+ return [
146
+ create_url(r"^(.+)/move/$", "move", self.move_view),
147
+ create_url(r"^tree_json/$", "tree_json", self.tree_json_view),
148
+ create_url(r"^grid/$", "grid", self.grid_view),
149
+ create_js_catalog_url(),
150
+ ] + super(DjangoMpttAdminMixin, self).get_urls()
151
+
152
+ def get_tree_media(self: ModelAdmin):
153
+ django_mptt_admin_js = (
154
+ "django_mptt_admin.coverage.js"
155
+ if getattr(settings, 'DJANGO_MPTT_ADMIN_COVERAGE_JS', False)
156
+ else "django_mptt_admin.js"
157
+ )
158
+
159
+ js = [
160
+ "admin/js/jquery.init.js",
161
+ static("django_mptt_admin/jquery_namespace.js"),
162
+ static(f"django_mptt_admin/{django_mptt_admin_js}"),
163
+ ]
164
+ css = dict(all=(static("django_mptt_admin/django_mptt_admin.css"),))
165
+
166
+ tree_media = Media(js=js, css=css)
167
+
168
+ return self.media + tree_media
169
+
170
+ @csrf_protect_m
171
+ @transaction.atomic()
172
+ def move_view(self: Union[ModelAdmin, 'DjangoMpttAdminMixin'], request, object_id):
173
+ request.current_app = self.admin_site.name
174
+ instance = self.get_object(request, unquote(object_id))
175
+
176
+ if not self.has_change_permission(request, instance):
177
+ raise PermissionDenied()
178
+
179
+ if request.method != "POST":
180
+ raise SuspiciousOperation()
181
+
182
+ target_id = request.POST["target_id"]
183
+ position = request.POST["position"]
184
+ target_instance = self.get_object(request, target_id)
185
+
186
+ self.do_move(instance, position, target_instance)
187
+
188
+ return JsonResponse(dict(success=True))
189
+
190
+ def do_move(self, instance, position, target_instance):
191
+ if position == "before":
192
+ instance.move_to(target_instance, "left")
193
+ elif position == "after":
194
+ instance.move_to(target_instance, "right")
195
+ elif position == "inside":
196
+ instance.move_to(target_instance)
197
+ else:
198
+ raise Exception("Unknown position")
199
+
200
+ if self.trigger_save_after_move:
201
+ instance.save()
202
+
203
+ def get_change_list_for_tree(self: Union[ModelAdmin, 'DjangoMpttAdminMixin'], request, node_id=None, max_level=None):
204
+ request.current_app = self.admin_site.name
205
+
206
+ return self.change_list_tree_class(
207
+ request=request,
208
+ model=self.model,
209
+ model_admin=self,
210
+ list_filter=self.get_list_filter(request),
211
+ node_id=node_id,
212
+ max_level=max_level,
213
+ )
214
+
215
+ def get_admin_url(self: ModelAdmin, name, args=None):
216
+ opts = self.opts
217
+ url_name = "admin:{0!s}_{1!s}_{2!s}".format(
218
+ opts.app_label, util.get_model_name(self.model), name
219
+ )
220
+
221
+ return reverse(url_name, args=args, current_app=self.admin_site.name)
222
+
223
+ def get_tree_data(self: Union[ModelAdmin, 'DjangoMpttAdminMixin'], qs, max_level, filters_params):
224
+ pk_attname = self.opts.pk.attname
225
+
226
+ preserved_filters = urlencode(
227
+ {"_changelist_filters": urlencode(filters_params)}
228
+ )
229
+
230
+ def add_preserved_filters_to_url(url):
231
+ return add_preserved_filters(
232
+ {"preserved_filters": preserved_filters, "opts": self.opts}, url
233
+ )
234
+
235
+ def handle_create_node(instance, node_info):
236
+ pk = quote(getattr(instance, pk_attname))
237
+
238
+ node_url = add_preserved_filters_to_url(
239
+ self.get_admin_url("change", (quote(pk),))
240
+ )
241
+
242
+ node_info.update(
243
+ url=node_url, move_url=self.get_admin_url("move", (quote(pk),))
244
+ )
245
+
246
+ return util.get_tree_from_queryset(
247
+ qs, handle_create_node, max_level, self.item_label_field_name
248
+ )
249
+
250
+ def tree_json_view(self: Union[ModelAdmin, 'DjangoMpttAdminMixin'], request):
251
+ request.current_app = self.admin_site.name
252
+ node_id = request.GET.get("node")
253
+
254
+ def get_max_level():
255
+ if node_id:
256
+ node = self.model.objects.get(pk=node_id)
257
+ return node.level + 1
258
+ else:
259
+ return self.tree_load_on_demand
260
+
261
+ max_level = get_max_level()
262
+
263
+ change_list = self.get_change_list_for_tree(request, node_id, max_level)
264
+
265
+ qs = change_list.get_queryset(request)
266
+ qs = self.filter_tree_queryset(qs, request)
267
+
268
+ tree_data = self.get_tree_data(qs, max_level, change_list.get_filters_params())
269
+
270
+ # Set safe to False because the data is a list instead of a dict
271
+ return JsonResponse(tree_data, safe=False)
272
+
273
+ def grid_view(self: Union[ModelAdmin, 'DjangoMpttAdminMixin'], request, extra_context=None):
274
+ request.current_app = self.admin_site.name
275
+
276
+ preserved_filters = self.get_preserved_filters(request)
277
+
278
+ tree_url = add_preserved_filters(
279
+ {"preserved_filters": preserved_filters, "opts": self.opts},
280
+ self.get_admin_url("changelist"),
281
+ )
282
+
283
+ context = dict(tree_url=tree_url)
284
+
285
+ if extra_context:
286
+ context.update(extra_context)
287
+ return super(DjangoMpttAdminMixin, self).changelist_view(request, context)
288
+
289
+ def get_preserved_filters(self: Union[ModelAdmin, 'DjangoMpttAdminMixin'], request):
290
+ """
291
+ Override `get_preserved_filters` to make sure that it returns the current filters for the grid view.
292
+ """
293
+
294
+ def must_return_current_filters():
295
+ match = request.resolver_match
296
+
297
+ if not self.preserve_filters or not match:
298
+ return False
299
+ else:
300
+ opts = self.opts
301
+ current_url = "{0!s}:{1!s}".format(match.app_name, match.url_name)
302
+ grid_url = "admin:{0!s}_{1!s}_grid".format(
303
+ opts.app_label, opts.model_name
304
+ )
305
+
306
+ return current_url == grid_url
307
+
308
+ if must_return_current_filters():
309
+ # for the grid view return the current filters
310
+ preserved_filters = request.GET.urlencode()
311
+ return urlencode({"_changelist_filters": preserved_filters})
312
+ else:
313
+ return super(DjangoMpttAdminMixin, self).get_preserved_filters(request)
314
+
315
+ def filter_tree_queryset(self, queryset, request):
316
+ """
317
+ Override 'filter_tree_queryset' to filter the queryset for the tree.
318
+ """
319
+ return queryset
320
+
321
+ def get_changeform_initial_data(self: Union[ModelAdmin, 'DjangoMpttAdminMixin'], request):
322
+ initial_data = super(DjangoMpttAdminMixin, self).get_changeform_initial_data(request=request)
323
+
324
+ if "insert_at" in request.GET:
325
+ initial_data[self.get_insert_at_field()] = request.GET.get("insert_at")
326
+
327
+ return initial_data
328
+
329
+ def get_insert_at_field(self):
330
+ return "parent"
331
+
332
+ def is_drag_and_drop_enabled(self) -> bool:
333
+ # Override this method to disable drag-and-drop
334
+ return True
335
+
336
+ def get_tree_mouse_delay(self):
337
+ return self.tree_mouse_delay
@@ -0,0 +1,30 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2020-03-12 11:48+0100\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+ #: django_mptt_admin/templates/django_mptt_admin/change_list.html:31
21
+ msgid "Filter"
22
+ msgstr "Filtre"
23
+
24
+ #: django_mptt_admin/templates/django_mptt_admin/change_list.html:42
25
+ msgid "Grid view"
26
+ msgstr "Vista de quadrícula"
27
+
28
+ #: django_mptt_admin/templates/django_mptt_admin/grid_view.html:7
29
+ msgid "Tree view"
30
+ msgstr "Vista d'arbre"
@@ -0,0 +1,34 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2020-03-12 11:51+0100\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+ #: django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js:1
21
+ msgid "edit"
22
+ msgstr "editar"
23
+
24
+ #: django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js:1
25
+ msgid "add"
26
+ msgstr "afegir"
27
+
28
+ #: django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js:1
29
+ msgid "Error while loading the data from the server"
30
+ msgstr "Error quan es carregaven les dades del servidor"
31
+
32
+ #: django_mptt_admin/static/django_mptt_admin/django_mptt_admin.js:1
33
+ msgid "move failed"
34
+ msgstr "moviment fallit"
@@ -0,0 +1,31 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2020-01-22 09:30+0100\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+
21
+ #: templates/django_mptt_admin/change_list.html:31
22
+ msgid "Filter"
23
+ msgstr ""
24
+
25
+ #: templates/django_mptt_admin/change_list.html:42
26
+ msgid "Grid view"
27
+ msgstr "Tabellenansicht"
28
+
29
+ #: templates/django_mptt_admin/grid_view.html:7
30
+ msgid "Tree view"
31
+ msgstr "Baumansicht"
@@ -0,0 +1,35 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2020-01-22 09:32+0100\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+
21
+ #: static/django_mptt_admin/django_mptt_admin.js:1
22
+ msgid "edit"
23
+ msgstr "Bearbeiten"
24
+
25
+ #: static/django_mptt_admin/django_mptt_admin.js:1
26
+ msgid "add"
27
+ msgstr "Neu"
28
+
29
+ #: static/django_mptt_admin/django_mptt_admin.js:1
30
+ msgid "Error while loading the data from the server"
31
+ msgstr "Fehler beim Laden der Daten vom Server"
32
+
33
+ #: static/django_mptt_admin/django_mptt_admin.js:1
34
+ msgid "move failed"
35
+ msgstr "Verschieben fehlgeschlagen"
@@ -0,0 +1,30 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2020-03-12 11:55+0100\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+ #: django_mptt_admin/templates/django_mptt_admin/change_list.html:31
21
+ msgid "Filter"
22
+ msgstr "Filtro"
23
+
24
+ #: django_mptt_admin/templates/django_mptt_admin/change_list.html:42
25
+ msgid "Grid view"
26
+ msgstr "Vista de cuadrícula"
27
+
28
+ #: django_mptt_admin/templates/django_mptt_admin/grid_view.html:7
29
+ msgid "Tree view"
30
+ msgstr "Vista de árbol"