0.1.34
chat routines
This commit is contained in:
@@ -44,7 +44,7 @@ def chat_w_user_View(request, user_id=None):
|
|||||||
'page': 'chat',
|
'page': 'chat',
|
||||||
'cur_receiver': cur_receiver,
|
'cur_receiver': cur_receiver,
|
||||||
'receivers': receivers,
|
'receivers': receivers,
|
||||||
'cur_chat_msgs':cur_chat_msgs
|
'messages':cur_chat_msgs
|
||||||
}
|
}
|
||||||
|
|
||||||
t = loader.get_template('pages/profile/p_user_profile.html')
|
t = loader.get_template('pages/profile/p_user_profile.html')
|
||||||
|
|||||||
@@ -11,4 +11,5 @@ urlpatterns = [
|
|||||||
path('create_ticket/', create_ticket_ajax, name='create_ticket_ajax'),
|
path('create_ticket/', create_ticket_ajax, name='create_ticket_ajax'),
|
||||||
path('support_show_chat_by_ticket/', support_show_chat_by_ticket_ajax, name='support_show_chat_by_ticket_ajax'),
|
path('support_show_chat_by_ticket/', support_show_chat_by_ticket_ajax, name='support_show_chat_by_ticket_ajax'),
|
||||||
path('send_msg/', send_msg_ajax, name='send_msg_ajax'),
|
path('send_msg/', send_msg_ajax, name='send_msg_ajax'),
|
||||||
|
path('show_chat_w_user/', show_chat_w_user_ajax, name='show_chat_w_user_ajax'),
|
||||||
]
|
]
|
||||||
@@ -15,6 +15,34 @@ from .funcs import *
|
|||||||
import json
|
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/')
|
@login_required(login_url='/profile/login/')
|
||||||
def send_msg_ajax(request):
|
def send_msg_ajax(request):
|
||||||
from AuthApp.models import User
|
from AuthApp.models import User
|
||||||
|
|||||||
Reference in New Issue
Block a user