diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index b932693..a145697 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index cb8f7bd..fdf6df4 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 2ba60ea..bde313b 100644 --- a/core/admin.py +++ b/core/admin.py @@ -12,6 +12,8 @@ from django.core.mail import send_mail from django.conf import settings from .mail import send_html_email import logging +import csv +from django.http import HttpResponse class ProfileInline(admin.StackedInline): model = Profile @@ -22,9 +24,32 @@ class CustomUserAdmin(UserAdmin): inlines = (ProfileInline,) class ParcelAdmin(admin.ModelAdmin): - list_display = ('tracking_number', 'shipper', 'status', 'created_at') - list_filter = ('status', 'created_at') - search_fields = ('tracking_number', 'shipper__username', 'receiver_name') + list_display = ('tracking_number', 'shipper', 'carrier', 'price', 'status', 'payment_status', 'created_at') + list_filter = ('status', 'payment_status', 'created_at') + search_fields = ('tracking_number', 'shipper__username', 'receiver_name', 'carrier__username') + actions = ['export_as_csv'] + + def export_as_csv(self, request, queryset): + response = HttpResponse(content_type='text/csv') + response['Content-Disposition'] = 'attachment; filename="parcels_report.csv"' + writer = csv.writer(response) + + writer.writerow(['Tracking Number', 'Shipper', 'Carrier', 'Price (OMR)', 'Status', 'Payment Status', 'Created At', 'Updated At']) + + for obj in queryset: + writer.writerow([ + obj.tracking_number, + obj.shipper.username if obj.shipper else '', + obj.carrier.username if obj.carrier else '', + obj.price, + obj.get_status_display(), + obj.get_payment_status_display(), + obj.created_at, + obj.updated_at + ]) + + return response + export_as_csv.short_description = _("Export Selected to CSV") class PlatformProfileAdmin(admin.ModelAdmin): fieldsets = ( diff --git a/core/templates/core/driver_dashboard.html b/core/templates/core/driver_dashboard.html index 8c19b25..f932197 100644 --- a/core/templates/core/driver_dashboard.html +++ b/core/templates/core/driver_dashboard.html @@ -10,7 +10,10 @@
{% trans "You haven't accepted any shipments yet." %}
{% endif %}| {% trans "Date" %} | +{% trans "Tracking ID" %} | +{% trans "From" %} | +{% trans "To" %} | +{% trans "Price" %} | +{% trans "Status" %} | +
|---|---|---|---|---|---|
| {{ parcel.created_at|date:"Y-m-d" }} | +#{{ parcel.tracking_number }} | +{{ parcel.pickup_city.name|default:parcel.pickup_address }} | +{{ parcel.delivery_city.name|default:parcel.delivery_address }} | +{{ parcel.price }} OMR | ++ + {{ parcel.get_status_display }} + + | +
{% trans "No completed deliveries yet." %}
+{% trans "From" %}: {{ parcel.pickup_address }}
-{% trans "To" %}: {{ parcel.delivery_address }}
- -{% trans "From" %}: {{ parcel.pickup_address }}
+{% trans "To" %}: {{ parcel.delivery_address }}
+ +{% trans "Receiver" %}: {{ parcel.receiver_name }}
-{% trans "Carrier" %}: {% if parcel.carrier %}{{ parcel.carrier.get_full_name|default:parcel.carrier.username }}{% else %}{% trans "Waiting for pickup" %}{% endif %}
+ {% if parcel.payment_status == 'pending' %} + {% if payments_enabled %} + + {% trans "Pay Now" %} + + {% endif %} + {% endif %} + +{% trans "Receiver" %}: {{ parcel.receiver_name }}
+{% trans "Carrier" %}: {% if parcel.carrier %}{{ parcel.carrier.get_full_name|default:parcel.carrier.username }}{% else %}{% trans "Waiting for pickup" %}{% endif %}
+{% trans "You have no active shipments." %}
+ {% trans "Send your first shipment" %} +| {% trans "Date" %} | +{% trans "Tracking ID" %} | +{% trans "Description" %} | +{% trans "Carrier" %} | +{% trans "Bid/Price" %} | +{% trans "Status" %} | +
|---|---|---|---|---|---|
| {{ parcel.created_at|date:"Y-m-d" }} | +#{{ parcel.tracking_number }} | +{{ parcel.description|truncatechars:30 }} | ++ {% if parcel.carrier %} + {{ parcel.carrier.get_full_name|default:parcel.carrier.username }} + {% else %} + - + {% endif %} + | +{{ parcel.price }} OMR | ++ + {{ parcel.get_status_display }} + + | +
{% trans "No completed transactions yet." %}
+{% trans "You haven't sent any shipments yet." %}
- {% trans "Send your first shipment" %} -