diff --git a/apps/participation/templates/participation/create_team.html b/apps/participation/templates/participation/create_team.html index 1c93537..f45e1d9 100644 --- a/apps/participation/templates/participation/create_team.html +++ b/apps/participation/templates/participation/create_team.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/participation/templates/participation/join_team.html b/apps/participation/templates/participation/join_team.html index 9beef23..53c1ab9 100644 --- a/apps/participation/templates/participation/join_team.html +++ b/apps/participation/templates/participation/join_team.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/participation/templates/participation/note_form.html b/apps/participation/templates/participation/note_form.html index 78231ff..40b9090 100644 --- a/apps/participation/templates/participation/note_form.html +++ b/apps/participation/templates/participation/note_form.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/participation/templates/participation/passage_form.html b/apps/participation/templates/participation/passage_form.html index daabd59..4a70707 100644 --- a/apps/participation/templates/participation/passage_form.html +++ b/apps/participation/templates/participation/passage_form.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/participation/templates/participation/pool_form.html b/apps/participation/templates/participation/pool_form.html index ae9bb21..1a3dda4 100644 --- a/apps/participation/templates/participation/pool_form.html +++ b/apps/participation/templates/participation/pool_form.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/participation/templates/participation/team_leave.html b/apps/participation/templates/participation/team_leave.html index 72d3db9..ae41b15 100644 --- a/apps/participation/templates/participation/team_leave.html +++ b/apps/participation/templates/participation/team_leave.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load i18n %} diff --git a/apps/participation/templates/participation/team_list.html b/apps/participation/templates/participation/team_list.html index 71d0b98..17006a5 100644 --- a/apps/participation/templates/participation/team_list.html +++ b/apps/participation/templates/participation/team_list.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load django_tables2 i18n %} diff --git a/apps/participation/templates/participation/tournament_form.html b/apps/participation/templates/participation/tournament_form.html index e436656..cde426d 100644 --- a/apps/participation/templates/participation/tournament_form.html +++ b/apps/participation/templates/participation/tournament_form.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/participation/templates/participation/tournament_list.html b/apps/participation/templates/participation/tournament_list.html index a3c3b6b..3af9359 100644 --- a/apps/participation/templates/participation/tournament_list.html +++ b/apps/participation/templates/participation/tournament_list.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load django_tables2 i18n %} diff --git a/apps/participation/templates/participation/update_team.html b/apps/participation/templates/participation/update_team.html index 28f0d28..e053da8 100644 --- a/apps/participation/templates/participation/update_team.html +++ b/apps/participation/templates/participation/update_team.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/participation/templates/participation/upload_motivation_letter.html b/apps/participation/templates/participation/upload_motivation_letter.html index 90ccd06..b6d69d1 100644 --- a/apps/participation/templates/participation/upload_motivation_letter.html +++ b/apps/participation/templates/participation/upload_motivation_letter.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load i18n static crispy_forms_filters %} diff --git a/apps/participation/templates/participation/upload_notes.html b/apps/participation/templates/participation/upload_notes.html index 2e88851..c11ff4a 100644 --- a/apps/participation/templates/participation/upload_notes.html +++ b/apps/participation/templates/participation/upload_notes.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_tags %} {% load i18n %} diff --git a/apps/participation/templates/participation/upload_solution.html b/apps/participation/templates/participation/upload_solution.html index 378585f..d9c7c64 100644 --- a/apps/participation/templates/participation/upload_solution.html +++ b/apps/participation/templates/participation/upload_solution.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/participation/templates/participation/upload_synthesis.html b/apps/participation/templates/participation/upload_synthesis.html index f4c22d4..30be880 100644 --- a/apps/participation/templates/participation/upload_synthesis.html +++ b/apps/participation/templates/participation/upload_synthesis.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n static %} diff --git a/apps/registration/templates/registration/payment_form.html b/apps/registration/templates/registration/payment_form.html index 2af5bd6..3aa526b 100644 --- a/apps/registration/templates/registration/payment_form.html +++ b/apps/registration/templates/registration/payment_form.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/registration/templates/registration/update_user.html b/apps/registration/templates/registration/update_user.html index 05533b8..3f71a4e 100644 --- a/apps/registration/templates/registration/update_user.html +++ b/apps/registration/templates/registration/update_user.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load crispy_forms_filters i18n %} diff --git a/apps/registration/templates/registration/upload_parental_authorization.html b/apps/registration/templates/registration/upload_parental_authorization.html index 16cd910..117e1fc 100644 --- a/apps/registration/templates/registration/upload_parental_authorization.html +++ b/apps/registration/templates/registration/upload_parental_authorization.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load i18n static crispy_forms_filters %} diff --git a/apps/registration/templates/registration/upload_photo_authorization.html b/apps/registration/templates/registration/upload_photo_authorization.html index fdf1591..9b6109c 100644 --- a/apps/registration/templates/registration/upload_photo_authorization.html +++ b/apps/registration/templates/registration/upload_photo_authorization.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load i18n static crispy_forms_filters %} diff --git a/apps/registration/templates/registration/upload_vaccine_sheet.html b/apps/registration/templates/registration/upload_vaccine_sheet.html index e97ad94..5043968 100644 --- a/apps/registration/templates/registration/upload_vaccine_sheet.html +++ b/apps/registration/templates/registration/upload_vaccine_sheet.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% load i18n static crispy_forms_filters %} diff --git a/tfjm/middlewares.py b/tfjm/middlewares.py index 1a57201..0cb5ac7 100644 --- a/tfjm/middlewares.py +++ b/tfjm/middlewares.py @@ -52,3 +52,16 @@ class SessionMiddleware(object): _set_current_user_and_ip(None, None, None) 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) diff --git a/tfjm/settings.py b/tfjm/settings.py index a3f953d..aa09dce 100644 --- a/tfjm/settings.py +++ b/tfjm/settings.py @@ -87,6 +87,7 @@ MIDDLEWARE = [ 'django.middleware.locale.LocaleMiddleware', 'django.contrib.sites.middleware.CurrentSiteMiddleware', 'tfjm.middlewares.SessionMiddleware', + 'tfjm.middlewares.FetchMiddleware', ] ROOT_URLCONF = 'tfjm.urls' diff --git a/tfjm/templates/base.html b/tfjm/templates/base.html index edc2acc..d12045b 100644 --- a/tfjm/templates/base.html +++ b/tfjm/templates/base.html @@ -259,7 +259,7 @@ if (!modalBody.innerHTML.trim()) { if (url instanceof Function) url = url() - fetch(url) + fetch(url, {headers: {'CONTENT-ONLY': '1'}}) .then(resp => resp.text()) .then(resp => new DOMParser().parseFromString(resp, 'text/html')) .then(res => modalBody.innerHTML = res.getElementById(content_id).outerHTML) diff --git a/tfjm/templates/empty.html b/tfjm/templates/empty.html new file mode 100644 index 0000000..9b5178d --- /dev/null +++ b/tfjm/templates/empty.html @@ -0,0 +1 @@ +{% block content %}{% endblock content %} diff --git a/tfjm/templates/registration/login.html b/tfjm/templates/registration/login.html index db50a06..744a38d 100644 --- a/tfjm/templates/registration/login.html +++ b/tfjm/templates/registration/login.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends request.content_only|yesno:"empty.html,base.html" %} {% comment %} SPDX-License-Identifier: GPL-2.0-or-later {% endcomment %} diff --git a/tfjm/templates/search/search.html b/tfjm/templates/search/search.html index d3f41f1..75ad266 100644 --- a/tfjm/templates/search/search.html +++ b/tfjm/templates/search/search.html @@ -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 %}