summaryrefslogtreecommitdiff
path: root/app/projects
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2014-05-23 11:28:10 -0400
committerluxagraf <sng@luxagraf.net>2014-05-23 11:28:10 -0400
commit518b2d618bc10f93cfa44a83715593b8358eb9ce (patch)
treea07993c3ae31bed42f32c0e00788989568790716 /app/projects
parent4bae11bb25a8e3c43118891d17fd8e981ecf8dc6 (diff)
minor refactor to adoipt pep8 and pyflakes coding styles and clean up
some cruft that's been hangin round for years
Diffstat (limited to 'app/projects')
-rw-r--r--app/projects/admin.py237
-rw-r--r--app/projects/models/base.py32
-rw-r--r--app/projects/models/fiveby.py33
-rw-r--r--app/projects/models/gifs.py9
-rw-r--r--app/projects/models/natparks.py41
-rw-r--r--app/projects/shortcuts.py46
-rw-r--r--app/projects/urls.py3
-rw-r--r--app/projects/views.py37
8 files changed, 163 insertions, 275 deletions
diff --git a/app/projects/admin.py b/app/projects/admin.py
index e97a261..15c822a 100644
--- a/app/projects/admin.py
+++ b/app/projects/admin.py
@@ -1,8 +1,5 @@
from django.contrib import admin
-from django import forms
from django.contrib.gis.admin import OSMGeoAdmin
-from django.contrib.gis.maps.google import GoogleMap
-from django.conf import settings
from projects.models.base import Project
from projects.models.fiveby import FiveBy
@@ -10,200 +7,110 @@ from projects.models.natparks import NationalParks
from projects.models.gifs import AnimatedGif
-GMAP = GoogleMap(key=settings.GOOGLE_MAPS_API_KEY)
-
class ProjectAdmin(OSMGeoAdmin):
-
- list_display = ('title', 'pub_date', 'status',)
+ list_display = ('title', 'pub_date', 'status',)
search_fields = ['title', 'body_markdown']
- prepopulated_fields = {"slug" : ('title',)}
+ prepopulated_fields = {"slug": ('title',)}
list_filter = ('pub_date', 'status')
fieldsets = (
- ('Project', {'fields': ('title','subtitle','lede', 'pub_date', 'model_name',('status','image',), 'slug',), 'classes': ('show','extrapretty','wide')}),
+ ('Project', {
+ 'fields': (
+ 'title',
+ 'subtitle',
+ 'lede',
+ 'pub_date',
+ 'model_name',
+ ('status', 'image'),
+ 'slug',
+ ),
+ '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 FiveByAdmin(OSMGeoAdmin):
-
- list_display = ('title', 'pub_date', 'status',)
- search_fields = ['title',]
- prepopulated_fields = {"slug" : ('title',)}
+ list_display = ('title', 'pub_date', 'status',)
+ search_fields = ['title']
+ prepopulated_fields = {"slug": ('title',)}
list_filter = ('pub_date', 'status')
fieldsets = (
- ('Project', {'fields': ('title','lede', 'pub_date', 'status',('image','videoh264','videoogg'), 'slug',('vimeo_link','youtube_link'),('point','location','region')), 'classes': ('show','extrapretty','wide')}),
+ ('Project', {'fields': ('title', 'lede', 'pub_date', 'status', ('image', 'videoh264', 'videoogg'), 'slug', ('vimeo_link', 'youtube_link'), ('point', 'location', 'region')), '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
+
+ # options for OSM map Using custom ESRI topo map
+ default_lon = -9285175
+ default_lat = 4025046
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
+ units = 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
-
+ map_height = 425
+ map_template = 'gis/admin/osm.html'
class NationalParksAdmin(OSMGeoAdmin):
-
- list_display = ('unit_name','type','state','name','visited', 'size')
+ list_display = ('unit_name', 'type', 'state', 'name', 'visited', 'size')
list_filter = ('state', 'type')
- search_fields = ['name',]
+ 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','date_park_created'),'zoom'), 'classes': ('show','extrapretty','wide')}),
+ ('Project', {
+ 'fields': (
+ 'name',
+ 'tag_line',
+ ('state', 'visited'),
+ 'dek',
+ 'date_visited_begin',
+ 'date_visited_end',
+ 'mpoly',
+ 'image',
+ ('post', 'gallery'),
+ ('url', 'size', 'fee', 'camping_fee', 'date_park_created'),
+ '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
+
+ # options for OSM map Using custom ESRI topo map
+ default_lon = -9285175
+ default_lat = 4025046
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
+ units = 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
+ map_height = 425
+ map_template = 'gis/admin/osm.html'
-from django.contrib import admin
-
-from projects.models.code import Code,CodeBlogEntry,CodeBlogDemo
-
-class CodeAdmin(admin.ModelAdmin):
- list_display = ('name', 'date_created', 'status')
- search_fields = ['name','body_html']
- list_filter = ['status',]
- fieldsets = (
- (None, {'fields': ('name','date_created','slug','status','body_html')}),
- )
-
-class CodeBlogEntryAdmin(admin.ModelAdmin):
- list_display = ('title', 'pub_date', 'status')
- search_fields = ['name','body_markdown']
- list_filter = ['status',]
- prepopulated_fields = {"slug" : ('title',)}
- fieldsets = (
- (None, {'fields': ('title','body_markdown','pub_date','slug','status','enable_comments')}),
- )
-
-class CodeBlogDemoAdmin(admin.ModelAdmin):
- list_display = ('title', 'pub_date', )
- search_fields = ['name','body']
- fieldsets = (
- (None, {'fields': ('title','slug','template','head','body')}),
- )
class AnimatedGifAdmin(admin.ModelAdmin):
list_display = ('title', 'date_created')
- search_fields = ['title',]
+ search_fields = ['title']
fieldsets = (
- (None, {'fields': ('title','gif','date_created','slug','music_ogg','music_mp3')}),
+ (None, {
+ 'fields': (
+ 'title',
+ 'gif',
+ 'date_created',
+ 'slug',
+ 'music_ogg',
+ 'music_mp3'
+ )
+ }),
)
-
+
admin.site.register(AnimatedGif, AnimatedGifAdmin)
-admin.site.register(CodeBlogEntry, CodeBlogEntryAdmin)
-admin.site.register(CodeBlogDemo, CodeBlogDemoAdmin)
-admin.site.register(Code, CodeAdmin)
admin.site.register(Project, ProjectAdmin)
admin.site.register(FiveBy, FiveByAdmin)
admin.site.register(NationalParks, NationalParksAdmin)
diff --git a/app/projects/models/base.py b/app/projects/models/base.py
index 26a0122..51379a0 100644
--- a/app/projects/models/base.py
+++ b/app/projects/models/base.py
@@ -1,26 +1,18 @@
import datetime
from django.contrib.gis.db import models
-from django.conf import settings
from django.contrib.sitemaps import Sitemap
-from django.template.defaultfilters import truncatewords_html
-from django.contrib.syndication.views import Feed
-
import markdown
-from photos.models import PhotoGallery
-from locations.models import Location,Region
-
-
def get_upload_path(self, filename):
- return "images/project-thumbs/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
+ return "images/project-thumbs/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
-def markdown_processor(md):
- html = markdown.markdown(md, safe_mode = False).split('<break>')
+
+def markdown_processor(md):
+ html = markdown.markdown(md, safe_mode=False).split('<break>')
return html
-
class Project(models.Model):
title = models.CharField(max_length=200)
subtitle = models.CharField(max_length=200, null=True, blank=True)
@@ -32,9 +24,9 @@ class Project(models.Model):
(1, 'Published'),
)
status = models.IntegerField(choices=PUB_STATUS, default=0)
- image = models.FileField(upload_to=get_upload_path, null=True,blank=True)
+ image = models.FileField(upload_to=get_upload_path, null=True, blank=True)
model_name = models.CharField(max_length=200, null=True)
-
+
@property
def longitude(self):
'''Get the site's longitude.'''
@@ -43,8 +35,8 @@ class Project(models.Model):
@property
def latitude(self):
'''Get the site's latitude.'''
- return self.point.y
-
+ return self.point.y
+
class Meta:
ordering = ('-pub_date',)
get_latest_by = 'pub_date'
@@ -55,14 +47,14 @@ class Project(models.Model):
def get_absolute_url(self):
return "/%s/%s/" % ('projects', self.slug)
-
+
def get_previous_published(self):
return self.get_previous_by_pub_date(status__exact=1)
-
+
def get_next_published(self):
return self.get_next_by_pub_date(status__exact=1)
-
-
+
+
class ProjectSitemap(Sitemap):
changefreq = "monthly"
priority = 0.5
diff --git a/app/projects/models/fiveby.py b/app/projects/models/fiveby.py
index 45aa21d..b6c7e33 100644
--- a/app/projects/models/fiveby.py
+++ b/app/projects/models/fiveby.py
@@ -1,25 +1,23 @@
import datetime
from django.contrib.gis.db import models
-from django.conf import settings
-from django.contrib.sitemaps import Sitemap
-from django.template.defaultfilters import truncatewords_html
-from django.contrib.syndication.views import Feed
+from locations.models import Location, Region
-from locations.models import Location,Region
def get_upload_path(self, filename):
- return "images/projects/videos/5x5/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
+ return "images/projects/videos/5x5/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
+
def get_image_upload_path(self, filename):
- return "images/projects/5x5/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
-
+ return "images/projects/5x5/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
+
+
class FiveBy(models.Model):
title = models.CharField(max_length=200)
slug = models.SlugField(unique_for_date='pub_date')
lede = models.TextField(blank=True)
- image = models.FileField(upload_to=get_image_upload_path, null=True,blank=True)
- videoh264 = models.FileField(upload_to=get_upload_path, null=True,blank=True)
- videoogg = models.FileField(upload_to=get_upload_path, null=True,blank=True)
+ image = models.FileField(upload_to=get_image_upload_path, null=True, blank=True)
+ videoh264 = models.FileField(upload_to=get_upload_path, null=True, blank=True)
+ videoogg = models.FileField(upload_to=get_upload_path, null=True, blank=True)
vimeo_link = models.CharField(max_length=200)
youtube_link = models.CharField(max_length=200)
pub_date = models.DateTimeField('Date published')
@@ -31,21 +29,19 @@ class FiveBy(models.Model):
point = models.PointField(null=True)
location = models.ForeignKey(Location, null=True)
region = models.ForeignKey(Region, null=True)
-
-
-
+
class Meta:
ordering = ('-pub_date',)
get_latest_by = 'pub_date'
app_label = 'projects'
verbose_name_plural = '5x5'
-
- def __unicode__(self):
+
+ def __str__(self):
return self.title
def get_absolute_url(self):
return "/%s/%s/%s/" % ('projects', '5x5', self.slug)
-
+
@property
def longitude(self):
'''Get the site's longitude.'''
@@ -54,5 +50,4 @@ class FiveBy(models.Model):
@property
def latitude(self):
'''Get the site's latitude.'''
- return self.point.y
-
+ return self.point.y
diff --git a/app/projects/models/gifs.py b/app/projects/models/gifs.py
index e20530b..25b8734 100644
--- a/app/projects/models/gifs.py
+++ b/app/projects/models/gifs.py
@@ -3,7 +3,7 @@ from django.db import models
def get_upload_path(self, filename):
- return "images/projects/gifs/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
+ return "images/projects/gifs/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
class AnimatedGif(models.Model):
@@ -18,8 +18,9 @@ class AnimatedGif(models.Model):
verbose_name_plural = "Animated Gifs"
app_label = 'projects'
ordering = ('-date_created',)
- # Returns the string representation of the model.
- def __unicode__(self):
+
+ def __str__(self):
return self.slug
+
def get_absolute_url(self):
- return '/projects/gifs/%s/' %(self.slug)
+ return '/projects/gifs/%s/' % (self.slug)
diff --git a/app/projects/models/natparks.py b/app/projects/models/natparks.py
index 11fe6bb..3615737 100644
--- a/app/projects/models/natparks.py
+++ b/app/projects/models/natparks.py
@@ -1,19 +1,13 @@
-from django.contrib.gis.db import models
+import datetime
from PIL import Image
+from django.contrib.gis.db import models
from blog.models import Entry
from photos.models import PhotoGallery
from locations.models import State
-PUB_STATUS = (
- (0, 'Draft'),
- (1, 'Published'),
- )
-
-
-import datetime
def get_upload_path(self, filename):
- return "images/projects/np/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
+ return "images/projects/np/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
class NationalParks(models.Model):
@@ -24,33 +18,34 @@ class NationalParks(models.Model):
fee = models.CharField(max_length=5, null=True)
camping_fee = models.CharField(max_length=10, null=True)
url = models.CharField(max_length=250, null=True)
- code= models.CharField(max_length=16)
- unit_name= models.CharField(max_length=254)
- date_visited_begin = models.DateField('Date Visited',null=True)
- date_visited_end = models.DateField('Date Visited',null=True)
- date_park_created = models.DateField('Date Park Created',null=True)
- zoom= models.IntegerField(null=True)
+ code = models.CharField(max_length=16)
+ unit_name = models.CharField(max_length=254)
+ date_visited_begin = models.DateField('Date Visited', null=True)
+ date_visited_end = models.DateField('Date Visited', null=True)
+ date_park_created = models.DateField('Date Park Created', null=True)
+ zoom = models.IntegerField(null=True)
mpoly = models.MultiPolygonField(null=True)
visited = models.BooleanField(default=False)
dek = models.TextField(null=True, blank=True)
tag_line = models.CharField(max_length=254, null=True)
post = models.ForeignKey(Entry, null=True)
gallery = models.ForeignKey(PhotoGallery, blank=True, null=True, verbose_name='photo set')
- image = models.FileField(upload_to=get_upload_path, null=True,blank=True,help_text="width: 980px, height: > 450px")
- image_height = models.CharField(max_length=20, null=True,blank=True)
- image_width = models.CharField(max_length=20, null=True,blank=True)
+ image = models.FileField(upload_to=get_upload_path, null=True, blank=True,
+ help_text="width: 980px, height: > 450px")
+ image_height = models.CharField(max_length=20, null=True, blank=True)
+ image_width = models.CharField(max_length=20, null=True, blank=True)
objects = models.GeoManager()
class Meta:
verbose_name_plural = "National Parks"
app_label = 'projects'
- ordering = ('-visited','unit_name',)
- # Returns the string representation of the model.
- def __unicode__(self):
+ ordering = ('-visited', 'unit_name',)
+
+ def __str__(self):
return self.unit_name
- def save(self):
+ def save(self):
#get image dimensions
img = Image.open(self.image)
- self.image_width, self.image_height = img.size
+ self.image_width, self.image_height = img.size
super(NationalParks, self).save()
diff --git a/app/projects/shortcuts.py b/app/projects/shortcuts.py
index 600e56d..7753d18 100644
--- a/app/projects/shortcuts.py
+++ b/app/projects/shortcuts.py
@@ -28,22 +28,22 @@ def a_shapes(request):
mimetype=mimetype,
proj_transform=900913,
pretty_print=pretty_print
- )
-
+ )
+
def responses(qs,type_='countries',pretty_print=True,mimetype='text/plain'):
if type_ == 'locations':
qs = qs.geolocations()
- return render_to_geojson(qs,
- excluded_fields=['json'],
+ return render_to_geojson(qs,
+ excluded_fields=['json'],
geom_field='point',
proj_transform=900913,
mimetype=mimetype,
pretty_print=pretty_print
)
- elif type_ == 'affiliates':
+ elif type_ == 'affiliates':
qs = qs.exclude(geokeywords='').attach_locations()
return render_to_geojson(qs,
- included_fields=['id','_geokeywords_cache'],
+ included_fields=['id','_geokeywords_cache'],
geom_attribute='point',
extra_attributes=['name'],
proj_transform=900913,
@@ -57,11 +57,11 @@ def responses(qs,type_='countries',pretty_print=True,mimetype='text/plain'):
#geom_attribute='point',
mimetype=mimetype,
pretty_print=pretty_print
- )
+ )
else:# type_ == 'countries' or type is None:
if len(qs) > 10:
# this is a limit, weird huh?
- # requires another all() otherwise it
+ # requires another all() otherwise it
# returns a list!
qs = qs.all()[:10]
return render_to_geojson(qs,
@@ -77,10 +77,10 @@ def responses(qs,type_='countries',pretty_print=True,mimetype='text/plain'):
def render_to_geojson(query_set, geom_field=None, geom_attribute=None, extra_attributes=[],mimetype='text/plain', pretty_print=False, excluded_fields=[],included_fields=[],proj_transform=None):
'''
-
+
Shortcut to render a GeoJson FeatureCollection from a Django QuerySet.
Currently computes a bbox and adds a crs member as a sr.org link
-
+
'''
excluded_fields.append('_state')
collection = {}
@@ -89,7 +89,7 @@ def render_to_geojson(query_set, geom_field=None, geom_attribute=None, extra_att
query_set = [query_set]
else:
fields = query_set.model._meta.fields
-
+
if geom_attribute:
geometry_name = geom_attribute
geo_field = None
@@ -112,7 +112,7 @@ def render_to_geojson(query_set, geom_field=None, geom_attribute=None, extra_att
else:
geo_fields = [f for f in fields if isinstance(f, GeometryField)]
-
+
#attempt to assign geom_field that was passed in
if geom_field:
#import pdb;pdb.set_trace()
@@ -126,15 +126,15 @@ def render_to_geojson(query_set, geom_field=None, geom_attribute=None, extra_att
raise Exception('There appears to be no valid geometry on this model')
geo_field = geo_fields[0] # no support yet for multiple geometry fields
-
- #remove other geom fields from showing up in attributes
+
+ #remove other geom fields from showing up in attributes
if len(geo_fields) > 1:
for field in geo_fields:
if field.name not in excluded_fields:
excluded_fields.append(field.name)
geometry_name = geo_field.name
-
+
srid = geo_field.srid
@@ -148,10 +148,10 @@ def render_to_geojson(query_set, geom_field=None, geom_attribute=None, extra_att
crs_properties = {}
crs_properties['href'] = 'http://spatialreference.org/ref/epsg/%s/' % to_srid
crs_properties['type'] = 'proj4'
- crs['properties'] = crs_properties
+ crs['properties'] = crs_properties
collection['crs'] = crs
collection['srid'] = to_srid
-
+
# Build list of features
features = []
if query_set.distinct():
@@ -199,14 +199,14 @@ def render_to_geojson(query_set, geom_field=None, geom_attribute=None, extra_att
pass #features.append({'type':'Feature','geometry': {},'properties':{}})
# Label as FeatureCollection and add Features
- collection['type'] = "FeatureCollection"
+ collection['type'] = "FeatureCollection"
collection['features'] = features
-
+
# Attach extent of all features
if query_set:
ex = None
query_set.query.distinct = False
- if hasattr(query_set,'agg_extent'):
+ if hasattr(query_set,'agg_extent'):
ex = [x for x in query_set.agg_extent.tuple]
elif '.' in geometry_name:
prop, meth = geometry_name.split('.')
@@ -223,13 +223,13 @@ def render_to_geojson(query_set, geom_field=None, geom_attribute=None, extra_att
poly.transform(proj_transform)
ex = poly.extent
collection['bbox'] = ex
-
+
# Return response
response = HttpResponse()
if pretty_print:
response.write('%s' % simplejson.dumps(collection, indent=1))
else:
- response.write('%s' % simplejson.dumps(collection))
+ response.write('%s' % simplejson.dumps(collection))
response['Content-length'] = str(len(response.content))
response['Content-Type'] = mimetype
- return response \ No newline at end of file
+ return response
diff --git a/app/projects/urls.py b/app/projects/urls.py
index bd7c13d..f826624 100644
--- a/app/projects/urls.py
+++ b/app/projects/urls.py
@@ -9,7 +9,6 @@ urlpatterns = patterns('',
(r'(?P<slug>[-\w]+)/$', 'projects.views.detail'),
(r'^$', ListView.as_view(
queryset=Project.objects.filter(status__exact=1).order_by('-pub_date'),
- template_name = "archives/projects.html",
+ template_name="archives/projects.html",
)),
)
-
diff --git a/app/projects/views.py b/app/projects/views.py
index e9c755f..39ae781 100644
--- a/app/projects/views.py
+++ b/app/projects/views.py
@@ -1,21 +1,21 @@
-from django.shortcuts import render_to_response,get_object_or_404
+from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.db.models import get_model
-from django.http import HttpResponse
-from django.core import serializers
from projects.shortcuts import render_to_geojson
-from projects.models.base import Project
-from projects.models.fiveby import FiveBy
from projects.models.natparks import NationalParks
from projects.models.gifs import AnimatedGif
-projects = {'5x5':'FiveBy','6x6':'SixBy','national-parks':'NationalParks','code':'Code'}
+projects = {
+ '5x5': 'FiveBy',
+ '6x6': 'SixBy',
+ 'national-parks': 'NationalParks',
+ 'code': 'Code'
+}
-"""
-Projects by slug
-"""
-def detail(request,slug):
+
+def detail(request, slug):
+ """Projects by slug"""
name = projects[slug]
model = get_model('projects', name)
if slug == 'national-parks':
@@ -23,13 +23,13 @@ def detail(request,slug):
else:
qs = model.objects.filter(status__exact=1)
context = {
- "object_list" : qs,
- }
- template = 'details/%s.html' %(slug)
- return render_to_response(template, context, context_instance = RequestContext(request))
+ "object_list": qs,
+ }
+ template = 'details/%s.html' % (slug)
+ return render_to_response(template, context, context_instance=RequestContext(request))
-def gif_detail(request,slug):
+def gif_detail(request, slug):
obj = get_object_or_404(AnimatedGif, slug__exact=slug)
return render_to_response('details/gifs.html', {'object': obj}, context_instance=RequestContext(request))
@@ -38,9 +38,8 @@ def data_json(request, id):
qs = NationalParks.objects.filter(pk=id)
return render_to_geojson(
qs,
- included_fields=['id',],
+ included_fields=['id'],
geom_attribute='mpoly',
- mimetype = 'application/json',
+ mimetype='application/json',
pretty_print=True
- )
-
+ )