Merge remote-tracking branch 'origin/main'

This commit is contained in:
2023-09-05 20:07:06 +03:00
6 changed files with 126 additions and 42 deletions

View File

@@ -74,6 +74,29 @@ class Route(BaseModel):
verbose_name_plural = _(u'Маршруты') verbose_name_plural = _(u'Маршруты')
ordering = ('name',) ordering = ('name',)
def from_country_n_city_str(self):
country = 'Неизвестно'
if self.from_city:
city = self.from_city.name
if self.from_city.country:
country = self.from_city.country
else:
city = 'Неизвестно'
return f'{city} / {country}'
def to_country_n_city_str(self):
country = 'Неизвестно'
if self.to_city:
city = self.to_city.name
if self.to_city.country:
country = self.to_city.country
else:
city = 'Неизвестно'
return f'{city} / {country}'
def get_address_points(self): def get_address_points(self):
from ReferenceDataApp.models import Airport, City from ReferenceDataApp.models import Airport, City

View File

@@ -1632,25 +1632,26 @@ button#remove_route {
} }
button.confirm_remove{ button.confirm_remove{
width: 49% !important; width: 49% !important;
background: #ff0000a8; border: 1px solid #ff0000a8;
border-radius: 10px; border-radius: 10px;
color: white; color: #ff0000a8;
font-style: normal; font-style: normal;
font-weight: 600; font-weight: 600;
margin-right: 3px; margin-right: 3px;
padding: 5px 0px 5px 0px; padding: 5px 0px 5px 0px;
font-size: 16px;
} }
button.cancel_remove{ button.cancel_remove{
width: 48%; width: 48%;
background: #808080cc; border: 1px solid #808080cc;
border-radius: 10px; border-radius: 10px;
color: white; color: #808080cc;
font-style: normal; font-style: normal;
font-weight: 600; font-weight: 600;
padding: 5px 0px 5px 0px; padding: 5px 0px 5px 0px;
font-size: 16px;
} }

View File

