Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -5,7 +5,7 @@ from django.core.exceptions import ValidationError
|
|||||||
from .models import *
|
from .models import *
|
||||||
|
|
||||||
|
|
||||||
class CreateTicketForm(forms.ModelForm):
|
class TicketForm(forms.ModelForm):
|
||||||
text = forms.CharField(required=True)
|
text = forms.CharField(required=True)
|
||||||
# files = forms.CharField(required=True)
|
# files = forms.CharField(required=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ from django.contrib.auth import views
|
|||||||
from RoutesApp.js_views import new_route_view_ajax
|
from RoutesApp.js_views import new_route_view_ajax
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('support_create_ticket_ajax/', support_create_ticket_ajax, name='support_create_ticket_ajax'),
|
path('support_create_ticket_form/', support_create_ticket_form_ajax, name='support_create_ticket_form_ajax'),
|
||||||
|
path('create_ticket/', create_ticket_ajax, name='create_ticket_ajax'),
|
||||||
# path('create_/', registration_ajax, name='registration_ajax'),
|
# path('create_/', registration_ajax, name='registration_ajax'),
|
||||||
|
|
||||||
]
|
]
|
||||||
@@ -13,7 +13,7 @@ from django.template.loader import render_to_string
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
@login_required(login_url='/profile/login/')
|
@login_required(login_url='/profile/login/')
|
||||||
def support_create_ticket_ajax(request):
|
def support_create_ticket_form_ajax(request):
|
||||||
from ChatServiceApp.forms import CreateTicketForm
|
from ChatServiceApp.forms import CreateTicketForm
|
||||||
|
|
||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
@@ -24,4 +24,52 @@ def support_create_ticket_ajax(request):
|
|||||||
}
|
}
|
||||||
|
|
||||||
html = render_to_string('blocks/profile/b_create_ticket.html', Dict, request=request)
|
html = render_to_string('blocks/profile/b_create_ticket.html', Dict, request=request)
|
||||||
return JsonResponse({'html': html}, status=200)
|
return JsonResponse({'html': html}, status=200)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url='/profile/login/')
|
||||||
|
def create_ticket_ajax(request):
|
||||||
|
from ChatServiceApp.forms import TicketForm
|
||||||
|
|
||||||
|
if request.method != 'POST':
|
||||||
|
raise Http404
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
data = request.POST
|
||||||
|
|
||||||
|
form = TicketForm(data)
|
||||||
|
if not form.is_valid():
|
||||||
|
form.initial = form.cleaned_data
|
||||||
|
Dict = {'form': form}
|
||||||
|
html = render_to_string('blocks/profile/b_create_ticket.html', Dict, request=request)
|
||||||
|
return JsonResponse({'html': html}, status=400)
|
||||||
|
|
||||||
|
obj = form.save(commit=False)
|
||||||
|
obj.owner = request.user
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
Dict = {
|
||||||
|
'ticket': obj
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
html = render_to_string('blocks/profile/b_support_chat.html', Dict, request=request)
|
||||||
|
|
||||||
|
res_Dict = {
|
||||||
|
'html': html
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonResponse(res_Dict)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
|
||||||
|
errors_Dict = {
|
||||||
|
'errors': {
|
||||||
|
'all__': f'ошибка в запросе = {str(e)}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Dict = {'form': errors_Dict}
|
||||||
|
html = render_to_string('blocks/profile/b_create_ticket.html', Dict, request=request)
|
||||||
|
return JsonResponse({'html': html}, status=400)
|
||||||
|
|
||||||
|
|||||||
@@ -141,8 +141,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.create-ticket-file{
|
.create-ticket-file{
|
||||||
display: block;
|
display: none;
|
||||||
opacity: 0;
|
/*opacity: 0;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-create-tickets-btns{
|
.form-create-tickets-btns{
|
||||||
@@ -263,9 +263,55 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.footer-chat{
|
.footer-chat{
|
||||||
width: 100%;
|
width: calc(100% - 40px);
|
||||||
height: 60px;
|
height: 20px;
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
border: 1px solid #E6E6E6;
|
border: 1px solid #E6E6E6;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-part-block-enter-message{
|
||||||
|
width: 90%;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enter-message-inp{
|
||||||
|
color: #000000;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: none;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.attach-file-btn-message{
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
background: url("/static/img/svg/attach-file.svg");
|
||||||
|
background-size: 24px;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.send-message{
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
background: url("/static/img/svg/send_btn.svg");
|
||||||
|
background-size: 40px;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.errors{
|
||||||
|
color: red;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.errors_all{
|
||||||
|
font-size: 11px;
|
||||||
|
color: #ffb3b3;
|
||||||
|
float: left;
|
||||||
}
|
}
|
||||||
5
static/img/svg/attach-file.svg
Normal file
5
static/img/svg/attach-file.svg
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g id="filled/editor/attach-file">
|
||||||
|
<path id="Vector" d="M16.5 6V17.5C16.5 19.71 14.71 21.5 12.5 21.5C10.29 21.5 8.5 19.71 8.5 17.5V5C8.5 3.62 9.62 2.5 11 2.5C12.38 2.5 13.5 3.62 13.5 5V15.5C13.5 16.05 13.05 16.5 12.5 16.5C11.95 16.5 11.5 16.05 11.5 15.5V6H10V15.5C10 16.88 11.12 18 12.5 18C13.88 18 15 16.88 15 15.5V5C15 2.79 13.21 1 11 1C8.79 1 7 2.79 7 5V17.5C7 20.54 9.46 23 12.5 23C15.54 23 18 20.54 18 17.5V6H16.5Z" fill="#272424" fill-opacity="0.6"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 565 B |
4
static/img/svg/send_btn.svg
Normal file
4
static/img/svg/send_btn.svg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="40" height="40" rx="10" fill="#FF613A"/>
|
||||||
|
<path d="M10.01 29L31 20L10.01 11L10 18L25 20L10 22L10.01 29Z" fill="white"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 235 B |
@@ -1,7 +1,7 @@
|
|||||||
function createTicketShow () {
|
function createTicketShow () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||||||
url: '/ru/user_account/support_create_ticket_ajax/',
|
url: '/ru/messages/support_create_ticket_form/',
|
||||||
type: "POST",
|
type: "POST",
|
||||||
// async: true,
|
// async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
@@ -29,6 +29,22 @@ function countLetters () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// var input;
|
||||||
|
|
||||||
|
|
||||||
|
function inputQuest (){
|
||||||
|
event.preventDefault()
|
||||||
|
// let input = document.querySelector(".create-ticket-file")
|
||||||
|
let input = document.createElement("input");
|
||||||
|
input.setAttribute("type", "file")
|
||||||
|
input.style.display = "none"
|
||||||
|
input.click()
|
||||||
|
// console.log("asd")
|
||||||
|
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function attachFileCreateTicket () {
|
function attachFileCreateTicket () {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
let input = document.querySelector(".create-ticket-file")
|
let input = document.querySelector(".create-ticket-file")
|
||||||
@@ -54,61 +70,50 @@ function attachFileCreateTicket () {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function attachFilemeassge () {
|
||||||
|
let input = inputQuest()
|
||||||
|
let file = input.files[0]
|
||||||
|
// let file_url = URL.createObjectURL(file)
|
||||||
|
|
||||||
// $( "#slider-range" ).slider({
|
|
||||||
// range: true,
|
|
||||||
// min: 0,
|
let data = file
|
||||||
// max: 1000,
|
$.ajax({
|
||||||
// values: [ 0, 1000 ],
|
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||||||
// step: 1,
|
url: '/ru/user_account/support_create_ticket_ajax/',
|
||||||
// slide: function( event, ui ) {
|
type: "POST",
|
||||||
// $( "#control-price-1" ).val(ui.values[ 0 ]);
|
// async: true,
|
||||||
// $( "#control-price-2" ).val( ui.values[ 1 ] );
|
cache: false,
|
||||||
// }
|
processData: false,
|
||||||
// });
|
contentType: false,
|
||||||
// $( "#control-price-1" ).val($( "#slider-range" ).slider( "values", 0 ));
|
// enctype: 'json',
|
||||||
// $( "#control-price-2" ).val($( "#slider-range" ).slider( "values", 1 ));
|
data: data,
|
||||||
//
|
success: function(data){
|
||||||
//
|
|
||||||
//
|
document.querySelector(".insert-tech-place").innerHTML = data.html;
|
||||||
// function set_range(obj) {
|
|
||||||
// let parent = $(obj).parents('.input-control-price')[0];
|
},
|
||||||
// let min_obj = $(parent).find('#control-price-1')[0];
|
});
|
||||||
// let max_obj = $(parent).find('#control-price-2')[0];
|
input.remove()
|
||||||
// var valmin = min_obj.value;
|
}
|
||||||
// var valmax = max_obj.value;
|
|
||||||
//
|
function createTicket (el) {
|
||||||
// if (min_obj === obj) {
|
let form = el.form
|
||||||
// if (valmin < 0){
|
let formData = new formData (form)
|
||||||
// valmin = 0
|
$.ajax({
|
||||||
// }
|
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||||||
// else if (valmin > 1000){
|
url: '/ru/user_account/support_create_ticket_ajax/',
|
||||||
// valmin = 1000
|
type: "POST",
|
||||||
// }
|
// async: true,
|
||||||
// else if (valmin > valmax){
|
cache: false,
|
||||||
// valmin = valmax
|
processData: false,
|
||||||
// }
|
contentType: false,
|
||||||
// $(parent).find('#control-price-1')[0].value = valmin;
|
// enctype: 'json',
|
||||||
// } else if (max_obj === obj) {
|
data: formData,
|
||||||
// if (valmax > 1000) {
|
success: function(data){
|
||||||
// valmax = 1000
|
|
||||||
// }
|
document.querySelector(".insert-tech-place").innerHTML = data.html;
|
||||||
// else if (valmax < 1) {
|
|
||||||
// valmax = 1
|
},
|
||||||
// }
|
});
|
||||||
// else if (valmax < valmin) {
|
}
|
||||||
// valmax = valmin
|
|
||||||
// }
|
|
||||||
// $(parent).find('#control-price-2')[0].value = valmax;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// $("#slider-range" ).slider({
|
|
||||||
// values: [parseInt(valmin), parseInt(valmax)]
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -1,26 +1,37 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
<form class="form-create-ticket" name="create-ticket">
|
<form class="form-create-ticket" name="create-ticket">
|
||||||
|
|
||||||
|
{% if errors.all__ %}<div class="errors_all" style="margin-bottom: 12px;width: 100%;font-size: 16px;">{{ errors.all__ }}</div>{% endif %}
|
||||||
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<select name="department"
|
<select name="department"
|
||||||
id="id_department"
|
id="id_department"
|
||||||
class="el-form-create-ticket">
|
class="el-form-create-ticket">
|
||||||
|
<option>Отдел: Техническая поддержка</option>
|
||||||
</select>
|
</select>
|
||||||
|
{% if form.errors.department %}<div class="errors">{{ form.errors.department }}</div>{% endif %}
|
||||||
<input type="text"
|
<input type="text"
|
||||||
class="el-form-create-ticket"
|
class="el-form-create-ticket"
|
||||||
name="name"
|
name="name"
|
||||||
id="id_name"
|
id="id_name"
|
||||||
placeholder="Тема запроса"
|
placeholder="Тема запроса"
|
||||||
|
value="{% if form.adding_machine.name %}{{ form.adding_machine.name }}{% endif %}"
|
||||||
>
|
>
|
||||||
|
{% if form.errors.name %}<div class="errors">{{ form.errors.name }}</div>{% endif %}
|
||||||
|
|
||||||
<div class="letrs-count" style="color: #27242499;position: relative;top: 20px;left: 780px;display: inline-block;"><span class="letrs-count-span">0</span><span>/500</span></div>
|
<div class="letrs-count" style="color: #27242499;position: relative;top: 20px;left: 780px;display: inline-block;"><span class="letrs-count-span">0</span><span>/500</span></div>
|
||||||
<textarea name="text"
|
<textarea name="text"
|
||||||
id="id_text"
|
id="id_text"
|
||||||
class="el-form-create-ticket-textarea"
|
class="el-form-create-ticket-textarea"
|
||||||
placeholder="Введите сообщение..."
|
placeholder="Введите сообщение..."
|
||||||
|
value="{% if form.adding_machine.text %}{{ form.adding_machine.text }}{% endif %}"
|
||||||
onkeyup="countLetters()"></textarea>
|
onkeyup="countLetters()"></textarea>
|
||||||
|
{% if form.errors.text %}<div class="errors">{{ form.errors.text }}</div>{% endif %}
|
||||||
|
|
||||||
<div class="form-create-tickets-btns">
|
<div class="form-create-tickets-btns">
|
||||||
<button class="create-ticket-btn">Создать тикет</button>
|
<button class="create-ticket-btn" onclick="createTicket()">Создать тикет</button>
|
||||||
<button class="attach-file-btn" onclick="attachFileCreateTicket()"></button>
|
<button class="attach-file-btn" onclick="attachFileCreateTicket()"></button>
|
||||||
<input class="create-ticket-file" type="file" value="">
|
{# <input class="create-ticket-file" type="file" value="">#}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -20,12 +20,12 @@
|
|||||||
{% include "widgets/w_message.html" %}
|
{% include "widgets/w_message.html" %}
|
||||||
</div>
|
</div>
|
||||||
<div class="footer-chat">
|
<div class="footer-chat">
|
||||||
<div>
|
<div class="left-part-block-enter-message">
|
||||||
|
<input class="enter-message-inp" placeholder="Отправить сообщение">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="right-part-block-enter-message">
|
||||||
<img>
|
<button class="attach-file-btn-message" onclick="attachFilemeassge()"></button>
|
||||||
<button></button>
|
<button class="send-message"></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -34,5 +34,6 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
1
templates/blocks/profile/b_support_chat.html
Normal file
1
templates/blocks/profile/b_support_chat.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{% load static %}
|
||||||
Reference in New Issue
Block a user