Example #1
0
def unpark(request):
    if request.method == 'GET':
        form = UnparkForm(request.POST)
        if form.is_valid():
            url = createurl(UNPARKURL)
            id = form.cleaned_data['id']
            response = json.loads(requests.delete(url=url, params=id)._content)
            context = {'data': response}
            return render(request, 'park.html', context)
    else:
        form = UnparkForm()

    return render(request, 'form.html', {'link': 'unpark-form', 'form': form})
Example #2
0
def search(request):
    if request.method == 'POST':
        form = SearchForm(request.POST)
        if form.is_valid():
            url = createurl(SEARCHURL)
            params = {(k, v) for k, v in form.cleaned_data.iteritems() if v}
            response = json.loads(
                requests.get(url=url, params=params)._content)
            context = {'data': response}
            return render(request, 'park.html', context)

    # if a GET (or any other method) we'll create a blank form
    else:
        form = SearchForm()

    return render(request, 'form.html', {'link': 'search-form', 'form': form})
def park(request):
    if request.method == "POST":
        form = ParkForm(request.POST)
        if form.is_valid():
            url = createurl(PARKURL)
            # print url
            # print form.cleaned_data
            response = json.loads(requests.post(url=url, data=json.dumps(form.cleaned_data))._content)
            removekey(response, "status")
            context = dict(data=response)
            return render(request, "park.html", context)

    # if a GET (or any other method) we'll create a blank form
    else:
        form = ParkForm()

    return render(request, "form.html", {"link": "park-form", "form": form})
def unpark(request):
    if request.method == 'GET':
        form = UnparkForm(request.POST)
        if form.is_valid():
            url=createurl(UNPARKURL)
            print url
            print form.cleaned_data, type(form.cleaned_data)
            id = form.cleaned_data['id']
            response = json.loads(requests.delete(url=url, params=id)._content)
            print "Response", response, type(response)
            context= dict(data=response)
            # print context , type(context)
            return render(request, 'park.html', context)
    else:
        form = UnparkForm()

    return render(request, 'form.html', {'link': 'unpark-form', 'form': form})
def park(request):
    if request.method == 'POST':
        form = ParkForm(request.POST)
        if form.is_valid():
            url = createurl(PARKURL)
            response = json.loads(
                requests.post(url=url,
                              data=json.dumps(form.cleaned_data))._content)
            removekey(response, 'status')
            context = {'data': response}
            return render(request, 'park.html', context)

    # if a GET (or any other method) we'll create a blank form
    else:
        form = ParkForm()

    return render(request, 'form.html', {'link': 'park-form', 'form': form})
def search(request):
    if request.method == 'POST':
        form = SearchForm(request.POST)
        if form.is_valid():
            url=createurl(SEARCHURL)
            print url
            print form.cleaned_data, type(form.cleaned_data)
            params = dict((k, v) for k, v in form.cleaned_data.iteritems() if v)
            print "Non-Empty", params
            # response = requests.get(url=url,params=params)._content
            response = json.loads(requests.get(url=url, params=params)._content)
            # print "Response", response, type(response)
            context= dict(data=response)
            # print context , type(context)
            return render(request, 'park.html', context)

    # if a GET (or any other method) we'll create a blank form
    else:
        form = SearchForm()

    return render(request, 'form.html', {'link': 'search-form', 'form': form})