summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorluxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f>2010-05-06 22:46:22 +0000
committerluxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f>2010-05-06 22:46:22 +0000
commit940e343ee500a990a2be45578708d3f5d9875263 (patch)
tree4f57ac3a994434582047decfa439d6c50b8a7f68 /apps
parent1b8c0ae77d1ffe6fe9af30e2c1646ea7cd2466c6 (diff)
revamped slideshow with jquery, maps and exif data
Diffstat (limited to 'apps')
-rw-r--r--apps/locations/admin.py7
-rw-r--r--apps/locations/models.py1
-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
-rw-r--r--apps/projects/admin.py204
-rw-r--r--apps/projects/models/__init__.py3
-rw-r--r--apps/projects/views.py8
10 files changed, 273 insertions, 16 deletions
diff --git a/apps/locations/admin.py b/apps/locations/admin.py
index 7fcfee5..77d1bb3 100644
--- a/apps/locations/admin.py
+++ b/apps/locations/admin.py
@@ -136,7 +136,7 @@ admin.site.register(Country,CountryAdmin)
class StateAdmin(OSMGeoAdmin):
# Standard Django Admin Options
- list_display = ('name','slug','country')
+ list_display = ('name','code','slug','country')
prepopulated_fields = {'slug': ('name',)}
search_fields = ('name','country')
ordering = ('name',)
@@ -144,7 +144,7 @@ class StateAdmin(OSMGeoAdmin):
search_fields = ['name',]
list_select_related = True
fieldsets = (
- ('Location', {'fields': ('name','slug','pub_date','country'), 'classes': ('show','extrapretty')}),
+ ('Location', {'fields': ('name','slug','code','pub_date','country'), 'classes': ('show','extrapretty')}),
('Editable Map View', {'fields': ('geometry',), 'classes': ('show', 'wide')}),
)
extra_js = [GMAP.api_url + GMAP.key]
@@ -238,4 +238,5 @@ class LocationAdmin(OSMGeoAdmin):
# Finally, with these options set now register the model
# associating the Options with the actual model
-admin.site.register(Location,LocationAdmin) \ No newline at end of file
+admin.site.register(Location,LocationAdmin)
+
diff --git a/apps/locations/models.py b/apps/locations/models.py
index 57806a2..47c5d65 100644
--- a/apps/locations/models.py
+++ b/apps/locations/models.py
@@ -126,6 +126,7 @@ class State(models.Model):
name = models.CharField(max_length=250, blank=True, null=True,)
country = models.ForeignKey(Country)
slug = models.SlugField()
+ code = models.CharField(max_length=2, null=True, blank=True)
pub_date = models.DateTimeField('Date published',null=True)
geometry = models.MultiPolygonField(srid=4326,null=True)
objects = models.GeoManager()
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
"""
diff --git a/apps/projects/admin.py b/apps/projects/admin.py
index 0ecdeed..e1142f8 100644
--- a/apps/projects/admin.py
+++ b/apps/projects/admin.py
@@ -6,6 +6,7 @@ from django.conf import settings
from projects.models.base import Project
from projects.models.fiveby import FiveBy
+from projects.models.natparks import NationalParkBorders,NationalParkBordersTwo, NationalParks
GMAP = GoogleMap(key=settings.GOOGLE_MAPS_API_KEY)
@@ -109,7 +110,208 @@ class FiveByAdmin(OSMGeoAdmin):
#wms_name = 'OpenLayers WMS'
#debug = False
#widget = OpenLayersWidget
+
+class NationalParkBordersAdmin(OSMGeoAdmin):
+
+ list_display = ('name1','name2','name3','url')
+ search_fields = ['name1',]
+ fieldsets = (
+ ('Project', {'fields': ('name1', 'mpoly','url'), 'classes': ('show','extrapretty','wide')}),
+ )
+
+
+
+ class Media:
+ js = ['/media/admin/custom/model.js']
+ extra_js = [GMAP.api_url + GMAP.key]
+ map_template = 'gis/admin/google.html'
+ #map_template = 'gis/admin/google.html'
+ # Default GeoDjango OpenLayers map options
+ # Uncomment and modify as desired
+ # To learn more about this jargon visit:
+ # www.openlayers.org
+
+ default_lon = -9314310
+ default_lat = 3991847
+ default_zoom = 6
+ #display_wkt = False
+ #display_srid = False
+ #extra_js = []
+ #num_zoom = 18
+ #max_zoom = False
+ #min_zoom = False
+ #units = False
+ #max_resolution = False
+ #max_extent = False
+ #modifiable = True
+ #mouse_position = True
+ #scale_text = True
+ #layerswitcher = True
+ scrollable = False
+ #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
+ map_width = 700
+ map_height = 325
+ #map_srid = 4326
+ #map_template = 'gis/admin/openlayers.html'
+ #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js'
+ #wms_url = 'http://labs.metacarta.com/wms/vmap0'
+ #wms_layer = 'basic'
+ #wms_name = 'OpenLayers WMS'
+ #debug = False
+ #widget = OpenLayersWidget
+
+
+class NationalParkBordersTwoAdmin(OSMGeoAdmin):
+
+ list_display = ('name',)
+ search_fields = ['name',]
+ fieldsets = (
+ ('Project', {'fields': ('name', 'mpoly','mline','mpoint'), 'classes': ('show','extrapretty','wide')}),
+ )
+
+
+
+ class Media:
+ js = ['/media/admin/custom/model.js']
+ extra_js = [GMAP.api_url + GMAP.key]
+ map_template = 'gis/admin/google.html'
+ #map_template = 'gis/admin/google.html'
+ # Default GeoDjango OpenLayers map options
+ # Uncomment and modify as desired
+ # To learn more about this jargon visit:
+ # www.openlayers.org
+
+ default_lon = -9314310
+ default_lat = 3991847
+ default_zoom = 6
+ #display_wkt = False
+ #display_srid = False
+ #extra_js = []
+ #num_zoom = 18
+ #max_zoom = False
+ #min_zoom = False
+ #units = False
+ #max_resolution = False
+ #max_extent = False
+ #modifiable = True
+ #mouse_position = True
+ #scale_text = True
+ #layerswitcher = True
+ scrollable = False
+ #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
+ map_width = 700
+ map_height = 325
+ #map_srid = 4326
+ #map_template = 'gis/admin/openlayers.html'
+ #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js'
+ #wms_url = 'http://labs.metacarta.com/wms/vmap0'
+ #wms_layer = 'basic'
+ #wms_name = 'OpenLayers WMS'
+ #debug = False
+ #widget = OpenLayersWidget
+class NationalParksAdmin(OSMGeoAdmin):
+
+ list_display = ('unit_name','type','state','name','visited', 'size')
+ list_filter = ('state', 'type')
+ search_fields = ['name',]
+ fieldsets = (
+ ('Project', {'fields': ('name', 'tag_line',('state','visited'),'dek','date_visited_begin','date_visited_end','mpoly','image',('post','gallery'),('url','size','fee', 'camping_fee'),'zoom'), 'classes': ('show','extrapretty','wide')}),
+ )
+
+
+
+ class Media:
+ js = ['/media/admin/custom/model.js']
+ extra_js = [GMAP.api_url + GMAP.key]
+ map_template = 'gis/admin/google.html'
+ #map_template = 'gis/admin/google.html'
+ # Default GeoDjango OpenLayers map options
+ # Uncomment and modify as desired
+ # To learn more about this jargon visit:
+ # www.openlayers.org
+
+ default_lon = -9314310
+ default_lat = 3991847
+ default_zoom = 6
+ #display_wkt = False
+ #display_srid = False
+ #extra_js = []
+ #num_zoom = 18
+ #max_zoom = False
+ #min_zoom = False
+ #units = False
+ #max_resolution = False
+ #max_extent = False
+ #modifiable = True
+ #mouse_position = True
+ #scale_text = True
+ #layerswitcher = True
+ scrollable = False
+ #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
+ map_width = 700
+ map_height = 325
+ #map_srid = 4326
+ #map_template = 'gis/admin/openlayers.html'
+ #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js'
+ #wms_url = 'http://labs.metacarta.com/wms/vmap0'
+ #wms_layer = 'basic'
+ #wms_name = 'OpenLayers WMS'
+ #debug = False
+ #widget = OpenLayersWidget
+'''
+class NPEntryAdmin(OSMGeoAdmin):
+
+ list_display = ('title',)
+ search_fields = ['title','park']
+ fieldsets = (
+ ('Project', {'fields': ('title', 'dek', 'park', 'post', ('slug', 'status'),'pub_date','point',), 'classes': ('show','extrapretty','wide')}),
+ )
+
+
+ class Media:
+ js = ['/media/admin/custom/model.js']
+ extra_js = [GMAP.api_url + GMAP.key]
+ map_template = 'gis/admin/google.html'
+ #map_template = 'gis/admin/google.html'
+ # Default GeoDjango OpenLayers map options
+ # Uncomment and modify as desired
+ # To learn more about this jargon visit:
+ # www.openlayers.org
+
+ default_lon = -9314310
+ default_lat = 3991847
+ default_zoom = 6
+ #display_wkt = False
+ #display_srid = False
+ #extra_js = []
+ #num_zoom = 18
+ #max_zoom = False
+ #min_zoom = False
+ #units = False
+ #max_resolution = False
+ #max_extent = False
+ #modifiable = True
+ #mouse_position = True
+ #scale_text = True
+ #layerswitcher = True
+ scrollable = False
+ #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
+ map_width = 700
+ map_height = 325
+ #map_srid = 4326
+ #map_template = 'gis/admin/openlayers.html'
+ #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js'
+ #wms_url = 'http://labs.metacarta.com/wms/vmap0'
+ #wms_layer = 'basic'
+ #wms_name = 'OpenLayers WMS'
+ #debug = False
+ #widget = OpenLayersWidget
+'''
admin.site.register(Project, ProjectAdmin)
-admin.site.register(FiveBy, FiveByAdmin) \ No newline at end of file
+admin.site.register(FiveBy, FiveByAdmin)
+#admin.site.register(NPEntry, NPEntryAdmin)
+admin.site.register(NationalParkBorders, NationalParkBordersAdmin)
+admin.site.register(NationalParkBordersTwo, NationalParkBordersTwoAdmin)
+admin.site.register(NationalParks, NationalParksAdmin) \ No newline at end of file
diff --git a/apps/projects/models/__init__.py b/apps/projects/models/__init__.py
index b29933a..5d544c1 100644
--- a/apps/projects/models/__init__.py
+++ b/apps/projects/models/__init__.py
@@ -1,2 +1,3 @@
from base import Project
-from fiveby import FiveBy \ No newline at end of file
+from fiveby import FiveBy
+from natparks import NationalParkBorders, NationalParkBordersTwo, NationalParks \ No newline at end of file
diff --git a/apps/projects/views.py b/apps/projects/views.py
index 8103270..e3ed773 100644
--- a/apps/projects/views.py
+++ b/apps/projects/views.py
@@ -6,8 +6,9 @@ from django.db.models import get_model
from projects.models.base import Project
from projects.models.fiveby import FiveBy
+from projects.models.natparks import NationalParks
-projects = {'5x5':'FiveBy','6x6':'SixBy'}
+projects = {'5x5':'FiveBy','6x6':'SixBy','national-parks':'NationalParks'}
"""
Projects by slug
@@ -15,7 +16,10 @@ Projects by slug
def detail(request,slug):
name = projects[slug]
model = get_model('projects', name)
- qs = model.objects.filter(status__exact=1)
+ if slug == 'national-parks':
+ qs = model.objects.filter(visited__exact=True).order_by("-date_visited_begin")
+ else:
+ qs = model.objects.filter(status__exact=1)
template = 'details/%s.html' %(slug)
return object_list(request, queryset=qs, template_name=template,)