Ejemplo n.º 1
0
def update_registry_info(request):
    if request.method == 'POST':
        try:
            #Get the ID
            registry_id = request.POST['registry_id']
            #Call the API to update information
            try:
                update_registry_info_model(registry_id)
                return HttpResponse(json.dumps({}), content_type='application/javascript')
            except OAIAPIException as e:
                return HttpResponseBadRequest(e.message)
            except Exception as e:
                return HttpResponseBadRequest('An error occurred. Please contact your administrator.')
        except Exception as e:
            return HttpResponseBadRequest('An error occurred. Please contact your administrator.')
Ejemplo n.º 2
0
def update_registry(registryId):
     try:
        #Update the registry information
        req = update_registry_info_model(registryId)
        data = req.data
        return "Message: {!s}, Status code: {!s}".format(data[APIMessage.label], str(req.status_code))

     except Exception as e:
        return e.message
Ejemplo n.º 3
0
def update_registry_info(request):
    """
    PUT http://localhost/oai_pmh/api/update/registry-info
    PUT data query='{"registry_id":"value"}'
    id: string
    """
    try:
        #Serialization of the input data
        serializer = UpdateRegistryInfo(data=request.DATA)
        if serializer.is_valid():
            registry_id = request.DATA['registry_id']
            return update_registry_info_model(registry_id)
        else:
            raise OAIAPISerializeLabelledException(errors=serializer.errors,
                                          status=status.HTTP_400_BAD_REQUEST)
    except OAIAPIException as e:
        return e.response()
    except Exception as e:
        content = APIMessage.getMessageLabelled('Unable to update the registry information.')
        return Response(content, status=status.HTTP_500_INTERNAL_SERVER_ERROR)