0.1.21
send msg
This commit is contained in:
@@ -14,6 +14,56 @@ from django.urls import reverse
|
|||||||
from .funcs import *
|
from .funcs import *
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url='/profile/login/')
|
||||||
|
def send_msg_ajax(request):
|
||||||
|
from AuthApp.models import User
|
||||||
|
|
||||||
|
if request.method != 'POST':
|
||||||
|
raise Http404
|
||||||
|
|
||||||
|
res_Dict = {}
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
data = json.loads(request.body)
|
||||||
|
ticket = None
|
||||||
|
|
||||||
|
if data['text']:
|
||||||
|
|
||||||
|
|
||||||
|
if 'ticket_id' in data:
|
||||||
|
ticket = MsgGroup.objects.get(id=data['ticket_id'])
|
||||||
|
|
||||||
|
kwargs = {
|
||||||
|
'sender': User.objects.get(id=data['sender']),
|
||||||
|
'receiver': User.objects.get(id=data['receiver']),
|
||||||
|
'text': data['text']
|
||||||
|
}
|
||||||
|
|
||||||
|
if ticket:
|
||||||
|
kwargs.update({'group': ticket})
|
||||||
|
|
||||||
|
msg = Message.objects.create(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res_Dict.update({
|
||||||
|
'ticket': ticket
|
||||||
|
})
|
||||||
|
|
||||||
|
tpl_name = 'blocks/profile/b_support_chat.html'
|
||||||
|
|
||||||
|
html = render_to_string(tpl_name, res_Dict, request=request)
|
||||||
|
return JsonResponse({'html': html}, status=200)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
msg = f'send_msg_ajax Error = {str(e)}'
|
||||||
|
return JsonResponse({'error': msg}, status=400)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url='/profile/login/')
|
@login_required(login_url='/profile/login/')
|
||||||
def support_show_chat_by_ticket_ajax(request):
|
def support_show_chat_by_ticket_ajax(request):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user