# Path: safecity/apps/danger/models.py
# class Report(models.Model):
#     """
#     Processed data for messages that are reporting suspicious activity.
#     
#     TODO: support multi-part messages.
#     """
#     location = models.PointField(
#         spatial_index=True,
#         help_text='Location extracted from the report.')
#         
#     text = models.CharField(
#         max_length=160,
#         help_text='Body of the message.')
#         
#     sender = models.CharField(
#         max_length=16,
#         null=True,
#         help_text='Phone number of the reporter in e164 format. None if anonymized.')
#         
#     received = models.DateTimeField(
#         auto_now_add=True,
#         help_text='Date and time this message was received. Approximate if anonymized.')
# 
#     objects = models.GeoManager()
#     
#     class Meta:
#         ordering = ['-received']
#         get_latest_by = 'received'
#         
#     def find_nearby_residents(self):
#         """
#         Get a list of residents near this report.
#         """
#         return Resident.objects.filter(location__distance_lte=(self.location, D(km=1)))


import json
import logging
from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template.loader import render_to_string
from safecity.apps.danger.models import Report
log = logging.getLogger("safecity.public.views")



def index(request):
    """
    Render the index page that displays anonymized data for public
    consumption.
    """
    map_center = ('41.88', '-87.76')
    
    reports = []
    

# Path: safecity/apps/danger/models.py
# class Report(models.Model):
#     """
#     Processed data for messages that are reporting suspicious activity.
#     
#     TODO: support multi-part messages.
#     """
#     location = models.PointField(
#         spatial_index=True,
#         help_text='Location extracted from the report.')
#         
#     text = models.CharField(
#         max_length=160,
#         help_text='Body of the message.')
#         
#     sender = models.CharField(
#         max_length=16,
#         null=True,
#         help_text='Phone number of the reporter in e164 format. None if anonymized.')
#         
#     received = models.DateTimeField(
#         auto_now_add=True,
#         help_text='Date and time this message was received. Approximate if anonymized.')
# 
#     objects = models.GeoManager()
#     
#     class Meta:
#         ordering = ['-received']
#         get_latest_by = 'received'
#         
#     def find_nearby_residents(self):
#         """
#         Get a list of residents near this report.
#         """
#         return Resident.objects.filter(location__distance_lte=(self.location, D(km=1)))


# Path: safecity/apps/public/views.py
import json
import logging
from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template.loader import render_to_string
from safecity.apps.danger.models import Report

log = logging.getLogger("safecity.public.views")



def index(request):
    """
    Render the index page that displays anonymized data for public
    consumption.
    """
    map_center = ('41.88', '-87.76')
    
    reports = []
    

    for report in Report.objects.all()[:2]: