add --nomodelpolicy option for loading fixtures
diff --git a/planetstack/manage.py b/planetstack/manage.py
index c12bf36..ce14cdb 100644
--- a/planetstack/manage.py
+++ b/planetstack/manage.py
@@ -7,4 +7,9 @@
from django.core.management import execute_from_command_line
+ if "--nomodelpolicy" in sys.argv:
+ import model_policy
+ model_policy.EnableModelPolicy(False)
+ sys.argv.remove("--nomodelpolicy")
+
execute_from_command_line(sys.argv)
diff --git a/planetstack/model_policy.py b/planetstack/model_policy.py
index ba0cb99..9224c50 100644
--- a/planetstack/model_policy.py
+++ b/planetstack/model_policy.py
@@ -4,10 +4,19 @@
from core.models import *
import model_policies
+modelPolicyEnabled = True
+
+def EnableModelPolicy(x):
+ global modelPolicyEnabled
+ modelPolicyEnabled = x
+
@receiver(post_save)
def post_save_handler(sender, instance, **kwargs):
sender_name = sender.__name__
policy_name = 'model_policy_%s'%sender_name
+
+ if not modelPolicyEnabled:
+ return
if (not kwargs['update_fields']):
try:
diff --git a/planetstack/scripts/opencloud b/planetstack/scripts/opencloud
index b307e66..7811483 100755
--- a/planetstack/scripts/opencloud
+++ b/planetstack/scripts/opencloud
@@ -48,7 +48,7 @@
python /opt/planetstack/manage.py syncdb --noinput
if [[ $DJANGO_17 ]]; then
echo "Loading initial data from fixture..."
- python /opt/planetstack/manage.py loaddata /opt/planetstack/core/fixtures/initial_data.json
+ python /opt/planetstack/manage.py --nomodelpolicy loaddata /opt/planetstack/core/fixtures/initial_data.json
fi
}
function evolvedb {