def init(request): if not request.method == 'POST': return HttpResponseBadRequest('Error: Request method must be POST') if not 'user' in request.POST: return HttpResponseBadRequest('Error: You must provide a state') c = Chatter.objects.filter(name__exact=request.POST['user']).delete() c = Chatter(name=request.POST['user']) c.save() u = expired_users(c) return HttpResponse(c.id)
def updateUserlist(request): if not request.method == 'POST': return HttpResponseBadRequest('Error: Request method must be POST') if not 'userid' in request.POST: return HttpResponseBadRequest('Error: You must provide a userid') try: c = Chatter.objects.get(pk=request.POST['userid']) except Chatter.DoesNotExist: return HttpResponse('{ "error": "true" }') c.save() u = expired_users(c) serializer = serializers.get_serializer('json')() return HttpResponse(serializer.serialize(u))