6 os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
8 sys.path.append("../sommitrealweird")
10 from django.conf import settings
11 from photo.models import Album, Photo
14 print "You must specify a photo album to update."
16 # check if we have an argument for the album name
21 alb_slug = sys.argv[1]
23 # check if the album exists...
24 if not Album.objects.filter(slug__exact=alb_slug):
25 # there's no album, can't update.
26 print "Can't find album '%s'" %(alb_slug)
28 album = Album.objects.get(slug__exact=alb_slug)
30 # loop through photos, carefully
31 root, dirs, files = os.walk("../media/photos/%s" %(alb_slug)).next()
33 if not Photo.objects.filter(image__exact="photos/%s/%s" %(alb_slug, file)):
34 if file[-4:] == ".jpg":
37 photo.image = "photos/%s/%s" %(alb_slug, file)