add rebuild tool
diff --git a/xos/core/models/xosmodel.py b/xos/core/models/xosmodel.py
index ad021d3..c632f08 100644
--- a/xos/core/models/xosmodel.py
+++ b/xos/core/models/xosmodel.py
@@ -19,3 +19,11 @@
# def can_update(self, user):
# return user.can_update_site(self.site, allow=['tech'])
+ def rebuild(self):
+ for service_controller in self.service_controllers.all():
+ for scr in service_controller.service_controller_resources.all():
+ scr.save()
+ service_controller.save()
+ self.save()
+
+
diff --git a/xos/tools/rebuild.py b/xos/tools/rebuild.py
new file mode 100755
index 0000000..dc2c482
--- /dev/null
+++ b/xos/tools/rebuild.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+import os
+import sys
+sys.path.append("/opt/xos")
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
+import django
+from core.models import XOS
+django.setup()
+
+xoses = XOS.objects.all()
+if not xoses:
+ print "There is no XOS model"
+
+for xos in xoses:
+ xos.rebuild()
+