|
@@ -10,6 +10,7 @@ import re
|
|
|
import sys
|
|
|
from datetime import date, timedelta
|
|
|
from contextlib import contextmanager
|
|
|
+from functools import wraps
|
|
|
|
|
|
from django.utils import translation
|
|
|
from django.core.mail import EmailMultiAlternatives
|
|
@@ -149,6 +150,18 @@ def respects_language(fun):
|
|
|
return fun(*args, **kwargs)
|
|
|
return _inner
|
|
|
|
|
|
+
|
|
|
+def disable_for_loaddata(signal_handler):
|
|
|
+ """Decorator for post_save events that disables them when loading
|
|
|
+ data from fixtures."""
|
|
|
+ @wraps(signal_handler)
|
|
|
+ def wrapper(*args, **kwargs):
|
|
|
+ if kwargs['raw']:
|
|
|
+ return
|
|
|
+ signal_handler(*args, **kwargs)
|
|
|
+ return wrapper
|
|
|
+
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
# ldap_hash expects an unicode string
|
|
|
print(ldap_hash(sys.argv[1].decode("utf-8")))
|