From d83b8dc03e2d163cd202d08b0d0a0b2749497e8f Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 23 Apr 2012 17:54:17 +0530 Subject: [PATCH] add import script for image folders --- urbstudio/urb/imports.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 urbstudio/urb/imports.py diff --git a/urbstudio/urb/imports.py b/urbstudio/urb/imports.py new file mode 100644 index 0000000..4680260 --- /dev/null +++ b/urbstudio/urb/imports.py @@ -0,0 +1,22 @@ +from models import * +from django.core.files import File +from glob import glob + +def importFile(filePath, project): + f = File(open(filePath)) + pi = ProjectImage() + pi.project = project + pi.image = f + pi.caption = '' + pi.save() + print "%s saved" % filePath + return + + +def doDir(dirpath, project): + for f in glob("%s/*" % dirpath): + importFile(f, project) + print "all done" + return + +