summaryrefslogtreecommitdiff
path: root/apps/photos/retriever.py
diff options
context:
space:
mode:
Diffstat (limited to 'apps/photos/retriever.py')
-rw-r--r--apps/photos/retriever.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/apps/photos/retriever.py b/apps/photos/retriever.py
index 64889ba..8d7b07c 100644
--- a/apps/photos/retriever.py
+++ b/apps/photos/retriever.py
@@ -64,7 +64,7 @@ def sync_flickr_photos(*args, **kwargs):
taglist.append(tag['raw'])
exif = exif_handler(client.flickr_photos_getExif(user_id=API_KEY, photo_id=safestr(info['id'])))
- photo = Photo.objects.create(
+ photo, created = Photo.objects.get_or_create(
title = info['title'],
flickr_id = info['id'],
flickr_owner = info['owner'],
@@ -86,8 +86,10 @@ def sync_flickr_photos(*args, **kwargs):
lon = float(info['longitude']),
region = region,
location = location,
- tags = ", ".join(t for t in taglist)
)
+ if created:
+ for t in taglist:
+ photo.tags.add(t)
#print info['title'], region, location
photo.save()
make_local_copies(photo)
@@ -130,7 +132,10 @@ def get_geo(lat,lon):
location = Location.objects.get(geometry__contains=pnt_wkt)
except Location.DoesNotExist:
location = None
- region = Region.objects.get(geometry__contains=pnt_wkt)
+ try:
+ region = Region.objects.get(geometry__contains=pnt_wkt)
+ except Region.DoesNotExist:
+ region = None
return location, region