kopia lustrzana https://github.com/wagtail/wagtail
Eliminate template tags from snippet chooser JS
rodzic
568928215e
commit
a5a3e0251f
|
@ -1,4 +1,4 @@
|
|||
function(modal) {
|
||||
modal.respond('snippetChosen', {{ snippet_json|safe }});
|
||||
function(modal, jsonData) {
|
||||
modal.respond('snippetChosen', jsonData['result']);
|
||||
modal.close();
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
import json
|
||||
|
||||
from django.contrib.admin.utils import quote, unquote
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.urls import reverse
|
||||
|
@ -74,17 +72,15 @@ def chosen(request, app_label, model_name, pk):
|
|||
model = get_snippet_model_from_url_params(app_label, model_name)
|
||||
item = get_object_or_404(model, pk=unquote(pk))
|
||||
|
||||
snippet_json = json.dumps({
|
||||
snippet_data = {
|
||||
'id': item.pk,
|
||||
'string': str(item),
|
||||
'edit_link': reverse('wagtailsnippets:edit', args=(
|
||||
app_label, model_name, quote(item.pk)))
|
||||
})
|
||||
}
|
||||
|
||||
return render_modal_workflow(
|
||||
request,
|
||||
None, 'wagtailsnippets/chooser/chosen.js',
|
||||
{
|
||||
'snippet_json': snippet_json,
|
||||
}
|
||||
None, json_data={'result': snippet_data}
|
||||
)
|
||||
|
|
Ładowanie…
Reference in New Issue