0.1.34
chat routines
This commit is contained in:
@@ -15,6 +15,34 @@ from .funcs import *
|
||||
import json
|
||||
|
||||
|
||||
@login_required(login_url='/profile/login/')
|
||||
def show_chat_w_user_ajax(request):
|
||||
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
from AuthApp.models import User
|
||||
cur_receiver = User.objects.get(id=data['user_id'])
|
||||
|
||||
Dict = {
|
||||
'cur_receiver': cur_receiver,
|
||||
'messages': get_msgs_for_chat_w_users(request.user, cur_receiver),
|
||||
}
|
||||
|
||||
tpl_name = 'blocks/profile/b_chats.html'
|
||||
|
||||
html = render_to_string(tpl_name, Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
except Exception as e:
|
||||
msg = f'show_chat_w_user_ajax Error = {str(e)}'
|
||||
return JsonResponse({'error': msg}, status=400)
|
||||
|
||||
|
||||
@login_required(login_url='/profile/login/')
|
||||
def send_msg_ajax(request):
|
||||
from AuthApp.models import User
|
||||
|
||||
Reference in New Issue
Block a user