Render only useful content when displaying modals
This commit is contained in:
parent
a8f24b6581
commit
69b94c9493
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load django_tables2 i18n %}
|
{% load django_tables2 i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load django_tables2 i18n %}
|
{% load django_tables2 i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load i18n static crispy_forms_filters %}
|
{% load i18n static crispy_forms_filters %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_tags %}
|
{% load crispy_forms_tags %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n static %}
|
{% load crispy_forms_filters i18n static %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters i18n %}
|
{% load crispy_forms_filters i18n %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load i18n static crispy_forms_filters %}
|
{% load i18n static crispy_forms_filters %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load i18n static crispy_forms_filters %}
|
{% load i18n static crispy_forms_filters %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load i18n static crispy_forms_filters %}
|
{% load i18n static crispy_forms_filters %}
|
||||||
|
|
||||||
|
|
|
@ -52,3 +52,16 @@ class SessionMiddleware(object):
|
||||||
_set_current_user_and_ip(None, None, None)
|
_set_current_user_and_ip(None, None, None)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
class FetchMiddleware(object):
|
||||||
|
"""
|
||||||
|
This middleware let requests to know when this was called by a fetch command or not.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, get_response):
|
||||||
|
self.get_response = get_response
|
||||||
|
|
||||||
|
def __call__(self, request):
|
||||||
|
request.content_only = 'CONTENT_ONLY' in request.headers
|
||||||
|
return self.get_response(request)
|
||||||
|
|
|
@ -87,6 +87,7 @@ MIDDLEWARE = [
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
'django.middleware.locale.LocaleMiddleware',
|
||||||
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
||||||
'tfjm.middlewares.SessionMiddleware',
|
'tfjm.middlewares.SessionMiddleware',
|
||||||
|
'tfjm.middlewares.FetchMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'tfjm.urls'
|
ROOT_URLCONF = 'tfjm.urls'
|
||||||
|
|
|
@ -259,7 +259,7 @@
|
||||||
if (!modalBody.innerHTML.trim()) {
|
if (!modalBody.innerHTML.trim()) {
|
||||||
if (url instanceof Function) url = url()
|
if (url instanceof Function) url = url()
|
||||||
|
|
||||||
fetch(url)
|
fetch(url, {headers: {'CONTENT-ONLY': '1'}})
|
||||||
.then(resp => resp.text())
|
.then(resp => resp.text())
|
||||||
.then(resp => new DOMParser().parseFromString(resp, 'text/html'))
|
.then(resp => new DOMParser().parseFromString(resp, 'text/html'))
|
||||||
.then(res => modalBody.innerHTML = res.getElementById(content_id).outerHTML)
|
.then(res => modalBody.innerHTML = res.getElementById(content_id).outerHTML)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{% block content %}{% endblock content %}
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.html" %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends 'base.html' %}
|
{% extends request.content_only|yesno:"empty.html,base.html" %}
|
||||||
|
|
||||||
{% load crispy_forms_filters highlight i18n search_results_tables django_tables2 %}
|
{% load crispy_forms_filters highlight i18n search_results_tables django_tables2 %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue