def post(self, request): user_id = request.POST["user_id"] chat_type = request.POST["chat_type"] customer = User.objects.get(id=user_id) name = uuid.uuid4().hex[:16].upper() new_chat_room = ChatRoom() new_chat_room.name = name new_chat_room.customer = customer new_chat_room.type = chat_type new_chat_room.status = "on_queue" new_chat_room.save() return JsonResponse({'chat_room_name': name})
def create_room(request, main): """ Create a chat room for a game after going to the index page """ request.user.profile.save() name = request.POST.get('Enter a New Room Name') try: if name.strip(): request.user.profile.own_room = True request.user.profile.save() new_room = ChatRoom() new_room.name = name new_room.owner = request.user.profile new_room.main = main new_room.save() QUEUES[name] = {} return redirect('/chat/room/' + str(new_room.pk)) except IntegrityError, AttributeError: pass