def NewConversation(request, username): from_user = request.user body = 'A NEW CONVERSATION HAS STARTED' try: to_user = User.objects.get(username=username) except Exception as e: return redirect('usersearch') if from_user != to_user: Message.send_message(from_user, to_user, body) return redirect('inbox')
def SendDirect(request): from_user = request.user to_user_username = request.POST.get('to_user') body = request.POST.get('body') if request.method == 'POST': to_user = User.objects.get(username=to_user_username) Message.send_message(from_user, to_user, body) return redirect('inbox') else: HttpResponseBadRequest()
def SendDirect(request): from_user = request.user to_user_username = request.POST.get('to_user') body = request.POST.get('body') if request.method == 'POST': to_user = get_object_or_404(User, username=to_user_username) Message.send_message(from_user, to_user, body) return HttpResponseRedirect(reverse('directs', args=[to_user_username])) else: HttpResponseBadRequest()
def NewConversation(request, username): from_user = request.user body = '' try: to_user = User.objects.get(username=username) except Exception as e: return redirect('usersearch') #prevent user from sending themselves a message if from_user != to_user: Message.send_message(from_user, to_user, body) return redirect('inbox')
def NewConversation( request, username): # from search results of users send one user a message from_user = request.user body = '' try: to_user = User.objects.get(username=username) except Exception as e: return redirect('user_search') if from_user != to_user: Message.send_message(from_user, to_user, body) return redirect('inbox')
def SendDirect( request ): # brings messages from another user into the inbox and conversation sections from_user = request.user to_user_username = request.POST.get('to_user') body = request.POST.get('body') if request.method == 'POST': to_user = User.objects.get(username=to_user_username) Message.send_message(from_user, to_user, body) return redirect('inbox') else: HttpResponseBadRequest()
def reportIssue(request): from_user = request.user body = 'A NEW CONVERSATION HAS STARTED' if from_user != 'admin': Message.send_message(from_user, 'admin', body) return redirect('inbox')