]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
Merge branch 'master' of /home/brettp/sommitrealweird
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Sun, 8 Nov 2009 19:42:02 +0000 (19:42 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Sun, 8 Nov 2009 19:42:02 +0000 (19:42 +0000)
scripts/update-photos.py [new file with mode: 0644]
sommitrealweird/photo/admin.py
sommitrealweird/settings.py

diff --git a/scripts/update-photos.py b/scripts/update-photos.py
new file mode 100644 (file)
index 0000000..78bef0b
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+
+import sys
+import os
+
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+
+sys.path.append("../sommitrealweird")
+
+from django.conf import settings
+from photo.models import Album, Photo
+
+def usage():
+    print "You must specify a photo album to update."
+
+# check if we have an argument for the album name
+if len(sys.argv) < 2:
+    usage()
+    sys.exit(2)
+
+alb_slug = sys.argv[1]
+
+# check if the album exists...
+if not Album.objects.filter(slug__exact=alb_slug):
+    # there's no album, can't update.
+    print "Can't find album '%s'" %(alb_slug)
+
+album = Album.objects.get(slug__exact=alb_slug)
+
+# loop through photos, carefully
+root, dirs, files = os.walk("../media/photos/%s" %(alb_slug)).next()
+for file in files:
+    if not Photo.objects.filter(image__exact="photos/%s/%s" %(alb_slug, file)):
+        if file[-4:] == ".jpg":
+            photo = Photo()
+            photo.album = album
+            photo.image = "photos/%s/%s" %(alb_slug, file)
+            photo.save()
+
index 90c48b217b4937dac9d3e782f9709c3b2b55b5a7..d45b4c115d71ca1bff71dc57ccadf29ca6b56ae1 100644 (file)
@@ -3,6 +3,10 @@ from django.contrib import admin
 
 class AlbumAdmin(admin.ModelAdmin):
     prepopulated_fields = { "slug": ("name",) }
+    ordering = ( 'name', )
+
+class PhotoAdmin(admin.PhotoAdmin):
+    ordering = ( 'image', )
 
 admin.site.register(Album, AlbumAdmin)
-admin.site.register(Photo)
+admin.site.register(Photo, PhotoAdmin)
index 73ea9ce99678f0d96fd2d303cef75b3cd122180a..46627e7d6f741c9184319c3eb0dda29efe79fae9 100644 (file)
@@ -91,6 +91,7 @@ APPEND_SLASH=False
 
 RESTRUCTUREDTEXT_FILTER_SETTINGS = {
     'initial_header_level': 2,
+    'doctitle_xform': False,
 }
 
 BPCMS_ROOT = '/'