chat routines
This commit is contained in:
SDE
2023-08-06 15:22:52 +03:00
parent 5ce185cf01
commit 8c2043198f
3 changed files with 30 additions and 1 deletions

View File

@@ -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