From c954aa2497ed0e95c1ffc6fa3406dcac00a84f9d Mon Sep 17 00:00:00 2001 From: tomtom5152 Date: Sun, 29 Mar 2015 13:40:52 +0100 Subject: [PATCH] Add edit urls to API results. Change mic API lookup to profile --- RIGS/templates/RIGS/event_form.html | 2 +- RIGS/views.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/RIGS/templates/RIGS/event_form.html b/RIGS/templates/RIGS/event_form.html index 073cb027..c18db6f3 100644 --- a/RIGS/templates/RIGS/event_form.html +++ b/RIGS/templates/RIGS/event_form.html @@ -323,7 +323,7 @@ diff --git a/RIGS/views.py b/RIGS/views.py index 7c97c3b9..57feffaa 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -1,7 +1,7 @@ from django.core.exceptions import PermissionDenied from django.http.response import HttpResponseRedirect from django.http import HttpResponse -from django.core.urlresolvers import reverse_lazy +from django.core.urlresolvers import reverse_lazy, reverse, NoReverseMatch from django.views import generic from django.db.models import Q from django.shortcuts import get_object_or_404 @@ -193,7 +193,6 @@ class SecureAPIRequest(generic.View): 'venue': models.Venue, 'person': models.Person, 'organisation': models.Organisation, - 'mic': models.Profile, 'profile': models.Profile, } @@ -201,7 +200,6 @@ class SecureAPIRequest(generic.View): 'venue': 'RIGS.view_venue', 'person': 'RIGS.view_person', 'organisation': 'RIGS.view_organisation', - 'mic': None, 'profile': None, } @@ -253,6 +251,12 @@ class SecureAPIRequest(generic.View): 'value': o.pk, 'label': o.name, } + + try: # See if there is an update url or don't bother with it otherwise + data['update'] = reverse("%s_update" % model, kwargs={'pk': o.pk}) + except NoReverseMatch: + pass + results.append(data) json = simplejson.dumps(results[:20]) return HttpResponse(json, content_type="application/json") # Always json