Exemplo n.º 1
0
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')
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
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')
Exemplo n.º 5
0
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')
Exemplo n.º 6
0
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()
Exemplo n.º 7
0
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')