Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ add optional CSP nonce to allow inline script compliance #171

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions advanced_filters/templates/admin/advanced_filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ <h1>{% trans "Create advanced filter" %}:</h1>
<br />
<input method="POST" type="submit" value="{% trans "Save" %}">
<input method="POST" name="_save_goto" type="submit" value="{% trans "Save & Filter Now!" %}">
<a href="#" class="grp-button" style="margin:auto" onclick="$.magnificPopup.close();">{% trans "Cancel" %}</a>
<a href="#" id="advanced-filters-close-btn" class="grp-button" style="margin:auto">{% trans "Cancel" %}</a>
</form>

{{ advanced_filters.media.js }}

<script type="text/javascript" charset="utf-8">
<script type="text/javascript" charset="utf-8" nonce="{{request.csp_nonce}}">
document.getElementById("advanced-filters-close-btn").addEventListener('click', ()=>$.magnificPopup.close());
// using django's original jquery, initial formset
var FORM_MODEL = undefined;
var MODEL_LABEL = '{{ app_label }}.{{ opts.model_name }}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h1>{% trans "Change advanced filter" %}:</h1>
{% prepopulated_fields_js %}
{{ adminform.media.js }}

<script type="text/javascript" charset="utf-8">
<script type="text/javascript" charset="utf-8" nonce="{{request.csp_nonce}}">
// using django's original jquery, initial formset
var FORM_MODEL = '{% if adminform %}{{ adminform.form.instance.model }}{% endif %}';
var MODEL_LABEL = '{{ app_label }}.{{ opts.model_name }}';
Expand Down
2 changes: 1 addition & 1 deletion advanced_filters/templates/admin/common_js_init.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n static %}

<script type="text/javascript">
<script type="text/javascript" nonce="{{request.csp_nonce}}">
// globals
var _af_handlers = window._af_handlers || null;
var ADVANCED_FILTER_CHOICES_LOOKUP_URL = "{% url 'afilters_get_field_choices' %}";
Expand Down