Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: c8ac36182b
...
compare: c07d536776
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 19, 2013
@jarus jarus Small clean up e4a0986
Commits on Apr 05, 2013
@jarus jarus Extend api and add wikipedia api endpoint c07d536
View
51 krprj/api/resources.py
@@ -1,26 +1,56 @@
+import json
+
from django.contrib.gis.geos import Point, Polygon
from tastypie import fields
-from tastypie.resources import ModelResource
from tastypie.contrib.gis.resources import ModelResource as GeoModelResource
from tastypie.exceptions import InvalidFilterError, BadRequest
from krprj.krunite.models import KircheUnite
from krprj.osm.models import KircheOsm
+from krprj.wikipedia.models import KircheWikipedia
-from time import time
-from django.db import connection
class OSMPlacesResource(GeoModelResource):
+
class Meta:
queryset = KircheOsm.objects.all()
+ allowed_methods = ['get']
resource_name = 'osm_places'
- max_limit = 500
+ max_limit = 50
+
+ place = fields.ToOneField('krprj.api.resources.PlacesResource', 'unite',
+ null=True)
+
+ def dehydrate_addional_fields(self, bundle):
+ return json.loads(bundle.data.get('addional_fields', '{}'))
+
+
+class WikipediaArticleResource(GeoModelResource):
+
+ class Meta:
+ queryset = KircheWikipedia.objects.all()
+ allowed_methods = ['get']
+ resource_name = 'wikipedia_articles'
+ max_limit = 50
+
+ contents = fields.CharField(attribute='contents', null=True,
+ use_in='detail')
+
+ place = fields.ToOneField('krprj.api.resources.PlacesResource', 'unite',
+ null=True)
+
+ def dehydrate_infobox(self, bundle):
+ return json.loads(bundle.data['infobox'])
class PlacesResource(GeoModelResource):
- osm_places = fields.ToManyField(OSMPlacesResource, 'kircheosm_set', full=True)
+ osm_places = fields.ToManyField(OSMPlacesResource, 'kircheosm_set',
+ full=False, use_in='detail')
+ wikipedia_articles = fields.ToManyField(WikipediaArticleResource,
+ 'kirchewikipedia_set',
+ full=False, use_in='detail')
class Meta:
queryset = KircheUnite.objects.all()
@@ -30,7 +60,7 @@ class Meta:
filtering = {
"name": ('exact', 'startswith', 'contains')
}
- max_limit = 100
+ max_limit = 500
def build_filters(self, filters=None):
if filters is None:
@@ -64,16 +94,7 @@ def build_filters(self, filters=None):
return orm_filters
- def get_list(self, request, **kwargs):
- if 'without_relations' in request.GET:
- self.fields.pop("osm_places", None)
- self._meta.max_limit = 500
- return super(PlacesResource, self).get_list(request, **kwargs)
-
def alter_list_data_to_serialize(self, request, data):
- for x in connection.queries:
- print x
- print
if 'request_id' in request.GET:
data['meta']['request_id'] = request.GET['request_id']
return data
View
4 krprj/api/urls.py
@@ -1,10 +1,12 @@
from django.conf.urls import patterns, include
from tastypie.api import Api
-from .resources import PlacesResource, OSMPlacesResource
+from .resources import PlacesResource, OSMPlacesResource, \
+ WikipediaArticleResource
v1_api = Api(api_name='v1')
v1_api.register(PlacesResource())
v1_api.register(OSMPlacesResource())
+v1_api.register(WikipediaArticleResource())
urlpatterns = patterns('', (r'^', include(v1_api.urls)))
View
2  krprj/worshipmap/static/lib/kirchenreich/worshipmap.js
@@ -77,7 +77,7 @@ kr.refresh_markers = function(bounds){
$("#nav_status").html('<span class="label label-warning">Loading...</span>');
kr.request_id++;
- var url = "/api/v1/places/?without_relations&limit=300&in_bbox=" + bounds.toBBoxString() + "&request_id=" + kr.request_id;
+ var url = "/api/v1/places/?limit=500&in_bbox=" + bounds.toBBoxString() + "&request_id=" + kr.request_id;
if (kr.on_mobile()){
url = url + "&limit=100";
}

No commit comments for this range

Something went wrong with that request. Please try again.