forked from CGM_Public/pretix_original
Fix EventPluginSignal to recognize Django apps with custom app labels
This commit is contained in:
@@ -8,6 +8,15 @@ from django.dispatch.dispatcher import NO_RECEIVERS
|
|||||||
|
|
||||||
from .models import Event
|
from .models import Event
|
||||||
|
|
||||||
|
app_cache = {}
|
||||||
|
|
||||||
|
|
||||||
|
def _populate_app_cache():
|
||||||
|
global app_cache
|
||||||
|
apps.check_apps_ready()
|
||||||
|
for ac in apps.app_configs.values():
|
||||||
|
app_cache[ac.name] = ac
|
||||||
|
|
||||||
|
|
||||||
class EventPluginSignal(django.dispatch.Signal):
|
class EventPluginSignal(django.dispatch.Signal):
|
||||||
"""
|
"""
|
||||||
@@ -30,18 +39,16 @@ class EventPluginSignal(django.dispatch.Signal):
|
|||||||
if not self.receivers or self.sender_receivers_cache.get(sender) is NO_RECEIVERS:
|
if not self.receivers or self.sender_receivers_cache.get(sender) is NO_RECEIVERS:
|
||||||
return responses
|
return responses
|
||||||
|
|
||||||
|
if not app_cache:
|
||||||
|
_populate_app_cache()
|
||||||
|
|
||||||
for receiver in self._live_receivers(sender):
|
for receiver in self._live_receivers(sender):
|
||||||
# Find the Django application this belongs to
|
# Find the Django application this belongs to
|
||||||
searchpath = receiver.__module__
|
searchpath = receiver.__module__
|
||||||
app = None
|
|
||||||
mod = None
|
mod = None
|
||||||
while True:
|
while True:
|
||||||
try:
|
app = app_cache.get(searchpath)
|
||||||
if apps.is_installed(searchpath):
|
if "." not in searchpath or app:
|
||||||
app = apps.get_app_config(searchpath.split(".")[-1])
|
|
||||||
except LookupError:
|
|
||||||
pass
|
|
||||||
if "." not in searchpath:
|
|
||||||
break
|
break
|
||||||
searchpath, mod = searchpath.rsplit(".", 1)
|
searchpath, mod = searchpath.rsplit(".", 1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user