Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

change urmobile URLs to 'mobile'

  • Loading branch information...
commit d15d156f75a4e31f50bafff154132ef3c69a7c45 1 parent f110183
Jennifer Bell authored
2  .project
View
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>fixmystreet google code</name>
+ <name>FixMySteet</name>
<comment></comment>
<projects>
</projects>
117 mainapp/fixtures/test_rest.json
View
@@ -0,0 +1,117 @@
+[
+ {
+ "pk": 1,
+ "model": "mainapp.report",
+ "fields": {
+ "category": 5,
+ "is_hate": false,
+ "sent_at": "2009-02-02 16:58:06",
+ "is_confirmed": true,
+ "title": "Unfixed 1",
+ "photo": "",
+ "created_at": "2009-02-02 16:47:06",
+ "point": "POINT (-75.6965517998000053 45.4187415580000007)",
+ "updated_at": "2010-02-02 16:47:06",
+ "email_sent_to": "jennifer@visiblegovernment.ca",
+ "author": "Jennifer Bell",
+ "fixed_at": null,
+ "reminded_at": "2009-02-02 16:47:06",
+ "ward": 3,
+ "is_fixed": false,
+ "desc": "Here's a description with a lot of 'escapes' in it.\r\n\r\nAnd linebreaks!"
+ }
+ },
+
+ {
+ "pk": 2,
+ "model": "mainapp.report",
+ "fields": {
+ "category": 1,
+ "is_hate": false,
+ "sent_at": "2009-02-02 16:58:06",
+ "is_confirmed": true,
+ "title": "Unfixed 2",
+ "photo": "",
+ "created_at": "2009-02-02 16:47:06",
+ "point": "POINT (-75.6965517998000053 45.4187415580000007)",
+ "updated_at": "2010-02-02 16:47:06",
+ "email_sent_to": "jennifer@visiblegovernment.ca",
+ "author": "Jennifer Bell",
+ "fixed_at": null,
+ "reminded_at": "2009-02-02 16:47:06",
+ "ward": 3,
+ "is_fixed": false,
+ "desc": "Here's a description with a lot of 'escapes' in it.\r\n\r\nAnd linebreaks!"
+ }
+ },
+
+ {
+ "pk": 3,
+ "model": "mainapp.report",
+ "fields": {
+ "category": 1,
+ "is_hate": false,
+ "sent_at": "2009-02-02 16:58:06",
+ "is_confirmed": true,
+ "title": "Fixed in Two Days",
+ "photo": "",
+ "created_at": "2009-02-02 16:47:06",
+ "point": "POINT (-75.6824648380000014 45.4301269580000024)",
+ "updated_at": "2009-02-02 16:47:06",
+ "email_sent_to": "jennifer@visiblegovernment.ca",
+ "author": "Jennifer Bell",
+ "fixed_at": "2009-02-04 16:58:06",
+ "reminded_at": "2009-02-02 16:47:06",
+ "ward": 3,
+ "is_fixed": true,
+ "desc": "Here's a description with a lot of 'escapes' in it.\r\n\r\nAnd linebreaks!"
+ }
+ },
+
+ {
+ "pk": 4,
+ "model": "mainapp.report",
+ "fields": {
+ "category": 5,
+ "is_hate": false,
+ "sent_at": "2009-02-02 15:18:43",
+ "is_confirmed": true,
+ "title": "Fixed in 16 Days",
+ "photo": "",
+ "created_at": "2009-02-02 15:11:49",
+ "point": "POINT (-75.6824648380000014 45.4301269580000024)",
+ "updated_at": "2009-02-09 19:35:16",
+ "email_sent_to": "jennifer@visiblegovernment.ca",
+ "author": "Jennifer Bell",
+ "fixed_at": "2009-02-18 19:35:16",
+ "reminded_at": "2009-02-02 15:11:49",
+ "ward": 4,
+ "is_fixed": true,
+ "desc": "Parks!"
+ }
+ },
+
+ {
+ "pk": 5,
+ "model": "mainapp.report",
+ "fields": {
+ "category": 5,
+ "is_hate": false,
+ "sent_at": "2009-02-02 15:18:43",
+ "is_confirmed": false,
+ "title": "Fixed in 16 Days",
+ "photo": "",
+ "created_at": "2009-02-02 15:11:49",
+ "point": "POINT (-75.6824648380000014 45.4301269580000024)",
+ "updated_at": "2009-02-09 19:35:16",
+ "email_sent_to": "jennifer@visiblegovernment.ca",
+ "author": "Jennifer Bell",
+ "fixed_at": "2009-02-18 19:35:16",
+ "reminded_at": "2009-02-02 15:11:49",
+ "ward": 4,
+ "is_fixed": false,
+ "desc": "Parks!"
+ }
+ }
+
+]
28 mainapp/models.py
View
@@ -266,7 +266,12 @@ class ReportUpdate(models.Model):
phone = models.CharField(max_length=255, verbose_name = ugettext_lazy("Phone") )
first_update = models.BooleanField(default=False)
- def send_emails(self):
+ def notify(self):
+ """
+ Tell whoever cares that there's been an update to this report.
+ - If it's the first update, tell city officials
+ - Anything after that, tell subscribers
+ """
if self.first_update:
self.notify_on_new()
else:
@@ -318,6 +323,15 @@ def notify_on_update(self):
def save(self):
+ # does this update require confirmation?
+ if not self.is_confirmed:
+ self.get_confirmation()
+ else:
+ self.notify()
+
+
+ def get_confirmation(self):
+ """ Send a confirmation email to the user. """
if not self.confirm_token or self.confirm_token == "":
m = md5.new()
m.update(self.email)
@@ -345,7 +359,7 @@ class Meta:
class ReportSubscriber(models.Model):
"""
- Report Subscribers are notified when there's an update.
+ Report Subscribers are notified when there's an update to an existing report.
"""
report = models.ForeignKey(Report)
@@ -435,17 +449,15 @@ def __init__(self,ward, reports = []):
class CityMap(GoogleMap):
"""
- Show all wards in a city as overlays.
+ Show all wards in a city as overlays. Used when debugging maps for new cities.
"""
def __init__(self,city):
polygons = []
- kml_url = 'http://localhost:8000/media/kml/' + city.name + '.kml'
-
ward = Ward.objects.filter(city=city)[:1][0]
- #for ward in Ward.objects.filter(city=city):
- # for poly in ward.geom:
- # polygons.append( GPolygon( poly ) )
+ for ward in Ward.objects.filter(city=city):
+ for poly in ward.geom:
+ polygons.append( GPolygon( poly ) )
GoogleMap.__init__(self,center=ward.geom.centroid,zoom=13,key=settings.GMAP_KEY, polygons=polygons, kml_urls=[kml_url],dom_id='map_canvas')
3  mainapp/tests/__init__.py
View
@@ -1,2 +1,3 @@
from emailrules import *
-from stats import *
+from stats import *
+from mobile import *
13 mainapp/tests/mobile.py
View
@@ -49,23 +49,23 @@ def get_json(self, query):
return( simplejson.loads(response.content) )
def test_get_by_query(self):
- result = self.get_json('/rest/reports.json?q=K2P1N8')
+ result = self.get_json('/mobile/reports.json?q=K2P1N8')
self.assertEquals( len(result), 4 )
def test_get_bad_format(self):
- response = self.c.get('/rest/reports.unknown?q=K2P1N8')
+ response = self.c.get('/mobile/reports.unknown?q=K2P1N8')
self.assertEquals(response.status_code,415)
def test_get_by_lat_lon(self):
lon = '-75.6824648380000014'
lat = '45.4301269580000024'
- result = self.get_json('/rest/reports.json?lat=%s;lon=%s' % (lat,lon))
+ result = self.get_json('/mobile/reports.json?lat=%s;lon=%s' % (lat,lon))
self.assertEquals( len(result), 4 )
def test_get_by_lat_lon_with_r(self):
lon = '-75.6824648380000014'
lat = '45.4301269580000024'
- result = self.get_json('/rest/reports.json?lat=%s;lon=%s;r=.002' % (lat,lon))
+ result = self.get_json('/mobile/reports.json?lat=%s;lon=%s;r=.002' % (lat,lon))
self.assertEquals( len(result), 2 )
def test_create_param_tranform(self):
@@ -80,7 +80,7 @@ def test_create(self):
m = md5.new( seed )
params['api_key'] = binascii.b2a_base64(m.digest())
- response = self.c.post('/rest/reports.json', params )
+ response = self.c.post('/mobile/reports.json', params )
self.assertEquals( response.status_code, 200 )
self.assertEqual(Report.objects.filter(title=params['title']).count(), 1 )
# mail should go directly to the city.
@@ -89,9 +89,8 @@ def test_create(self):
def test_create_no_nonce(self):
params = MOBILE_PARAMS.copy()
- response = self.c.post('/rest/reports.json', params )
+ response = self.c.post('/mobile/reports.json', params )
self.assertEquals( response.status_code, 412 )
- print response.content
def test_create_basecase(self):
"""
47 mainapp/views/main.py
View
@@ -1,6 +1,7 @@
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponseRedirect
from mainapp.models import Report, ReportUpdate, Ward, FixMyStreetMap, ReportCountQuery, City, FaqEntry, GoogleAddressLookup
+from mainapp import search
from django.template import Context, RequestContext
from django.contrib.gis.measure import D
from django.contrib.gis.geos import *
@@ -13,7 +14,6 @@
import urllib
-
def index(request, error_msg = None, disambiguate=None):
reports_with_photos = Report.objects.filter(is_confirmed=True).exclude(photo='').order_by("-created_at")[:3]
recent_reports = Report.objects.filter(is_confirmed=True).order_by("-created_at")[:5]
@@ -27,43 +27,38 @@ def index(request, error_msg = None, disambiguate=None):
'disambiguate':disambiguate },
context_instance=RequestContext(request))
-
def search_address(request):
if request.method == 'POST':
address = iri_to_uri(u'/search?q=%s' % request.POST["q"])
return HttpResponseRedirect( address )
-# address = urllib.urlencode({'x':urlquote(request.POST["q"])})[2:]
-# return HttpResponseRedirect("/search?q=" + address )
- address = request.GET["q"]
- address_lookup = GoogleAddressLookup( address )
+ address = request.GET["q"]
- if not address_lookup.resolve():
- return index(request, _("Sorry, we couldn\'t retreive the coordinates of that location, please use the Back button on your browser and try something more specific or include the city name at the end of your search."))
-
- if not address_lookup.exists():
- return index( request, _("Sorry, we couldn\'t find the address you entered. Please try again with another intersection, address or postal code, or add the name of the city to the end of the search."))
+ match_index = -1
+ if request.GET.has_key("index"):
+ match_index = int(request.GET["index"] or 0)
- if address_lookup.matches_multiple() and not request.GET.has_key("index"):
- addrs = address_lookup.get_match_options()
- addr_list = ""
+ addrs = []
+ try:
+ point_str = search.search_address(address, match_index, addrs)
+ except search.SearchAddressDisambiguateError, e:
+ # addrs = address_lookup.get_match_options()
+ addr_list = ""
for i in range(0,len(addrs)):
link = "/search?q=" + urlquote(address) + "&index=" + str(i)
addr_list += "<li><a href='%s'>%s</a></li>" % ( link, addrs[i] )
addr_list += "</ul>"
return index(request,disambiguate = addr_list )
-
- # otherwise, we have a specific match
- match_index = 0
- if request.GET.has_key("index"):
- match_index = int(request.GET["index"])
-
- point_str = "POINT(" + address_lookup.lon(match_index) + " " + address_lookup.lat(match_index) + ")"
- pnt = fromstr(point_str, srid=4326)
- wards = Ward.objects.filter(geom__contains=point_str)
- if (len(wards) == 0):
- return( index(request, _("Sorry, we don't yet have that area in our database. Please have your area councillor contact fixmystreet.ca.")))
-
+ except search.SearchAddressException, e:
+ return index(request, _(str(e)))
+
+ pnt = fromstr(point_str, srid=4326)
+
+ try:
+ wards = search.search_wards(point_str)
+ except search.SearchAddressNotSupported, e:
+ return( index(request, _(str(e))))
+
reports = Report.objects.filter(is_confirmed = True,point__distance_lte=(pnt,D(km=4))).distance(pnt).order_by('distance')
gmap = FixMyStreetMap(pnt,True,reports)
203 mainapp/views/mobile.py
View
@@ -3,14 +3,110 @@
from django.contrib.gis.geos import fromstr
from django.contrib.gis.measure import D
from django.forms.util import ErrorDict
-
-from mainapp.models import Report
+from mainapp.models import Report,ReportCategory
from mainapp import search
+from mainapp.views.reports.main import create_report
+import md5
+import binascii
+import settings
+from django.core import serializers
+from django.http import HttpResponse, HttpResponseBadRequest
+from django.db import models
class InputValidationException(Exception):
pass
+class InvalidAPIKey(Exception):
+ pass
+
+class MobileReportAPI(object):
+
+ EXPOSE_FIELDS = ('id','point', 'title','desc','author','email_sent_to','created_at','is_fixed')
+
+ FORIEGN_TO_LOCAL_KEYS = { 'customer_email':'email',
+ 'customer_phone':'phone',
+ 'description': 'desc',
+ 'category': 'category_id'
+ }
+
+ def get(self,request):
+ ids = request.GET.getlist("id")
+ if ids:
+ try:
+ ids = [int(id) for id in ids]
+ except (TypeError, ValueError), e:
+ raise InputValidationException(str(e))
+ reports = Report.objects.filter(id__in = ids)
+ # process ids right now
+ else:
+ lon = request.GET.get("lon")
+ lat = request.GET.get("lat")
+ address = request.GET.get("q")
+ if lat and lon:
+ point_str = "POINT(%s %s)" %(lon, lat)
+ elif address:
+ addrs = []
+ match_index = int(request.GET.get('index', -1))
+ point_str = search.search_address(address, match_index, addrs)
+ else:
+ raise InputValidationException('Must supply either a `q`, `lat` `lon`, or a report `id`')
+
+ radius = float(request.GET.get('r', 4))
+ pnt = fromstr(point_str, srid=4326)
+ reports = Report.objects.filter(is_confirmed = True,point__distance_lte=(pnt,D(km=radius))).distance(pnt).order_by('distance')[:100]
+ return( reports )
+
+ def post(self,request):
+ request.POST = MobileReportAPI._transform_params(request.POST)
+
+ if not request.POST.has_key('device_id'):
+ raise InputValidationException('General Service Error: No device_id')
+
+ if not MobileReportAPI._nonce_ok(request):
+ raise InvalidAPIKey('Invalid API Key')
+
+ # we're good.
+ report = create_report(request,True)
+ if not report:
+ # some issue with our form input. Does this need to be more detailed?
+ raise InputValidationException('General Service Error: bad input')
+ return( Report.objects.filter(pk=report.id) )
+
+ def make_response(self,format,models = [],fields= None,status=200):
+ mimetype = 'application/%s'%format
+ data = serializers.serialize(format, models, fields=fields)
+ return HttpResponse(data,mimetype=mimetype,status=status)
+
+ @staticmethod
+ def _nonce_ok(request):
+ timestamp = request.POST.get('timestamp')
+ email = request.POST.get('email')
+ nonce = request.POST.get('api_key')
+ seed = '%s:%s:%s' % ( email,timestamp,settings.MOBILE_SECURE_KEY )
+ m = md5.new( seed )
+ compare_nonce = binascii.b2a_base64(m.digest())
+ return( compare_nonce == nonce)
+
+ @staticmethod
+ def _transform_params(params):
+ for theirkey,ourkey in MobileReportAPI.FORIEGN_TO_LOCAL_KEYS.items():
+ if params.has_key(theirkey):
+ params[ ourkey ] = params[ theirkey ]
+ del(params[theirkey])
+
+ # combine first and last names.
+ if params.has_key('first_name') or params.has_key('last_name'):
+ if params.has_key('first_name') and params.has_key('last_name'):
+ params['author'] = params.get('first_name') + " " + params.get('last_name')
+ else:
+ params['author'] = params.get('first_name',params.get('last_name'))
+ del(params['first_name'])
+ del(params['last_name'])
+
+ return( params )
+
+
class RestCollection(Collection):
''' Subclasses Collection to provide multiple responders '''
def __init__(self, queryset, responders=None, **kwargs):
@@ -43,6 +139,11 @@ def __call__(self, request, format, *args, **kwargs):
self.responder = self.responders[format]
try:
return Collection.__call__(self, request, *args, **kwargs)
+ except search.SearchAddressDisambiguateError, e:
+ return self.responder.error(request, 412, ErrorDict({
+ 'info': [str(e)],
+ 'possible_addresses': addrs }))
+
except InputValidationException, e:
errors = ErrorDict({'info': [str(e)]})
error_code = 412
@@ -52,68 +153,54 @@ def __call__(self, request, format, *args, **kwargs):
{'info': ['Requested content type "%s" not available!' %format]})
# Using the last used responder to return error
return self.responder.error(request, error_code, errors)
+
+class MobileReportRest(RestCollection):
-class CreateReportApi(RestCollection):
-
- def create(self, request, *args, **kwargs):
- #
- # Create a New Report
- #
- form = request.method == 'POST' and forms.ReportForm(request.POST) or forms.ReportForm()
- if request.method == 'POST' and form.is_valid():
- # lon = request.GET.get("lon")
- #lat = request.GET.get("lat")
- #address = request.GET.get("q")
-
- #report = form.save()
- if report:
- return HttpResponseCreated(request, request.build_absolute_uri())
- return self.render('create.html', request, {'form': form})
-
-class ReportRest(RestCollection):
-
+ api = MobileReportAPI()
+
def read(self, request):
- ids = request.GET.getlist("id")
- if ids:
- try:
- ids = [int(id) for id in ids]
- except (TypeError, ValueError), e:
- raise InputValidationException(str(e))
- reports = Report.objects.filter(id__in = ids)
- # process ids right now
- else:
- lon = request.GET.get("lon")
- lat = request.GET.get("lat")
- address = request.GET.get("q")
- if lat and lon:
- point_str = "POINT(%s %s)" %(lon, lat)
- elif address:
- addrs = []
- match_index = int(request.GET.get('index', -1))
- try:
- point_str = search.search_address(address, match_index, addrs)
- except search.SearchAddressDisambiguateError, e:
- return self.responder.error(request, 412, ErrorDict({
- 'info': [str(e)],
- 'possible_addresses': addrs }))
- else:
- raise InputValidationException('Must supply either a `q`, `lat` `lon`, or a report `id`')
+ reports = self.api.get(request)
+ return self.responder.list(request, reports)
- radius = float(request.GET.get('r', 4))
- pnt = fromstr(point_str, srid=4326)
- reports = Report.objects.filter(is_confirmed = True,point__distance_lte=(pnt,D(km=radius))).distance(pnt).order_by('distance')
+ def create(self, request, *args, **kwargs):
+ report = self.api.post(request)
+ return self.responder.list(request, report )
- return self.responder.list(request, reports)
+
-reports_rest = ReportRest(
+# These use the django-rest-api library.
+mobile_report_rest = MobileReportRest(
queryset=Report.objects.all(),
- permitted_methods = ('GET', 'POST'),
-# expose_fields = ('id','point'),
+ permitted_methods = ['GET', 'POST'],
+ expose_fields = MobileReportAPI.EXPOSE_FIELDS
)
-report_create = CreateReportApi(
- queryset=Report.objects.all(),
- permitted_methods = ('GET', 'POST'),
-# expose_fields = ('id','point'),
-)
+json_poll_resource = Collection(
+ queryset = ReportCategory.objects.all(),
+ expose_fields = ('id', 'name_en', 'name_fr'),
+ #permitted_methods = ('GET'),
+ responder = JSONResponder()
+)
+
+# These classes do not use the django-rest-api library
+
+class MobileReportAPIError(models.Model):
+ EXPOSE_FIELDS = ('error',)
+ error = models.CharField(max_length=255)
+
+def mobile_reports( request, format ):
+ api = MobileReportAPI()
+ supported_formats = [ 'xml','json' ]
+ if not format in supported_formats:
+ return( HttpResponse('Requested content type "%s" not available.'%format,status=415))
+ try:
+ if request.method == "POST":
+ to_serialize = api.post(request)
+ else:
+ to_serialize = api.get(request)
+ return( api.make_response(format,to_serialize,MobileReportAPIError.EXPOSE_FIELDS ) )
+ except Exception, e:
+ to_serialize = [ MobileReportAPIError(error=str(e)) ]
+ return( api.make_response(format,to_serialize,MobileReportAPIError.EXPOSE_FIELDS, status=412 ) )
+
66 mainapp/views/reports/main.py
View
@@ -7,37 +7,51 @@
from fixmystreet import settings
from django.utils.translation import ugettext as _
+def create_report( request, is_confirmed = False):
+ """
+ Helper method used by both internal and Open311 API.
+ """
+ pnt = fromstr("POINT(" + request.POST["lon"] + " " + request.POST["lat"] + ")", srid=4326)
+ update_form = ReportUpdateForm( request.POST )
+ report_form = ReportForm( request.POST, request.FILES )
+
+ # this is a lot more complicated than it has to be because of the information
+ # spread across two forms.
+
+ if request.POST['category_id'] != "" and update_form.is_valid() and report_form.is_valid():
+ report = report_form.save( commit = False )
+ update = update_form.save(commit=False)
+ #these are in the form for 'update'
+ report.desc = update.desc
+ report.author = update.author
+ #this is in neither form
+ report.category_id = request.POST['category_id']
+ #this info is custom
+ report.point = pnt
+ report.ward = Ward.objects.get(geom__contains=pnt)
+ report.is_confirmed = is_confirmed
+ update.report = report
+ update.first_update = True
+ update.is_confirmed = is_confirmed
+ update.created_at = report.created_at
+ report.save()
+ report.reportupdate_set.add(update)
+ report.save()
+ return( report )
+ else:
+ return None
def new( request ):
category_error = None
if request.method == "POST":
- pnt = fromstr("POINT(" + request.POST["lon"] + " " + request.POST["lat"] + ")", srid=4326)
- f = request.POST.copy()
- update_form = ReportUpdateForm( {'email':request.POST['email'], 'desc':request.POST['desc'],
- 'author':request.POST['author'], 'phone': request.POST['phone']})
- report_form = ReportForm({'title' : request.POST['title']}, request.FILES )
-
- # this is a lot more complicated than it has to be because of the infortmation
- # spread across two records.
-
- if request.POST['category_id'] != "" and update_form.is_valid() and report_form.is_valid():
- report = report_form.save( commit = False )
- report.point = pnt
- report.category_id = request.POST['category_id']
- report.author = request.POST['author']
- report.desc = request.POST['desc']
- report.ward = Ward.objects.get(geom__contains=pnt)
- report.save()
- update = update_form.save(commit=False)
- update.report = report
- update.first_update = True
- update.created_at = report.created_at
- update.save()
- return( HttpResponseRedirect( report.get_absolute_url() ))
-
- # other form errors are handled by the form objects.
- if not request.POST['category_id']:
+ # TOFIX:category ID is checked for separately as it's not part of the report form
+ if request.POST['category_id']:
+ report = create_report(request)
+ if report:
+ return( HttpResponseRedirect( report.get_absolute_url() ))
+ # otherwise, there was an error with one of the forms.
+ else:
category_error = _("Please select a category")
else:
10 mainapp/views/reports/updates.py
View
@@ -15,6 +15,13 @@ def new( request, report_id ):
update.save()
# redirect after a POST
return( HttpResponseRedirect( '/reports/updates/create/' ) )
+ else:
+ print "update not valid"
+ for field in update_form:
+ if field.errors:
+ print str(field)
+ print field.errors
+
else:
update_form = ReportUpdateForm()
@@ -55,7 +62,6 @@ def confirm( request, confirm_token ):
update.report.is_confirmed = True
update.report.save()
- update.send_emails()
-
+
# redirect to report
return( HttpResponseRedirect( update.report.get_absolute_url() ))
19 urls.py
View
@@ -85,24 +85,11 @@
# REST Urls
rest_format = r'(?P<format>\w+)'
-urlpatterns += patterns('mainapp.views.rest',
- url(r'^rest/reports.%s$'%rest_format, 'reports_rest'),
+urlpatterns += patterns('mainapp.views.mobile',
+ url(r'^mobile/reports.%s$'%rest_format, 'mobile_report_rest'),
+ url(r'^mobile/categories/(.*?)/?$', 'json_poll_resource'),
)
-urlpatterns += patterns('mainapp.views.rest',
- url(r'^rest/report/create/$', 'report_create',name='create'),
-)
-
-# Categories REST -- should move this to its rest.py
-json_poll_resource = Collection(
- queryset = ReportCategory.objects.all(),
- expose_fields = ('id', 'name_en', 'name_fr'),
- #permitted_methods = ('GET'),
- responder = JSONResponder()
-)
-urlpatterns += patterns('mainapp.views.rest',
- url(r'^rest/categories/(.*?)/?$', json_poll_resource),
-)
#The following is used to serve up local media files like images
#if settings.LOCAL_DEV:
Please sign in to comment.
Something went wrong with that request. Please try again.