Example #1
0
 def _log(self, message):
     if message:
         revision.start()
         revision.user = self.user
         revision.comment = "%s." % message
         revision.add(self.object)
         revision.end()
         return message
     return ""
# add extra libs to the python sys path
sys.path.extend(libs)
path = os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(path)

os.environ['RAPIDSMS_INI'] = os.path.join(path, "local.ini")
os.environ['DJANGO_SETTINGS_MODULE'] = 'rapidsms.webui.settings'
# import manager now that the path is correct
from rapidsms import manager
###
### END - SETUP RAPIDSMS ENVIRONMENT
###


from reversion import revision
from childcount.models import Clinic, CHW
from locations.models import Location

revision.start()

for chw in CHW.objects.filter(location__name__icontains='.H.C'):
    try:
        chw.clinic = Clinic.objects.get(location_ptr=chw.location)
        chw.save()
    except Clinic.DoesNotExist:
        pass

revision.end()