예제 #1
0
파일: views.py 프로젝트: maanas/wwwhisper
 def get(self, request):
     """Returns json representation of all resources in the collection."""
     items_list = [item.attributes_dict() for item in self.collection.all()]
     return http.HttpResponseOKJson({
             'self' : full_url(request.path),
             self.collection.collection_name: items_list
             })
예제 #2
0
파일: views.py 프로젝트: maanas/wwwhisper
    def put(self, request, location_uuid):
        """Creates a resource that enables open access to a given location."""
        location = self.locations_collection.find_item(location_uuid)
        if location is None:
            return http.HttpResponseNotFound('Location not found.')
        if location.open_access:
            return http.HttpResponseOKJson(self._attributes_dict(request))

        location.grant_open_access()
        response =  http.HttpResponseCreated(self._attributes_dict(request))
        response['Location'] = full_url(request.path)
        return response
예제 #3
0
파일: views.py 프로젝트: maanas/wwwhisper
 def _attributes_dict(request):
     """Attributes representing a resource to which a request is related."""
     return {'self' : full_url(request.path)}