@@ -153,32 +153,92 @@ function myProfile(el){
function removeRoute(el) {
let data = el.currentTarget.closest('.carrier-card');
let remove_item = data.dataset.numberOfRoute
let remove_data = {}
let name_route = 'route_id'
remove_data[name_route] = remove_item
// console.log(remove_item)
$.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/ru/routes/del_route/',
type: "POST",
// async: true,
cache: false,
processData: false,
contentType: false,
// enctype: 'json',
data: JSON.stringify(remove_data) ,
success: function(data){
if (data.user_alerts) {
getNewMessageSession()
}
// location.href = '/profile'
document.querySelector(".info_profile").innerHTML = data.html;
// let list_div = document.querySelectorAll('.menu_profile div');
// list_div.forEach(el=>{ el.classList.remove('selected'); });
// el.classList.add('selected')
//updating the url without reloading
window.history.pushState(null, null, '/ru/profile/page/change_profile/')
},
error: function (data, exception){
console.log(400)
}
});
}
function cancelRemove() {
let parent_cancel_button = document.querySelector('.button_remove_route')
let cancel_button = document.querySelector('.cancel_remove')
parent_cancel_button.removeChild(cancel_button)
let remove_button = document.querySelector('.confirm_remove');
remove_button.classList.remove('confirm_remove');
remove_button.innerText = 'Удалить';
remove_button.setAttribute("id", "remove_route");
}
function confirmRemove(el) { function confirmRemove(el) {
// let new_button = document.querySelector('.cancel_remove')
// if(!new_button){
// }
el.setAttribute("id", "select-remove"); el.setAttribute("id", "select-remove");
let btn = document.querySelector("#select-remove"); let btn = document.querySelector("#select-remove");
if(!btn.classList.contains('confirm_remove')){ if (!btn.classList.contains('confirm_remove')) {
btn.classList.add('confirm_remove') btn.classList.add('confirm_remove');
btn.innerText = 'Подтвердить удаление' btn.innerText = 'Подтвердить удаление';
// let place = document.querySelector('.button_remove_route') btn.addEventListener('click', removeRoute, { once: true });
let cancel_button = document.createElement('button')
let cancel_button = document.createElement('button');
cancel_button.className = "cancel_remove"; cancel_button.className = "cancel_remove";
cancel_button.innerText = "Отменить удаление"; cancel_button.innerText = "Отменить удаление";
let place = btn.closest(".button_remove_route") cancel_button.addEventListener('click', cancelRemove)
let place = btn.closest(".button_remove_route");
place.insertBefore(cancel_button, btn.nextSibling); place.insertBefore(cancel_button, btn.nextSibling);
btn.removeAttribute( "select-remove");
} }
btn.removeAttribute("id", "select-remove")
} }
function searchTown(el){ function searchTown(el){
if (el.value.length > 0){ if (el.value.length > 0){

View File

@@ -1,4 +1,4 @@
<div onmousedown='selectItemAddrPoint({{ id }}, "{{ fullname }}", "{{ ctrl_name }}")' class="autocomplete-result" data-index="{{ index }}"> <div onmousedown='selectItemAddrPoint({{ id }}, "{{ fullname }}", "{{ ctrl_name }}")' class="autocomplete-result" data-index="{{ index }}">
{% if airport_fullname %}<div>{{ airport_fullname|safe }}</div>{% endif %} {% if airport_fullname %}<div>{{ airport_fullname|safe }}</div>{% endif %}
<div class="autocomplete-location">{{ country_name }} / {{ city_name }}</div> <div class="autocomplete-location">{{ city_name }} / {{ country_name }}</div>
</div> </div>

View File

@@ -11,12 +11,12 @@
<div class="clear_both"></div> <div class="clear_both"></div>
</div> </div>
<div class="from-to-country-container-carrier"> <div class="from-to-country-container-carrier">
<div class="from-to-country-text left fl-left txt-al-right" title="{% if route.from_country %}{{ route.from_country }}{% else %}Неизвестно{% endif %} / {% if route.from_city %}{{ route.from_city }}{% else %}Неизвестно{% endif %}"> <div class="from-to-country-text left fl-left txt-al-right" title="{{ route.from_country_n_city_str }}">
{% if route.from_country %}{{ route.from_country }}{% else %}Неизвестно{% endif %} / {% if route.from_city %}{{ route.from_city }}{% else %}Неизвестно{% endif %} {{ route.from_country_n_city_str }}
</div> </div>
<div class="splitter-from-to-country"></div> <div class="splitter-from-to-country"></div>
<div class="from-to-country-text right fl-right txt-al-left" title="{% if route.to_country %}{{ route.to_country }}{% else %}Неизвестно{% endif %} / {% if route.to_city %}{{ route.to_city }}{% else %}Неизвестно{% endif %}"> <div class="from-to-country-text right fl-right txt-al-left" title="{{ route.to_country_n_city_str }}">
{% if route.to_country %}{{ route.to_country }}{% else %}Неизвестно{% endif %} / {% if route.to_city %}{{ route.to_city }}{% else %}Неизвестно{% endif %} {{ route.to_country_n_city_str }}
</div> </div>
</div> </div>
{% include "small_INCLUDES/carrier_card/inf_about_moving.html" %} {% include "small_INCLUDES/carrier_card/inf_about_moving.html" %}

View File

@@ -31,12 +31,12 @@
</div> </div>
<div class="from-to-country-container-carrier"> <div class="from-to-country-container-carrier">
<div class="from-to-country-text left fl-left txt-al-right" title="{% if route.from_country %}{{ route.from_country }}{% else %}Неизвестно{% endif %} / {% if route.from_city %}{{ route.from_city }}{% else %}Неизвестно{% endif %}"> <div class="from-to-country-text left fl-left txt-al-right" title="{{ route.from_country_n_city_str }}">
{% if route.from_country %}{{ route.from_country }}{% else %}Неизвестно{% endif %} / {% if route.from_city %}{{ route.from_city }}{% else %}Неизвестно{% endif %} {{ route.from_country_n_city_str }}
</div> </div>
<div class="splitter-from-to-country"></div> <div class="splitter-from-to-country"></div>
<div class="from-to-country-text right fl-right txt-al-left" title="{% if route.to_country %}{{ route.to_country }}{% else %}Неизвестно{% endif %} / {% if route.to_city %}{{ route.to_city }}{% else %}Неизвестно{% endif %}"> <div class="from-to-country-text right fl-right txt-al-left" title="{{ route.to_country_n_city_str }}">
{% if route.to_country %}{{ route.to_country }}{% else %}Неизвестно{% endif %} / {% if route.to_city %}{{ route.to_city }}{% else %}Неизвестно{% endif %} {{ route.to_country_n_city_str }}
</div> </div>
</div> </div>
{% include "small_INCLUDES/carrier_card/inf_about_moving.html" %} {% include "small_INCLUDES/carrier_card/inf_about_moving.html" %}
@@ -108,21 +108,21 @@
{#<div class="my_route">#} {#<div class="my_route">#}
{# <div class="route_info">#} {# <div class="route_info">#}
<div class="route_info_about"> {# <div class="route_info_about">#}
<span> {# <span>#}
Тип:{{ route.get_cargo_type_display }} {# Тип:{{ route.get_cargo_type_display }}#}
</span> {# </span>#}
{##}
<span> {# <span>#}
Вес:{{ route.weight }} кг {# Вес:{{ route.weight }} кг#}
</span> {# </span>#}
{##}
<span> {# <span>#}
{##}
{{ route.get_type_transport_display }} {# {{ route.get_type_transport_display }}#}
</span> {# </span>#}
{##}
</div> {# </div>#}
{##} {##}
{# <div class="route_info_point">#} {# <div class="route_info_point">#}
{##} {##}