Start python-level API

This commit is contained in:
Raphael Michel
2021-11-20 12:08:47 +01:00
committed by Raphael Michel
parent 202f34ad5b
commit c10a8575ad
9 changed files with 72 additions and 8 deletions
+1 -2
View File
@@ -2527,8 +2527,7 @@ Your {organizer} team"""))
'default': LazyI18nString.from_gettext(gettext_noop(
'We use cookies and similar technologies to gather data that allows us to improve this website and our '
'offerings. If you do not agree, we will only use cookies if they are essential to providing the services '
'this website offers. This includes cookies used to store your cart and personal settings, cookies used for '
'payment processing, as well as cookies required for technical or security reasons.'
'this website offers.'
)),
'type': LazyI18nString,
'serializer_class': I18nField,
+3
View File
@@ -45,6 +45,7 @@ from pretix.base.settings import GlobalSettingsObject
from pretix.helpers.i18n import (
get_javascript_format_without_seconds, get_moment_locale,
)
from .cookies import get_cookie_providers
from ..base.i18n import get_language_without_region
from .signals import (
@@ -140,6 +141,8 @@ def _default_context(request):
ctx['event'] = request.event
ctx['languages'] = [get_language_info(code) for code in request.event.settings.locales]
ctx['cookie_providers'] = get_cookie_providers(request.event, request)
if request.resolver_match:
ctx['cart_namespace'] = request.resolver_match.kwargs.get('cart_namespace', '')
elif hasattr(request, 'organizer'):
+10
View File
@@ -401,3 +401,13 @@ This signal is sent out when the description of an item or variation is rendered
additional text to the description. You are passed the ``item`` and ``variation`` and expected to return
HTML.
"""
register_cookie_providers = EventPluginSignal()
"""
Arguments: ``request``
This signal is sent out to get all cookie providers that could set a cookie on this page, regardless of
consent state. Receivers should return a list of pretix.presale.cookies.CookieProvider objects.
As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
"""
@@ -172,7 +172,7 @@
{% if request.event.settings.privacy_url %}
<li><a href="{% safelink request.event.settings.privacy_url %}" target="_blank" rel="noopener">{% trans "Privacy policy" %}</a></li>
{% endif %}
{% if request.event.settings.cookie_consent %}
{% if request.event.settings.cookie_consent and cookie_providers %}
<li><a href="#" id="cookie-consent-reopen">{% trans "Cookie settings" %}</a></li>
{% endif %}
{% if request.event.settings.imprint_url %}
@@ -17,7 +17,7 @@
</div>
</div>
</div>
{% if request.organizer %}
{% if request.organizer and cookie_providers %}
<script type="text/plain" id="cookie-consent-storage-key">cookie-consent-{{ request.organizer.slug }}</script>
<div id="cookie-consent-modal" hidden aria-live="polite">
<div class="modal-card">
@@ -32,10 +32,33 @@
{{ sh.settings.cookie_consent_dialog_text_secondary|rich_text }}
</div>
{% endif %}
<details id="cookie-consent-details">
<summary>
<span class="fa fa-fw chevron"></span>
{% trans "Detail settings" %}
</summary>
<div class="checkbox">
<label>
<input type="checkbox" name="functional" disabled checked="">
{% trans "Functional cookies" %}<br>
<span class="text-muted">{% trans "Used e.g. for shopping cart, login, payment, and security purposes" %}</span>
</label>
</div>
{% for cp in cookie_providers %}
<div class="checkbox">
<label>
<input type="checkbox" name="{{ cp.identifier }}">
{{ cp.provider_name }}<br>
</label>
</div>
{% endfor %}
</details>
<div class="row">
<div class="col-xs-12 col-md-6">
<p>
<button type="button" class="btn btn-lg btn-block btn-primary" id="cookie-consent-button-no">
<button type="button" class="btn btn-lg btn-block btn-primary" id="cookie-consent-button-no"
data-summary-text="{{ sh.settings.cookie_consent_dialog_button_no }}"
data-detail-text="{% trans "Save selection" %}">
{{ sh.settings.cookie_consent_dialog_button_no }}
</button>
</p>
@@ -58,4 +81,4 @@
</div>
</div>
</div>
{% endif %}
{% endif %}
@@ -90,7 +90,7 @@
{% if not request.event and request.organizer.settings.privacy_url %}
<li><a href="{% safelink request.organizer.settings.privacy_url %}" target="_blank" rel="noopener">{% trans "Privacy policy" %}</a></li>
{% endif %}
{% if not request.event and request.organizer.settings.cookie_consent %}
{% if not request.event and request.organizer.settings.cookie_consent and cookie_providers %}
<li><a href="#" id="cookie-consent-reopen">{% trans "Cookie settings" %}</a></li>
{% endif %}
{% if not request.event and request.organizer.settings.imprint_url %}
@@ -31,9 +31,20 @@ $(function () {
}
$("#cookie-consent-modal").hide()
})
$("#cookie-consent-details").on("toggle", function (e) {
if ($("#cookie-consent-details").attr("open")) {
$("#cookie-consent-button-no").text(
$("#cookie-consent-button-no").attr("data-detail-text")
)
} else {
$("#cookie-consent-button-no").text(
$("#cookie-consent-button-no").attr("data-summary-text")
)
}
})
$("#cookie-consent-reopen").on("click", function (e) {
$("#cookie-consent-modal").show()
e.preventDefault()
return true
})
});
});
@@ -132,6 +132,15 @@ a.btn, button.btn {
}
}
details {
summary .chevron::before {
content: $fa-var-caret-right;
}
&[open] .chevron::before {
content: $fa-var-caret-down;
}
}
@media(max-width: $screen-xs-max) {
.nameparts-form-group {
@@ -187,6 +187,15 @@ body.loading .container {
.modal-card-content {
margin-left: 0;
}
details {
& > summary {
list-style: inherit;
}
& > summary::-webkit-details-marker {
display: inherit;
}
margin-bottom: 10px;
}
}
}
@media (max-width: 700px) {