From 704c44a6367beb3337e952128edcb950cb520a84 Mon Sep 17 00:00:00 2001 From: SDE Date: Tue, 5 Sep 2023 16:17:01 +0300 Subject: [PATCH 1/4] 0.7.25 country_n_city_str --- RoutesApp/models.py | 23 +++++++++++++++++++++++ templates/widgets/w_carrier_card.html | 8 ++++---- templates/widgets/w_route_info.html | 8 ++++---- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/RoutesApp/models.py b/RoutesApp/models.py index 7631e11..4efc563 100644 --- a/RoutesApp/models.py +++ b/RoutesApp/models.py @@ -74,6 +74,29 @@ class Route(BaseModel): verbose_name_plural = _(u'Маршруты') 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): from ReferenceDataApp.models import Airport, City diff --git a/templates/widgets/w_carrier_card.html b/templates/widgets/w_carrier_card.html index 43f005c..8e6fd59 100644 --- a/templates/widgets/w_carrier_card.html +++ b/templates/widgets/w_carrier_card.html @@ -11,12 +11,12 @@
-
- {% if route.from_country %}{{ route.from_country }}{% else %}Неизвестно{% endif %} / {% if route.from_city %}{{ route.from_city }}{% else %}Неизвестно{% endif %} +
+ {{ route.from_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 }}
{% include "small_INCLUDES/carrier_card/inf_about_moving.html" %} diff --git a/templates/widgets/w_route_info.html b/templates/widgets/w_route_info.html index 97c8b9b..5022f94 100644 --- a/templates/widgets/w_route_info.html +++ b/templates/widgets/w_route_info.html @@ -31,12 +31,12 @@
-
- {% if route.from_country %}{{ route.from_country }}{% else %}Неизвестно{% endif %} / {% if route.from_city %}{{ route.from_city }}{% else %}Неизвестно{% endif %} +
+ {{ route.from_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 }}
{% include "small_INCLUDES/carrier_card/inf_about_moving.html" %} From fa2c3ee5694b7cd0d03f12944890665c49365571 Mon Sep 17 00:00:00 2001 From: SDE Date: Tue, 5 Sep 2023 16:34:58 +0300 Subject: [PATCH 2/4] 0.7.26 country_n_city_str --- templates/widgets/w_ac_input_address_point.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/widgets/w_ac_input_address_point.html b/templates/widgets/w_ac_input_address_point.html index 3b9ba35..ec64cfe 100644 --- a/templates/widgets/w_ac_input_address_point.html +++ b/templates/widgets/w_ac_input_address_point.html @@ -1,4 +1,4 @@
{% if airport_fullname %}
{{ airport_fullname|safe }}
{% endif %} -
{{ country_name }} / {{ city_name }}
+
{{ city_name }} / {{ country_name }}
\ No newline at end of file From 9d226e3f6f91c60c56534f06c2ecbe6dc572c0c8 Mon Sep 17 00:00:00 2001 From: ArtemB Date: Tue, 5 Sep 2023 17:07:57 +0300 Subject: [PATCH 3/4] 0.0.128 remove_route func v0.1 --- static/js/user_profile.js | 54 +++++++++++++++++++++++++++-- templates/widgets/w_route_info.html | 30 ++++++++-------- 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/static/js/user_profile.js b/static/js/user_profile.js index 7c2872e..a3d9081 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -153,8 +153,52 @@ function myProfile(el){ +function removeRoute(el) { + let remove_item = el.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.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 confirmRemove(el) { @@ -166,7 +210,7 @@ function confirmRemove(el) { el.setAttribute("id", "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.innerText = 'Подтвердить удаление' // let place = document.querySelector('.button_remove_route') @@ -175,10 +219,16 @@ function confirmRemove(el) { cancel_button.innerText = "Отменить удаление"; let place = btn.closest(".button_remove_route") place.insertBefore(cancel_button, btn.nextSibling); + + btn.addEventListener('click', removeRoute, { once: true }) + btn.removeAttribute("id", "select-remove") + + } - btn.removeAttribute("id", "select-remove") } + + function searchTown(el){ if (el.value.length > 0){ diff --git a/templates/widgets/w_route_info.html b/templates/widgets/w_route_info.html index 5022f94..6d7ed4a 100644 --- a/templates/widgets/w_route_info.html +++ b/templates/widgets/w_route_info.html @@ -108,21 +108,21 @@ {#
#} {#
#} -
- - Тип:{{ route.get_cargo_type_display }} - - - - Вес:{{ route.weight }} кг - - - - - {{ route.get_type_transport_display }} - - -
+{#
#} +{# #} +{# Тип:{{ route.get_cargo_type_display }}#} +{# #} +{##} +{# #} +{# Вес:{{ route.weight }} кг#} +{# #} +{##} +{# #} +{##} +{# {{ route.get_type_transport_display }}#} +{# #} +{##} +{#
#} {##} {#
#} {##} From 7002bd2600d5f49fd280a798e525147afa700daf Mon Sep 17 00:00:00 2001 From: ArtemB Date: Tue, 5 Sep 2023 18:39:49 +0300 Subject: [PATCH 4/4] 0.0.129 add bad remove_route_button design --- static/css/styles.css | 15 ++++++++------- static/js/user_profile.js | 40 ++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/static/css/styles.css b/static/css/styles.css index c171e00..4101854 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -1632,25 +1632,26 @@ button#remove_route { } button.confirm_remove{ width: 49% !important; - background: #ff0000a8; + border: 1px solid #ff0000a8; border-radius: 10px; - color: white; + color: #ff0000a8; font-style: normal; font-weight: 600; margin-right: 3px; padding: 5px 0px 5px 0px; - - - + font-size: 16px; } + button.cancel_remove{ width: 48%; - background: #808080cc; + border: 1px solid #808080cc; border-radius: 10px; - color: white; + color: #808080cc; font-style: normal; font-weight: 600; padding: 5px 0px 5px 0px; + font-size: 16px; + } diff --git a/static/js/user_profile.js b/static/js/user_profile.js index a3d9081..8da3e97 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -154,11 +154,10 @@ function myProfile(el){ function removeRoute(el) { - - - let remove_item = el.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.dataset.numberOfRoute + let data = el.currentTarget.closest('.carrier-card'); + let remove_item = data.dataset.numberOfRoute let remove_data = {} - let name_route = 'route.id' + let name_route = 'route_id' remove_data[name_route] = remove_item // console.log(remove_item) @@ -199,29 +198,40 @@ 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) + + 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) { - // let new_button = document.querySelector('.cancel_remove') - // if(!new_button){ - - // } el.setAttribute("id", "select-remove"); let btn = document.querySelector("#select-remove"); if (!btn.classList.contains('confirm_remove')) { - btn.classList.add('confirm_remove') - btn.innerText = 'Подтвердить удаление' - // let place = document.querySelector('.button_remove_route') - let cancel_button = document.createElement('button') + 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 = "Отменить удаление"; - 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); - btn.addEventListener('click', removeRoute, { once: true }) - btn.removeAttribute("id", "select-remove") + btn.removeAttribute( "select-remove"); }