diff --git a/AuthApp/js_urls.py b/AuthApp/js_urls.py
index 9cfcbcf..5d3ceb9 100644
--- a/AuthApp/js_urls.py
+++ b/AuthApp/js_urls.py
@@ -28,6 +28,6 @@ urlpatterns = [
path('change_profile_confirm/', change_profile_confirm_ajax, name='change_profile_confirm_ajax'),
path('change_avatar_confirm/', change_avatar_confirm_ajax, name='change_avatar_confirm_ajax'),
- path('request_offer/', request_offer_ajax, name='request_offer_ajax')
+ path('send_message/', send_message_ajax, name='send_message_ajax')
]
\ No newline at end of file
diff --git a/AuthApp/js_views.py b/AuthApp/js_views.py
index 8d77ece..edf7fbf 100644
--- a/AuthApp/js_views.py
+++ b/AuthApp/js_views.py
@@ -31,53 +31,95 @@ import base64
-def request_offer_ajax(request):
+def send_message_ajax(request):
if request.method != 'POST':
raise Http404
- data = request.POST
- if not data and request.body:
- data = request.body
+ try:
- from GeneralApp.funcs_options import get_options_by_opt_types, get_mail_send_options
- sets = get_options_by_opt_types(['domain', 'project_name'], only_vals=True)
+ data = request.POST
+ if not data and request.body:
+ data = request.body
- request_type = None
- subject = _('Получен запрос')
- if 'form_name' in data:
- if data['form_name'] == 'msg_from_advertisement':
- subject = _('Получен запрос на рекламу')
- request_type = _('запрос на рекламу')
+ from GeneralApp.funcs_options import get_options_by_opt_types, get_mail_send_options
+ sets = get_options_by_opt_types(['domain', 'project_name'], only_vals=True)
+
+ request_type = None
+ subject = _('Получен запрос')
+ if 'form_name' in data:
+ if data['form_name'] == 'msg_from_advertisement':
+ subject = _('Получен запрос на рекламу')
+ request_type = _('запрос на рекламу')
+ if data['form_name'] == 'msg_from_partners':
+ subject = _('Получен запрос на подключение к партнерской сети')
+ request_type = _('запрос на партнерство')
+ if data['form_name'] == 'msg_from_customer_service':
+ subject = _('Получен запрос в службу техподдержки')
+ request_type = _('запрос в техподдержку')
+ if data['form_name'] == 'msg_from_contacts':
+ subject = _('Получен запрос со страницы контактов')
+ request_type = _('запрос со страницы контактов')
+ if data['form_name'] == 'msg_from_about_service':
+ subject = _('Получен запрос со страницы О сервисе')
+ request_type = _('запрос со страницы о сервисе')
+ if data['form_name'] == 'footer':
+ subject = _('Получен запрос на рассылку')
+ request_type = _('запрос на рассылку')
- if request_type:
- request_type_str = f'{_("Тип запроса")}: {request_type}
'
- else:
request_type_str = ''
+ name_str = ''
+ phone_str = ''
+ email_str = ''
+ msg_str = ''
+ if request_type:
+ request_type_str = f'{_("Тип запроса")}: {request_type}
'
+ if 'name' in data:
+ name_str = f'{_("Имя")}: {data["name"]}
'
+ if 'phone' in data:
+ phone_str = f'{_("Телефон")}: {data["phone"]}
'
+ if 'email' in data:
+ email_str = f'{_("email")}: {data["email"]}
'
+ if 'text_msg' in data:
+ msg_str = (f'{_("Сообщение")}:
'
+ f'
{_("ДАННЫЕ ЗАПРОСА")}
' - f''
- f'{request_type_str}'
- f'{_("Имя")}: {data["name"]}
'
- f'{_("Телефон")}: {data["phone"]}'
- f'
{_("ДАННЫЕ ЗАПРОСА")}
' + f'' + f'{request_type_str}' + f'{name_str}' + f'{phone_str}' + f'{email_str}' + f'{msg_str}' + f'
' + } - return JsonResponse({'status': 'sended'}) + html = render_to_string('mail/m_request_offer.html', Dict, request) + from BaseModels.mailSender import admin_send_mail_by_SMTPlib + mail_sets = get_mail_send_options() + to = [mail_sets['sender_email'], 'web@syncsystems.net'] + res = admin_send_mail_by_SMTPlib( + mail_sets, + subject=subject, + from_email=mail_sets['sender_email'], to=to, + html_content=html + ) + + html = render_to_string('widgets/w_msg_send_success.html', Dict, request) + + return JsonResponse({ + 'status': 'sended', + 'html': html + }) + except Exception as e: + return JsonResponse({ + 'status': 'error', + 'error': str(e) + }, status=400) @login_required(login_url='/profile/login/') diff --git a/static/css/mobile_styles.css b/static/css/mobile_styles.css index bca9edf..dcbf4e3 100644 --- a/static/css/mobile_styles.css +++ b/static/css/mobile_styles.css @@ -2,7 +2,7 @@ @media (max-width: 1280px){ - button#remove_route{ + .remove_route{ width: 100%; text-align: center; } @@ -1018,7 +1018,9 @@ margin: unset; } .cargo_type_trans{ - float: right; + display: block; + margin-bottom: 15px; + float: unset; } .from-to-country-container-carrier{ diff --git a/static/css/styles.css b/static/css/styles.css index e9da490..d1b946a 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -1774,6 +1774,7 @@ input#id_extra_phone } .route_info_about{ margin-bottom: 30px; + font-size: 15px; } .route_info_point { @@ -1825,10 +1826,13 @@ input#id_extra_phone .cargo_type_disp{ background: url("/static/img/png/Tag.png") left center no-repeat; - margin: 0 20px 0 20px; + margin-right: 20px; padding-left: 15px; } +.cargo_type_trans{ + float: right; +} .cargo_weight{ background: url("/static/img/png/Scales.png") left center no-repeat; padding-left: 20px; @@ -1870,13 +1874,28 @@ button#edit_route { } -button#remove_route { +.remove_route { height: 44px; width: 285px; color: rgba(39, 36, 36, 0.60); } +.remove_route.hide{ + display: none; +} +.msg_send{ + font-size: 24px; + text-align: center; + font-weight: 700; + background: #FFFFFF; + box-shadow: -1px 4px 10px 0px rgba(198, 199, 203, 0.20), 0px -1px 10px 0px rgba(198, 199, 203, 0.20); +} +.msg_send.hide{ + display: none; +} + + button.confirm_remove{ - width: 49.5%; + width: 48.5%; border: 1px solid #ff0000a8; border-radius: 10px; color: #ff0000a8; @@ -1886,6 +1905,7 @@ button.confirm_remove{ /*padding: 5px 0px 5px 0px;*/ font-size: 16px; height: 44px; + display: none; } button.cancel_remove{ @@ -1898,9 +1918,14 @@ button.cancel_remove{ /*padding: 5px 0px 5px 0px;*/ font-size: 16px; height: 44px; + display: none; } +button.cancel_remove.show, button.confirm_remove.show{ + display: inline-block; +} + /*Static_pages*/ #title_static{ diff --git a/static/js/user_profile.js b/static/js/user_profile.js index 7e58997..cb8a8fd 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -146,9 +146,8 @@ -function removeRoute(el) { - let data = el.currentTarget.closest('.carrier-card'); - let remove_item = data.dataset.numberOfRoute +function removeRoute(el,route_id ) { + let remove_item = route_id let remove_data = {} let name_route = 'route_id' remove_data[name_route] = remove_item @@ -176,7 +175,7 @@ function removeRoute(el) { // el.classList.add('selected') //updating the url without reloading - window.history.pushState(null, null, '/ru/profile/page/change_profile/') + window.history.pushState(null, null, '/ru/profile/page/my_routes/') middleWareJS() }, @@ -189,46 +188,35 @@ function removeRoute(el) { } -function cancelRemove() { - let parent_cancel_button = document.querySelector('.button_remove_route') - let cancel_button = document.querySelector('.cancel_remove') - parent_cancel_button.removeChild(cancel_button) +function cancelRemove(route_id) { + let confirm_remove = document.getElementById('confirm_remove_'+ route_id); + let cancel_remove = document.getElementById('cancel_remove_'+ route_id); - let remove_button = document.querySelector('.confirm_remove'); - remove_button.classList.remove('confirm_remove'); - remove_button.innerText = 'Удалить'; - remove_button.setAttribute("id", "remove_route"); + confirm_remove.classList.remove('show'); + cancel_remove.classList.remove('show'); - remove_button.removeEventListener('click', removeRoute); + let remove_btn = document.getElementById('remove_route_'+route_id); + remove_btn.classList.remove('hide'); +} +function hideBlock(el) { + + el.classList.add('hide') } -function confirmRemove(el) { +function confirmRemove(el, route_id) { - el.setAttribute("id", "select-remove"); - let btn = document.querySelector("#select-remove"); - - if (!btn.classList.contains('confirm_remove')) { - btn.classList.add('confirm_remove'); - btn.innerText = 'Подтвердить удаление'; - btn.addEventListener('click', removeRoute, { once: true }); - - let cancel_button = document.createElement('button'); - cancel_button.className = "cancel_remove"; - cancel_button.innerText = "Отменить удаление"; - cancel_button.addEventListener('click', cancelRemove) - - - let place = btn.closest(".button_remove_route"); - place.insertBefore(cancel_button, btn.nextSibling); - - btn.removeAttribute( "select-remove"); + let confirm_remove = document.getElementById('confirm_remove_'+ route_id); + let cancel_remove = document.getElementById('cancel_remove_'+ route_id); + confirm_remove.classList.add('show'); + cancel_remove.classList.add('show'); + let remove_btn = document.getElementById('remove_route_'+route_id); + remove_btn.classList.add('hide'); } -} function loader_place_ins_boris (el,type=null){ if (el && !window.location.href.includes("profile")){ @@ -820,7 +808,7 @@ function RequestCommercialOffer (el){ $.ajax({ headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, - url: '/user_account/request_offer/', + url: '/user_account/send_message/', type: "POST", // async: true, cache: false, @@ -830,7 +818,7 @@ function RequestCommercialOffer (el){ data: formData, success: function(data){ - alert("Сообщение отправлено") + $(data.html).insertBefore(document.querySelector(".feedback_form")) }, diff --git a/templates/blocks/static_pages_blocks/b_advertisement.html b/templates/blocks/static_pages_blocks/b_advertisement.html index dbc4093..e74accc 100644 --- a/templates/blocks/static_pages_blocks/b_advertisement.html +++ b/templates/blocks/static_pages_blocks/b_advertisement.html @@ -55,7 +55,7 @@