Skip to content

Commit ac09b56

Browse files
author
Massimiliano Pippi
committed
use client_id as lookup for applications in the api
1 parent 7979c65 commit ac09b56

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

example/example/api_v1.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ def applications_list(request, *args, **kwargs):
6868
@csrf_exempt
6969
@protected_resource()
7070
@require_http_methods(["GET", "PUT", "DELETE"])
71-
def applications_detail(request, pk, *args, **kwargs):
71+
def applications_detail(request, lookup, *args, **kwargs):
7272
"""
7373
Show resource with GET, update it with PUT, destroy with DELETE
7474
"""
7575
try:
76-
resource = MyApplication.objects.filter(user=request.resource_owner).filter(pk=pk).get()
76+
resource = MyApplication.objects.filter(user=request.resource_owner)\
77+
.filter(client_id=lookup).get()
7778
# hide default Application in the playground
7879
if resource.pk == 1:
7980
raise MyApplication.DoesNotExist

example/example/templates/example/api-client.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ <h3>POST /applications</h3>
7979
<li>authorization_grant_type (required, values: [authorization-code,implicit,passwordl,client-credentials,all-in-one]) - Authorization flow</li>
8080
</ul>
8181

82-
<h3>GET /applications/:pk</h3>
82+
<h3>GET /applications/:lookup</h3>
8383
<p>Retrieve Application detail</p>
8484
<p><strong>Authentication:</strong> OAuth2</p>
8585

86-
<h3>PUT /applications/:pk</h3>
86+
<h3>PUT /applications/:lookup</h3>
8787
<p>Update Application details</p>
8888
<p><strong>Authentication:</strong> OAuth2</p>
8989
<p>Parameters: same as application creation</p>
9090

91-
<h3>DELETE /applications/:pk</h3>
91+
<h3>DELETE /applications/:lookup</h3>
9292
<p>Delete application</p>
9393
<p><strong>Authentication:</strong> OAuth2</p>
9494

@@ -111,7 +111,7 @@ <h3>DELETE /applications/:pk</h3>
111111

112112
var getUrl = function() {
113113
var url = $('#idEndpoint').val();
114-
url = url.replace('pk', $('#idLookup').val());
114+
url = url.replace('lookup', $('#idLookup').val());
115115
return url;
116116
};
117117

example/example/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@
6565
# api v1
6666
url(r'^api/v1/system_info$', get_system_info, name="System Info"),
6767
url(r'^api/v1/applications$', applications_list, name="Application List"),
68-
url(r'^api/v1/applications/(?P<pk>\w+)/$', applications_detail, name="Application Detail"),
68+
url(r'^api/v1/applications/(?P<lookup>\w+)/$', applications_detail, name="Application Detail"),
6969
)

0 commit comments

Comments
 (0)