12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- from django.http import JsonResponse
- from .models import Contrib
- def public_json(request):
- contribs = Contrib.objects.all()
- properties = [
- ('name', 'privacy_name'),
- ('comment', 'privacy_comment'),
- ('place_details', 'privacy_place_details'),
- ('contrib_type', True),
- (''),
- ]
- data = []
- for i in contribs:
- if not i.is_public():
- continue
- data.append({
- "id": i.pk,
- "type": "Feature",
- "geometry": {
- "coordinates": [
- i.latitude,
- i.longitude,
- ],
- "type": "Point",
- },
- "properties": {
- "name": i.get_public_field('name'),
- "place": {
- "floor": i.get_public_field('floor'),
- "angles": i.get_public_field('angles'),
- "orientations": i.get_public_field('orientations'),
- "roof": i.get_public_field('roof'),
- "floor": i.get_public_field('floor'),
- "floor_total": i.get_public_field('floor_total'),
- "comment": i.get_public_field('comment'),
- }
- }
- })
- return JsonResponse({
- "id": "public",
- "license": {
- "type": "ODC-BY-1.0",
- "url": "http:\/\/opendatacommons.org\/licenses\/by\/1.0\/"
- },
- "features": data,
- })
|