From 704c44a6367beb3337e952128edcb950cb520a84 Mon Sep 17 00:00:00 2001 From: SDE Date: Tue, 5 Sep 2023 16:17:01 +0300 Subject: [PATCH] 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" %}