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
html_head signal not fired for non-event pages in backend #2988
Comments
Indeed one of them is declared to be a plain Signal and one to be an EventPluginSignal. I can't recall why that happened but I'm also not sure how careful we need to be with changing this for compatibility |
Oh, you're right. I hadn't even noticed that since (at this point) I don't care about the event. I agree that sending In the mean time I do have a workaround, but it's not fit for general consumption. I'm basing this on the fact that Danger: Don't do this unless you're absolutely sure that you're the only plugin using this trickIn signals: @receiver(html_head)
def my_html_head(sender, request=None, **kwargs):
return "bla"
def inject_head(request):
# This hack overrides `html_head` in backend *only* if not in event context
from django.urls import get_script_prefix
if not request.path.startswith(get_script_prefix() + 'control') or not hasattr(request, 'user'):
return {}
if request.user.is_authenticated and not hasattr(request, 'event'):
return {"html_head": my_html_head(None, request)}
return {} and in from django.conf import settings
settings.TEMPLATES[0]['OPTIONS']['context_processors'].append('...signals.inject_head') |
Yeah, the underlying conceptional issue is that pretix historically only has a concept of plugins on event level and every plugin that operates on organizer and global level is basically some level of hack or workaround. We need to fix that at some point, but it's unclear how to do it without creating a hard-to-understand user experience. |
Problem and impact
I'm developing a plugin and want to include additional scripts and styles in the backend, on all pages. The documentation lists two signal with virtually identical description:
<head>
, andThe issue is here
pretix/src/pretix/control/context.py
Line 83 in eeb6e11
html_page_start
signal is implemented inpretix/src/pretix/control/templates/pretixcontrol/base.html
Line 379 in eeb6e11
event
restriction.Expected behaviour
The wording "every page in the backend" in the documentation particularly suggests that these two signals would equally apply to, well, every page in the backend.
(Alternatively the documentation needs to highlight the difference. :)
Steps to reproduce
pretix.control.signals.html_head
andpretix.control.signals.html_page_start
. Let the plugin return some dummy content./control/
: Thehtml_page_start
signal is fired and the content visible at the start of the main content./control/event/...
: Thehtml_page_start
andhtml_ head
signals are fired. Content is visible both in page main and in<head>
.Screenshots
No response
Link
No response
Browser (software, desktop or mobile?) and version
No response
Operating system, dependency versions
No response
Version
No response
The text was updated successfully, but these errors were encountered: