Skip to content

Commit

Permalink
Fix: fixed the url to view resource
Browse files Browse the repository at this point in the history
  • Loading branch information
NegarehMir committed Aug 3, 2016
1 parent 6a501a6 commit a7735c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rodan/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
url(r'^inputport/(?P<pk>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', InputPortDetail.as_view(), name="inputport-detail"),
url(r'^resources/$', ResourceList.as_view(), name="resource-list"),
url(r'^resource/(?P<pk>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', ResourceDetail.as_view(), name="resource-detail"),
url(r'^resource/(?P<pk>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/viewer/(?P<working_user_token>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', ResourceViewer.as_view(), name="resource-viewer"),
url(r'^resource/(?P<resource_uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/(?P<working_user_token>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', ResourceViewer.as_view(), name="resource-viewer"),
url(r'^resource/(?P<resource_uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/acquire/$', ResourceAcquireView.as_view(), name='resource-viewer-acquire'),
url(r'^resourcelists/$', ResourceListList.as_view(), name="resourcelist-list"),
url(r'^resourcelist/(?P<pk>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', ResourceListDetail.as_view(), name="resourcelist-detail"),
Expand Down
6 changes: 3 additions & 3 deletions rodan/views/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ class ResourceViewer(APIView):

def get(self, request, resource_uuid, working_user_token, *a, **k):
# check expiry
working_user_expiry = 0
working_user_expiry = Tempauthtoken.objects.get(uuid=working_user_token).expiry
if timezone.now() > working_user_expiry:
raise CustomAPIException({'message': 'Permission denied'}, status=status.HTTP_401_UNAUTHORIZED)

resource = self.get_object()
resource = Resource.objects.get(uuid=resource_uuid)
viewer = resource.get_viewer()
if viewer == 'diva':
return render(request, 'diva.html', {
Expand Down Expand Up @@ -242,6 +242,6 @@ def post(self, request, resource_uuid, *args, **kwargs):
working_user_token = temp_token.uuid

return Response({
'working_url': request.build_absolute_uri(reverse('resource-viewer', kwargs={'pk': str(resource_uuid), 'working_user_token': str(working_user_token)})),
'working_url': request.build_absolute_uri(reverse('resource-viewer', kwargs={'resource_uuid': str(resource_uuid), 'working_user_token': str(working_user_token)})),
'working_user_expiry': expiry_date
})

0 comments on commit a7735c1

Please sign in to comment.