summaryrefslogtreecommitdiff
path: root/apps/photos
diff options
context:
space:
mode:
Diffstat (limited to 'apps/photos')
-rw-r--r--apps/photos/admin.py2
-rw-r--r--apps/photos/models.py39
-rw-r--r--apps/photos/urls.py1
-rw-r--r--apps/photos/utils.py15
-rw-r--r--apps/photos/views.py9
5 files changed, 57 insertions, 9 deletions
diff --git a/apps/photos/admin.py b/apps/photos/admin.py
index 0a6014f..15d308e 100644
--- a/apps/photos/admin.py
+++ b/apps/photos/admin.py
@@ -12,7 +12,7 @@ class PhotoAdmin(OSMGeoAdmin):
list_filter = ('pub_date',)
fieldsets = (
(None, {'fields': (('title', 'description'),'pub_date', 'tags',('lat','lon'))}),
- ('Exif Data', {'fields': ('exif_aperture','exif_shutter','exif_iso','exif_lens','exif_date','exif_make','exif_model'), 'classes': ('collapse')}),
+ ('Exif Data', {'fields': ('exif_aperture','exif_exposure','exif_iso','exif_focal_length','exif_lens','exif_date','exif_make','exif_model'), 'classes': ('collapse')}),
('Flickr Data', {'fields': ('flickr_id','flickr_owner','flickr_farm','flickr_server','flickr_secret','flickr_originalsecret'), 'classes': ('collapse')}),
)
extra_js = [GMAP.api_url + GMAP.key]
diff --git a/apps/photos/models.py b/apps/photos/models.py
index ee01bcf..05b759e 100644
--- a/apps/photos/models.py
+++ b/apps/photos/models.py
@@ -1,10 +1,12 @@
import datetime
+import Image
from django.contrib.gis.db import models
from django.contrib.syndication.feeds import Feed
from django.contrib.sitemaps import Sitemap
from django.utils.encoding import force_unicode
from django.conf import settings
+
from tagging.fields import TagField
from tagging.models import Tag
@@ -18,8 +20,9 @@ class Photo(models.Model):
exif_aperture = models.CharField(max_length=50, blank=True, null=True)
exif_make = models.CharField(max_length=50, blank=True, null=True)
exif_model = models.CharField(max_length=50, blank=True, null=True)
- exif_shutter = models.CharField(max_length=50, blank=True, null=True)
+ exif_exposure = models.CharField(max_length=50, blank=True, null=True)
exif_iso = models.CharField(max_length=50, blank=True, null=True)
+ exif_focal_length = models.CharField(max_length=50, blank=True, null=True)
exif_lens = models.CharField(max_length=50, blank=True, null=True)
exif_date = models.DateTimeField()
"""Flickr Specific Stuff"""
@@ -33,7 +36,10 @@ class Photo(models.Model):
lat = models.FloatField('Latitude',help_text="Latitude of centerpoint",null=True)
location = models.ForeignKey(Location, null=True)
region = models.ForeignKey(Region, null=True)
-
+ slideshowimage_width = models.CharField(max_length=4, blank=True, null=True)
+ slideshowimage_height = models.CharField(max_length=4, blank=True, null=True)
+ slideshowimage_margintop = models.CharField(max_length=4, blank=True, null=True)
+ slideshowimage_marginleft = models.CharField(max_length=4, blank=True, null=True)
@@ -80,6 +86,35 @@ class Photo(models.Model):
#return self.get_pic_url(size="original")
return "http://farm%s.static.flickr.com/%s/%s_%s_o.jpg" % (self.flickr_farm, self.flickr_server, self.flickr_id, self.flickr_originalsecret)
+ @property
+ def get_height(self):
+ im = Image.open('%sslideshow/%s/%s.jpg' %(settings.IMAGES_ROOT,self.pub_date.strftime("%Y"),self.flickr_id))
+ xsize, ysize = im.size
+ return ysize
+ @property
+ def get_width(self):
+ im = Image.open('%sslideshow/%s/%s.jpg' %(settings.IMAGES_ROOT,self.pub_date.strftime("%Y"),self.flickr_id))
+ xsize, ysize = im.size
+ cal = xsize-120
+ return xsize
+ @property
+ def get_margin_top(self):
+ im = Image.open('%sslideshow/%s/%s.jpg' %(settings.IMAGES_ROOT,self.pub_date.strftime("%Y"),self.flickr_id))
+ xsize, ysize = im.size
+ mtop = 340-(ysize/2)
+ return mtop
+
+ @property
+ def get_margin_left(self):
+ im = Image.open('%sslideshow/%s/%s.jpg' %(settings.IMAGES_ROOT,self.pub_date.strftime("%Y"),self.flickr_id))
+ xsize, ysize = im.size
+ mtop = 500-(xsize/2)
+ return mtop
+
+ @property
+ def flickr_link(self):
+ return '%s%s/' %('http://www.flickr.com/photos/luxagraf/', self.flickr_id)
+
def get_pic_url(self, size='small'):
# small_square=75x75
# thumb=100 on longest side
diff --git a/apps/photos/urls.py b/apps/photos/urls.py
index b53b343..d917d85 100644
--- a/apps/photos/urls.py
+++ b/apps/photos/urls.py
@@ -5,6 +5,7 @@ from django.views.generic.simple import redirect_to
urlpatterns = patterns('',
+ (r'data/(?P<slug>[-\w]+)/$', 'photos.views.photo_json'),
(r'galleries/(?P<slug>[-\w]+)/$', 'photos.views.gallery'),
(r'(?P<page>\d+)/$', 'photos.views.gallery_list'),
(r'(?P<slug>[-\w]+)/$', redirect_to, {'url': '/photos/%(slug)s/1/'}),
diff --git a/apps/photos/utils.py b/apps/photos/utils.py
index b3d8be1..24991b2 100644
--- a/apps/photos/utils.py
+++ b/apps/photos/utils.py
@@ -36,7 +36,7 @@ from photos.models import Photo,PhotoGallery
API_KEY = settings.FLICKR_API_KEY
from APIClients import FlickrClient
-EXIF_PARAMS = {"Aperture":'f/2.8',"Make":'Apple',"Model":'iPhone',"Exposure":'',"ISO Speed":'',"Focal Length":'',"Shutter Speed":'','Date and Time (Original)':'2008:07:03 22:44:25'}
+EXIF_PARAMS = {"Aperture":'f/2.8',"Make":'Apple',"Model":'iPhone',"Exposure":'',"ISO Speed":'',"Focal Length":'',"Shutter Speed":'',"Lens":'','Date and Time (Original)':'2008:07:03 22:44:25'}
def sync_flickr_photos(*args, **kwargs):
cur_page = 1 # Start on the first page of the stream
@@ -63,6 +63,7 @@ def sync_flickr_photos(*args, **kwargs):
tag = dict((k, smart_unicode(t.get(k))) for k in t.keys())
taglist.append(tag['raw'])
exif = exif_handler(client.flickr_photos_getExif(user_id=API_KEY, photo_id=safestr(info['id'])))
+
photo = Photo.objects.create(
title = info['title'],
flickr_id = info['id'],
@@ -76,9 +77,10 @@ def sync_flickr_photos(*args, **kwargs):
exif_aperture = exif['Aperture'],
exif_make = exif['Make'],
exif_model = exif['Model'],
- exif_shutter = exif['Exposure'],
+ exif_exposure = exif['Exposure'],
exif_iso = exif['ISO Speed'],
- exif_lens = exif['Focal Length'],
+ exif_lens = exif['Lens'],
+ exif_focal_length = exif['Focal Length'],
exif_date = flickr_datetime_to_datetime(exif["Date and Time (Original)"].replace(':', '-', 2)),
lat = float(info['latitude']),
lon = float(info['longitude']),
@@ -90,6 +92,7 @@ def sync_flickr_photos(*args, **kwargs):
photo.save()
make_local_copies(photo)
slideshow_image(photo)
+
def exif_handler(data):
converted = {}
@@ -100,7 +103,11 @@ def exif_handler(data):
if not converted.has_key("Aperture"):
converted["Aperture"] = safestr(t.findtext('clean'))
else:
- converted[safestr(e['label'])] = safestr(t.findtext('raw'))
+ if safestr(e['tag']) != 'Exposure':
+ if safestr(e['tag']) == 'ExposureTime':
+ converted[safestr(e['label'])] = safestr(t.findtext('clean'))
+ else:
+ converted[safestr(e['label'])] = safestr(t.findtext('raw'))
except:
pass
for k,v in EXIF_PARAMS.items():
diff --git a/apps/photos/views.py b/apps/photos/views.py
index a81feea..5ccec00 100644
--- a/apps/photos/views.py
+++ b/apps/photos/views.py
@@ -1,7 +1,9 @@
from django.shortcuts import render_to_response,get_object_or_404
from django.template import RequestContext
from django.views.generic.list_detail import object_list
-from django.http import Http404
+from django.http import Http404,HttpResponse
+from django.core import serializers
+
from view_wrapper import luxagraf_render
from tagging.models import Tag,TaggedItem
@@ -25,7 +27,10 @@ def gallery(request,slug):
g = PhotoGallery.objects.get(set_slug=slug)
return luxagraf_render(request,'details/photo_galleries.html', {'object': g,})
-
+def photo_json(request, slug):
+ p = PhotoGallery.objects.filter(set_slug=slug)
+ return HttpResponse(serializers.serialize('json', p), mimetype='application/json')
+
"""
Grabs entries by region or country
"""