Exemplo n.º 1
0
def rest_repo_action(request, repo_name):
    # display repository info
    if request.method == 'GET':
        repo = Repository(repo_name)
        json_reply = jsonpickle.encode(repo, unpicklable=False)

        return HttpResponse(json_reply)

    # delete a repo
    if request.method == 'DELETE':
        repo = Repository(repo_name)
        # delete the repo
        repo.delete()
        return HttpResponse(repo.name + " has been deleted")
    if request.method == 'PUT':
        repo = Repository(repo_name)
        # retrieve data sent by the client
        raw_data = json.loads(request.raw_post_data)
        # retrieve the bare property
        bare = raw_data['bare']
        # if the repository needs to be imported

        if repo.bare == False and bare == True:
            # convert the repository
            repo.convert_to_bare()

            return HttpResponse("The repository was successfully imported.")

        return HttpResponseServerError(
            "The repository was not imported successfully.")
Exemplo n.º 2
0
def rest_repo_action(request, repo_name):
    # display repository info
    if request.method == 'GET':
        repo = Repository(repo_name)
        json_reply = jsonpickle.encode(repo, unpicklable = False)

        return HttpResponse(json_reply)

    # delete a repo
    if request.method == 'DELETE':
        repo = Repository(repo_name)
        # delete the repo
        repo.delete()
        return HttpResponse(repo.name + " has been deleted")
    if request.method == 'PUT':
        repo = Repository(repo_name)
        # retrieve data sent by the client
        raw_data = json.loads(request.raw_post_data)
        # retrieve the bare property
        bare = raw_data['bare']
        # if the repository needs to be imported
        
        if repo.bare == False and bare == True:
            # convert the repository
            repo.convert_to_bare()
            
            return HttpResponse("The repository was successfully imported.")
    
        return HttpResponseServerError("The repository was not imported successfully.")