edit_route fixed
This commit is contained in:
SDE
2023-08-01 19:56:09 +03:00
parent 586428b857
commit 0b35e91159
6 changed files with 33 additions and 12 deletions

View File

@@ -40,7 +40,11 @@ def support_tickets_ajax(request):
if request.method != 'POST': if request.method != 'POST':
raise Http404 raise Http404
from ChatServiceApp.models import MsgGroup
tickets = MsgGroup.objects.filter(enable=True, owner=request.user)
Dict = { Dict = {
'tickets': tickets
} }
html = render_to_string('blocks/profile/b_support_tickets.html', Dict, request=request) html = render_to_string('blocks/profile/b_support_tickets.html', Dict, request=request)

View File

@@ -52,6 +52,7 @@ def create_ticket_ajax(request):
obj = form.save(commit=False) obj = form.save(commit=False)
obj.owner = request.user obj.owner = request.user
obj.enable = True
obj.save() obj.save()
Dict = { Dict = {

View File

@@ -5,8 +5,9 @@ from django.urls import path
from .js_views import * from .js_views import *
urlpatterns = [ urlpatterns = [
path('change_route/<int:route_id>/', create_or_change_route_ajax, name='change_route_ajax'),
path('create_or_change_route/', create_or_change_route_ajax, name='create_or_change_route_ajax'), path('create_or_change_route/', create_or_change_route_ajax, name='create_or_change_route_ajax'),
path('create_or_change_route/<int:route_id>/', create_or_change_route_ajax, name='change_route_ajax'),
path('edit_route/', edit_route_ajax, name='edit_route_ajax'), path('edit_route/', edit_route_ajax, name='edit_route_ajax'),
path('get_routes/', get_routes_ajax, name='get_routes_ajax'), path('get_routes/', get_routes_ajax, name='get_routes_ajax'),

View File

@@ -182,6 +182,8 @@ def create_or_change_route_ajax(request, route_id):
if request.method != 'POST': if request.method != 'POST':
raise Http404 raise Http404
Dict = {}
try: try:
data = request.POST data = request.POST
@@ -192,12 +194,14 @@ def create_or_change_route_ajax(request, route_id):
if route: if route:
form = RouteForm(data, instance=route) form = RouteForm(data, instance=route)
Dict.update({'route': route})
else: else:
form = RouteForm(data) form = RouteForm(data)
if not form.is_valid(): if not form.is_valid():
form.initial = form.cleaned_data form.initial = form.cleaned_data
Dict = {'form': form} Dict.update({'form': form})
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request) html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
return JsonResponse({'html': html}, status=400) return JsonResponse({'html': html}, status=400)
@@ -209,7 +213,7 @@ def create_or_change_route_ajax(request, route_id):
if 'errors' in routes_Dict: if 'errors' in routes_Dict:
form.errors.update(routes_Dict['errors']) form.errors.update(routes_Dict['errors'])
Dict = {'form': form} Dict.update({'form': form})
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request) html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
return JsonResponse({'html': html}, status=400) return JsonResponse({'html': html}, status=400)
@@ -228,6 +232,7 @@ def create_or_change_route_ajax(request, route_id):
'all__': f'ошибка в запросе = {str(e)}' 'all__': f'ошибка в запросе = {str(e)}'
} }
} }
Dict = {'form': errors_Dict} # Dict = {'form': errors_Dict}
Dict.update({'form': errors_Dict})
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request) html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
return JsonResponse({'html': html}, status=400) return JsonResponse({'html': html}, status=400)

View File

@@ -17,12 +17,13 @@
</div> </div>
<div class="container-requests-tech-sprt"> <div class="container-requests-tech-sprt">
<div class="cont-req-tech-sup">Мои обращения:</div> <div class="cont-req-tech-sup">Мои обращения:</div>
{% for ticket in tickets %}
{% include "widgets/w_request_tech_support.html" %}
{% endfor %}
{% include "widgets/w_request_tech_support.html" %} {# {% include "widgets/w_request_tech_support.html" %}#}
{##}
{% include "widgets/w_request_tech_support.html" %} {# {% include "widgets/w_request_tech_support.html" %}#}
{% include "widgets/w_request_tech_support.html" %}
</div> </div>
</div> </div>

View File

@@ -1,13 +1,22 @@
{% load static %} {% load static %}
<div class="container-message-req-sprt"> <div class="container-message-req-sprt">
<div class="message-sprt-title"> <div class="message-sprt-title">
<span>Текст последнего сообщени в чате (с размытием)</span> <span>
{# Текст последнего сообщени в чате (с размытием)#}
{{ ticket.name }}
</span>
</div> </div>
<div class="message-sprt-inf"> <div class="message-sprt-inf">
<div> <div>
<span>Статус: Открыт</span> <span>
Статус: {{ ticket.get_status_display }}
{# Статус: Открыт#}
</span>
{# <img>#} {# <img>#}
<span>10.02.2023</span> <span>
{# 10.02.2023#}
{{ ticket.modifiedDT }}
</span>
</div> </div>
</div> </div>