示例#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)