diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/blog/views.py | 9 | ||||
-rw-r--r-- | app/builder/base.py | 17 | ||||
-rw-r--r-- | app/photos/photos.js | 2 | ||||
-rw-r--r-- | app/projects/natparks.js | 2 | ||||
-rw-r--r-- | app/projects/shortcuts.py | 10 |
5 files changed, 21 insertions, 19 deletions
diff --git a/app/blog/views.py b/app/blog/views.py index 8ac04dd..1d552eb 100644 --- a/app/blog/views.py +++ b/app/blog/views.py @@ -45,12 +45,13 @@ def entry_list(request, page): request.page_url = '/writing/%d/' request.page = int(page) try: - extra_context = { - 'page': page, + is_build = request.POST['builder'] + extra_context={ + 'page':page, 'MEDIA_URL': settings.BAKED_MEDIA_URL } except: - extra_context = {'page': page} + extra_context={'page':page} context = { 'object_list': Entry.objects.filter(status__exact=1).order_by('-pub_date').select_related(), 'page': page @@ -64,7 +65,7 @@ def entry_list_by_area(request, slug, page): request.page = int(page) try: region = Region.objects.get(slug__exact=slug) - qs = Entry.objects.filter(status__exact=1, region=region).order_by('-pub_date') + qs = Entry.objects.filter(status__exact=1, location__state__country__lux_region=region.id).order_by('-pub_date') except: region = Country.objects.get(slug__exact=slug) qs = Entry.objects.filter( diff --git a/app/builder/base.py b/app/builder/base.py index 017cbd6..09e0a95 100644 --- a/app/builder/base.py +++ b/app/builder/base.py @@ -18,8 +18,8 @@ class Build(): if not os.path.isdir(path): os.makedirs(path) fpath = '%s%s.%s' % (path, filename, ext) - file = open(fpath, 'wt') - file.write(str(text_object)) + file = open(fpath, 'wb') + file.write(text_object) file.close() if ext == 'js': import jsmin @@ -86,7 +86,7 @@ class BuildWriting(Build): blog = get_model('blog', 'entry') regions = model.objects.all() for c in regions: - qs = blog.objects.filter(status__exact=1, location__state__country__region=c.id).order_by('-pub_date') + qs = blog.objects.filter(status__exact=1, location__state__country__lux_region=c.id).order_by('-pub_date') path = 'writing/%s/' % (c.slug) self.build_archive_pages(qs, path) @@ -156,9 +156,9 @@ class BuildPhotos(Build): fpath = '%sdesign/templates/js/leaflet-providers.js' % settings.PROJ_ROOT leaflet_providers_js = open(fpath, 'r').read() fpath = '%sapp/photos/photos.js' % settings.PROJ_ROOT - photos_js = open(fpath, 'r').read() + photos_js = open(fpath, 'r', encoding='UTF8').read() js = leaflet_providers_js + photos_js - self.write_file('media/js/', str(js), 'js', 'photos') + self.write_file('media/js/', js.encode('utf-8'), 'js', 'photos') class BuildProjects(Build): def build(self): @@ -166,6 +166,7 @@ class BuildProjects(Build): self.build_project_details() self.build_project_data() self.build_gifs() + self.build_np_basejs() def get_projects(self): all_proj = [] @@ -221,7 +222,7 @@ class BuildProjects(Build): for park in model.objects.filter(visited__exact=True): path = 'projects/data/natparks/' json = park.mpoly.json - self.write_file(path, json, 'json', park.id) + self.write_file(path, json.encode('utf-8'), 'json', park.id) def build_np_basejs(self): fpath = '%sdesign/templates/js/leaflet-providers.js' % settings.PROJ_ROOT @@ -229,7 +230,7 @@ class BuildProjects(Build): fpath = '%sapp/projects/natparks.js' % settings.PROJ_ROOT natparks_js = open(fpath, 'r').read() js = leaflet_providers_js + natparks_js - self.write_file('media/js/', str(js), 'js', 'natparks') + self.write_file('media/js/', js.encode('utf-8'), 'js', 'natparks') class BuildSitemap(Build): @@ -266,7 +267,7 @@ class BuildMap(Build): fpath = '%sdesign/templates/js/leaflet-providers.js' % settings.PROJ_ROOT leaflet_providers_js = open(fpath, 'r').read() js = leaflet_providers_js + t.decode(encoding='UTF-8') - self.write_file('media/js/', str(js), 'js', 'mainmap') + self.write_file('media/js/', js.encode('utf-8'), 'js', 'mainmap') c = Context({ 'country_list': cl, 'region_list': rl, diff --git a/app/photos/photos.js b/app/photos/photos.js index 1331b0e..b93467a 100644 --- a/app/photos/photos.js +++ b/app/photos/photos.js @@ -6,7 +6,7 @@ function mapit(obj) { map = L.map(document.getElementById("mw-"+elid)); centerCoord = new L.LatLng(lat, lon); zoom = 8; - L.tileLayer.provider('Esri.WorldTopoMap', {maxZoom: 18, attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Tiles © Esri and the GIS User Community'}).addTo(map); + L.tileLayer.provider('Esri.WorldTopoMap', {maxZoom: 18, attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Tiles © Esri and the GIS User Community'}).addTo(map); map.setView(centerCoord, zoom); L.marker([lat, lon]).addTo(map); } diff --git a/app/projects/natparks.js b/app/projects/natparks.js index 8e4748b..8481408 100644 --- a/app/projects/natparks.js +++ b/app/projects/natparks.js @@ -3,7 +3,7 @@ function mapit(lat,lon,zoom,id) { map = L.map(document.getElementById("map-wrapper-"+id)); centerCoord = new L.LatLng(lat, lon); zoom = zoom; - L.tileLayer.provider('Esri.WorldTopoMap', {maxZoom: 18, attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Tiles © Esri and the GIS User Community'}).addTo(map); + L.tileLayer.provider('Esri.WorldTopoMap', {maxZoom: 18, attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Tiles © Esri and the GIS User Community'}).addTo(map); map.setView(centerCoord, zoom); ////get the geojson for this map $.ajax({ diff --git a/app/projects/shortcuts.py b/app/projects/shortcuts.py index d54410c..90b1bb6 100644 --- a/app/projects/shortcuts.py +++ b/app/projects/shortcuts.py @@ -1,7 +1,7 @@ from django.contrib.gis.db.models.fields import GeometryField
#from django.contrib.gis.gdal import Envelope
from django.contrib.gis.geos import Polygon
-from django.utils import simplejson
+import json
from django.http import HttpResponse
#from django.db.models.fields.related import ManyRelatedManager
@@ -192,7 +192,7 @@ def render_to_geojson(query_set, geom_field=None, geom_attribute=None, extra_att if g:
if proj_transform:
g.transform(proj_transform)
- feat['geometry'] = simplejson.loads(g.geojson)
+ feat['geometry'] = json.loads(g.geojson)
feat['properties'] = d
features.append(feat)
else:
@@ -227,9 +227,9 @@ def render_to_geojson(query_set, geom_field=None, geom_attribute=None, extra_att # Return response
response = HttpResponse()
if pretty_print:
- response.write('%s' % simplejson.dumps(collection, indent=1))
+ response.write('%s' % json.dumps(collection, indent=1))
else:
- response.write('%s' % simplejson.dumps(collection))
+ response.write('%s' % json.dumps(collection))
response['Content-length'] = str(len(response.content))
response['Content-Type'] = mimetype
- return response
\ No newline at end of file + return response
|