def add(request): error = '' response = '' status = 201 if request.method == 'POST': data = request.POST.copy() if not request.user.is_authenticated(): status = 401 error += 'Unauthorized creation of restroom. Please log in.\n' else: t = Toilet() data['date'] = currentTime() data['creator'] = request.user info = AdditionalUserInfo.objects.get(user=request.user) if info.male == False and info.female == False: data['male'] = True data['male'] = True else: data['male'] = info.male data['female'] = info.female t.setattrs(data) t.save() response = serialize([t]) else: error += 'No POST data in request.\n' status = 415 return HttpResponse(package_error(response,error), status=status)
def add(request): error = '' response = '' status = 201 if request.method == 'POST': data = request.POST.copy() if not request.user.is_authenticated(): status = 401 error += 'Unauthorized creation of restroom. Please log in.\n' else: t = Toilet() data['date'] = currentTime() data['creator'] = request.user t.setattrs(data) t.save() response = serialize([t]) else: error += 'No POST data in request.\n' status = 415 return HttpResponse(package_error(response,error), status=status)