From bf29a0b21bd826379d83d461dccc1bed4e2bea74 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 1 Feb 2026 04:20:12 +0000 Subject: [PATCH] feat: Add Google Maps navigation links for drivers - Added and properties to model. - Exposed these URLs in . - Updated driver dashboard to show 'Navigate to Pickup' and 'Navigate to Delivery' buttons for active shipments. --- core/models.py | 12 ++++++++++++ core/serializers.py | 2 ++ core/templates/core/driver_dashboard.html | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/core/models.py b/core/models.py index 0e1a1eb..9f05d9d 100644 --- a/core/models.py +++ b/core/models.py @@ -300,6 +300,18 @@ class Parcel(models.Model): super().save(*args, **kwargs) + @property + def pickup_google_maps_url(self): + if self.pickup_lat and self.pickup_lng: + return f"https://www.google.com/maps/search/?api=1&query={self.pickup_lat},{self.pickup_lng}" + return f"https://www.google.com/maps/search/?api=1&query={self.pickup_address}" + + @property + def delivery_google_maps_url(self): + if self.delivery_lat and self.delivery_lng: + return f"https://www.google.com/maps/search/?api=1&query={self.delivery_lat},{self.delivery_lng}" + return f"https://www.google.com/maps/search/?api=1&query={self.delivery_address}" + def __str__(self): return f"Parcel {self.tracking_number} - {self.status}" diff --git a/core/serializers.py b/core/serializers.py index 415be60..b4cf0be 100644 --- a/core/serializers.py +++ b/core/serializers.py @@ -30,6 +30,8 @@ class ParcelSerializer(serializers.ModelSerializer): delivery_governate_detail = GovernateSerializer(source='delivery_governate', read_only=True) delivery_city_detail = CitySerializer(source='delivery_city', read_only=True) status_display = serializers.CharField(source='get_status_display', read_only=True) + pickup_google_maps_url = serializers.ReadOnlyField() + delivery_google_maps_url = serializers.ReadOnlyField() class Meta: model = Parcel diff --git a/core/templates/core/driver_dashboard.html b/core/templates/core/driver_dashboard.html index 6962256..21eb7e5 100644 --- a/core/templates/core/driver_dashboard.html +++ b/core/templates/core/driver_dashboard.html @@ -198,6 +198,16 @@

{% trans "To" %}: {{ parcel.delivery_governate.name }} / {{ parcel.delivery_city.name }}

{% trans "Receiver" %}: {{ parcel.receiver_name }}

+ +
+ + {% trans "Navigate to Pickup" %} + + + {% trans "Navigate to Delivery" %} + +
+
{% csrf_token %}