mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Add edit urls to API results.
Change mic API lookup to profile
This commit is contained in:
@@ -323,7 +323,7 @@
|
|||||||
|
|
||||||
<input type="text" id="{{ form.mic.id_for_label }}-input"
|
<input type="text" id="{{ form.mic.id_for_label }}-input"
|
||||||
class="form-control autocomplete-json"
|
class="form-control autocomplete-json"
|
||||||
data-sourceurl="{% url 'api_secure' model='mic' %}?fields=first_name,last_name,initials"
|
data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials"
|
||||||
data-target="{{ form.mic.id_for_label }}"
|
data-target="{{ form.mic.id_for_label }}"
|
||||||
value="{{ object.mic.name|default_if_none:"" }}"/>
|
value="{{ object.mic.name|default_if_none:"" }}"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.http.response import HttpResponseRedirect
|
from django.http.response import HttpResponseRedirect
|
||||||
from django.http import HttpResponse
|
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.views import generic
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
@@ -193,7 +193,6 @@ class SecureAPIRequest(generic.View):
|
|||||||
'venue': models.Venue,
|
'venue': models.Venue,
|
||||||
'person': models.Person,
|
'person': models.Person,
|
||||||
'organisation': models.Organisation,
|
'organisation': models.Organisation,
|
||||||
'mic': models.Profile,
|
|
||||||
'profile': models.Profile,
|
'profile': models.Profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +200,6 @@ class SecureAPIRequest(generic.View):
|
|||||||
'venue': 'RIGS.view_venue',
|
'venue': 'RIGS.view_venue',
|
||||||
'person': 'RIGS.view_person',
|
'person': 'RIGS.view_person',
|
||||||
'organisation': 'RIGS.view_organisation',
|
'organisation': 'RIGS.view_organisation',
|
||||||
'mic': None,
|
|
||||||
'profile': None,
|
'profile': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,6 +251,12 @@ class SecureAPIRequest(generic.View):
|
|||||||
'value': o.pk,
|
'value': o.pk,
|
||||||
'label': o.name,
|
'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)
|
results.append(data)
|
||||||
json = simplejson.dumps(results[:20])
|
json = simplejson.dumps(results[:20])
|
||||||
return HttpResponse(json, content_type="application/json") # Always json
|
return HttpResponse(json, content_type="application/json") # Always json
|
||||||
|
|||||||
Reference in New Issue
Block a user