예제 #1
0
def registerAPI(request):
        if request.method == 'POST':
		form = APIForm(request.POST)
		if form.is_valid():
			data = form.save()
		        return HttpResponseRedirect('/')
	else:
		form = APIForm()
	return render(request, 'registerAPI.html', {'form': form})
예제 #2
0
def changeAPI(request):
	if request.user.is_staff:
		winkAPI = WinkAPI.objects.all()[0]	# Get API info
                if request.method == 'POST':
                        API_form = APIForm(data=request.POST, instance=winkAPI)
                        if API_form.is_valid():
                                API_form.save()
                        return HttpResponseRedirect('/')
                else:
                        API_form = APIForm(instance=winkAPI);	# Form for API 
			content = {
				'API_form': API_form,
			}
                        return render(request, 'changeAPI.html', content)

		return render(request, 'changeAPI.html', content)
	return HttpResponse(status=401)
예제 #3
0
def registerAPI(request):
    if request.method == 'POST':
        form = APIForm(request.POST)
        if form.is_valid():
            data = form.save()
            return HttpResponseRedirect('/')
    else:
        form = APIForm()
    return render(request, 'registerAPI.html', {'form': form})
예제 #4
0
def changeAPI(request):
    if request.user.is_staff:
        winkAPI = WinkAPI.objects.all()[0]  # Get API info
        if request.method == 'POST':
            API_form = APIForm(data=request.POST, instance=winkAPI)
            if API_form.is_valid():
                API_form.save()
            return HttpResponseRedirect('/')
        else:
            API_form = APIForm(instance=winkAPI)
            # Form for API
            content = {
                'API_form': API_form,
            }
            return render(request, 'changeAPI.html', content)

        return render(request, 'changeAPI.html', content)
    return HttpResponse(status=401)