Add signaler app to intercept management commands and emit signals
This commit is contained in:
1
apps/signaler/__init__.py
Normal file
1
apps/signaler/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
0
apps/signaler/management/__init__.py
Normal file
0
apps/signaler/management/__init__.py
Normal file
0
apps/signaler/management/commands/__init__.py
Normal file
0
apps/signaler/management/commands/__init__.py
Normal file
13
apps/signaler/management/commands/collectstatic.py
Normal file
13
apps/signaler/management/commands/collectstatic.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.contrib.staticfiles.management.commands import collectstatic
|
||||
|
||||
from signaler.signals import pre_collectstatic
|
||||
|
||||
|
||||
class Command(collectstatic.Command):
|
||||
"""
|
||||
Wrapper for the collectstatic command
|
||||
"""
|
||||
|
||||
def handle_noargs(self, *args, **kwargs):
|
||||
pre_collectstatic.send(sender=self)
|
||||
super(Command, self).handle_noargs(*args, **kwargs)
|
||||
3
apps/signaler/models.py
Normal file
3
apps/signaler/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
3
apps/signaler/signals.py
Normal file
3
apps/signaler/signals.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.dispatch import Signal
|
||||
|
||||
pre_collectstatic = Signal()
|
||||
11
settings.py
11
settings.py
@@ -174,6 +174,8 @@ INSTALLED_APPS = (
|
||||
'rest_api',
|
||||
'document_signatures',
|
||||
|
||||
# Has to be last so the other apps can register it's signals
|
||||
'signaler',
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
@@ -328,19 +330,22 @@ if DEVELOPMENT:
|
||||
import rosetta
|
||||
INSTALLED_APPS += ('rosetta',)
|
||||
except ImportError:
|
||||
sys.stderr.write('DEBUG: rosetta is not installed\n')
|
||||
pass
|
||||
#sys.stderr.write('DEBUG: rosetta is not installed\n')
|
||||
|
||||
try:
|
||||
import django_extensions
|
||||
INSTALLED_APPS += ('django_extensions',)
|
||||
except ImportError:
|
||||
sys.stderr.write('DEBUG: django_extensions is not installed\n')
|
||||
pass
|
||||
#sys.stderr.write('DEBUG: django_extensions is not installed\n')
|
||||
|
||||
try:
|
||||
import debug_toolbar
|
||||
#INSTALLED_APPS +=('debug_toolbar',)
|
||||
except ImportError:
|
||||
sys.stderr.write('DEBUG: debug_toolbar is not installed\n')
|
||||
pass
|
||||
#sys.stderr.write('DEBUG: debug_toolbar is not installed\n')
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.debug',)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user