diff --git a/core/__pycache__/forms.cpython-311.pyc b/core/__pycache__/forms.cpython-311.pyc index 474c9c9..25d2e3b 100644 Binary files a/core/__pycache__/forms.cpython-311.pyc and b/core/__pycache__/forms.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index ff037fe..0a0ef94 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 8053aad..de61ba2 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/forms.py b/core/forms.py index 255ed32..86188ba 100644 --- a/core/forms.py +++ b/core/forms.py @@ -254,9 +254,9 @@ class ParcelForm(forms.ModelForm): self.fields['receiver_phone_code'].queryset = Country.objects.exclude(phone_code='').order_by(name_field) self.fields['receiver_phone_code'].label_from_instance = lambda obj: f"{obj.phone_code} ({obj.name})" - # Default Country logic + # Default Country logic (Oman) - Only if not editing oman = Country.objects.filter(name_en='Oman').first() - if oman: + if not self.instance.pk and oman: self.fields['receiver_phone_code'].initial = oman self.fields['pickup_country'].initial = oman self.fields['delivery_country'].initial = oman @@ -283,6 +283,8 @@ class ParcelForm(forms.ModelForm): self.fields['pickup_governate'].queryset = Governate.objects.filter(country_id=country_id).order_by(name_field) except (ValueError, TypeError): pass + elif self.instance.pk and self.instance.pickup_country: + self.fields['pickup_governate'].queryset = Governate.objects.filter(country=self.instance.pickup_country).order_by(name_field) elif oman: self.fields['pickup_governate'].queryset = Governate.objects.filter(country=oman).order_by(name_field) @@ -292,6 +294,8 @@ class ParcelForm(forms.ModelForm): self.fields['pickup_city'].queryset = City.objects.filter(governate_id=gov_id).order_by(name_field) except (ValueError, TypeError): pass + elif self.instance.pk and self.instance.pickup_governate: + self.fields['pickup_city'].queryset = City.objects.filter(governate_id=self.instance.pickup_governate.id).order_by(name_field) # Delivery self.fields['delivery_governate'].queryset = Governate.objects.none() @@ -303,6 +307,8 @@ class ParcelForm(forms.ModelForm): self.fields['delivery_governate'].queryset = Governate.objects.filter(country_id=country_id).order_by(name_field) except (ValueError, TypeError): pass + elif self.instance.pk and self.instance.delivery_country: + self.fields['delivery_governate'].queryset = Governate.objects.filter(country=self.instance.delivery_country).order_by(name_field) elif oman: self.fields['delivery_governate'].queryset = Governate.objects.filter(country=oman).order_by(name_field) @@ -312,6 +318,8 @@ class ParcelForm(forms.ModelForm): self.fields['delivery_city'].queryset = City.objects.filter(governate_id=gov_id).order_by(name_field) except (ValueError, TypeError): pass + elif self.instance.pk and self.instance.delivery_governate: + self.fields['delivery_city'].queryset = City.objects.filter(governate_id=self.instance.delivery_governate.id).order_by(name_field) def clean(self): cleaned_data = super().clean() diff --git a/core/templates/core/article_detail.html b/core/templates/core/article_detail.html index 6cd5e69..2a400ab 100644 --- a/core/templates/core/article_detail.html +++ b/core/templates/core/article_detail.html @@ -7,7 +7,7 @@
- {% trans "Back to Home" %} + {% trans "Back to Home" %}

{{ article.title }}

diff --git a/core/templates/core/contact.html b/core/templates/core/contact.html index 578976a..45fbd76 100644 --- a/core/templates/core/contact.html +++ b/core/templates/core/contact.html @@ -11,7 +11,7 @@
- {% trans "Back to Home" %} + {% trans "Back to Home" %}
diff --git a/core/templates/core/edit_parcel.html b/core/templates/core/edit_parcel.html new file mode 100644 index 0000000..34f66d9 --- /dev/null +++ b/core/templates/core/edit_parcel.html @@ -0,0 +1,205 @@ +{% extends 'base.html' %} +{% load static %} +{% load i18n %} + +{% block content %} +
+
+
+ + + +
+
+

{% trans "Edit Shipment" %}

+ {{ parcel.tracking_number }} +
+ +
+ {% csrf_token %} +
+ +
+ + {{ form.description }} + {% if form.description.errors %} +
{{ form.description.errors }}
+ {% endif %} +
+
+ + {{ form.weight }} + {% if form.weight.errors %} +
{{ form.weight.errors }}
+ {% endif %} +
+
+ + {{ form.price }} + {% if form.price.errors %} +
{{ form.price.errors }}
+ {% endif %} +
+ + +
+

{% trans "Pickup Details" %}

+
+
+ + {{ form.pickup_country }} + {% if form.pickup_country.errors %} +
{{ form.pickup_country.errors }}
+ {% endif %} +
+
+ + {{ form.pickup_governate }} + {% if form.pickup_governate.errors %} +
{{ form.pickup_governate.errors }}
+ {% endif %} +
+
+ + {{ form.pickup_city }} + {% if form.pickup_city.errors %} +
{{ form.pickup_city.errors }}
+ {% endif %} +
+
+ + {{ form.pickup_address }} + {% if form.pickup_address.errors %} +
{{ form.pickup_address.errors }}
+ {% endif %} +
+ + +
+

{% trans "Delivery Details" %}

+
+
+ + {{ form.delivery_country }} + {% if form.delivery_country.errors %} +
{{ form.delivery_country.errors }}
+ {% endif %} +
+
+ + {{ form.delivery_governate }} + {% if form.delivery_governate.errors %} +
{{ form.delivery_governate.errors }}
+ {% endif %} +
+
+ + {{ form.delivery_city }} + {% if form.delivery_city.errors %} +
{{ form.delivery_city.errors }}
+ {% endif %} +
+
+ + {{ form.delivery_address }} + {% if form.delivery_address.errors %} +
{{ form.delivery_address.errors }}
+ {% endif %} +
+ + +
+

{% trans "Receiver Details" %}

+
+
+ + {{ form.receiver_name }} + {% if form.receiver_name.errors %} +
{{ form.receiver_name.errors }}
+ {% endif %} +
+
+ +
+
+ {{ form.receiver_phone_code }} +
+
+ {{ form.receiver_phone }} +
+
+ {% if form.receiver_phone_code.errors %} +
{{ form.receiver_phone_code.errors }}
+ {% endif %} + {% if form.receiver_phone.errors %} +
{{ form.receiver_phone.errors }}
+ {% endif %} +
+ +
+ {% trans "Cancel" %} + +
+
+
+
+
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/core/templates/core/edit_profile.html b/core/templates/core/edit_profile.html index 0037256..d7135cc 100644 --- a/core/templates/core/edit_profile.html +++ b/core/templates/core/edit_profile.html @@ -11,7 +11,7 @@
- {% trans "Back to Profile" %} + {% trans "Back to Profile" %}
diff --git a/core/templates/core/invoice.html b/core/templates/core/invoice.html index b79ab24..236a659 100644 --- a/core/templates/core/invoice.html +++ b/core/templates/core/invoice.html @@ -4,14 +4,15 @@ - Invoice {{ parcel.tracking_number }} + {% trans "Invoice" %} {{ parcel.tracking_number }} @@ -225,4 +230,4 @@
- + \ No newline at end of file diff --git a/core/templates/core/parcel_label.html b/core/templates/core/parcel_label.html index 40a0982..efaff35 100644 --- a/core/templates/core/parcel_label.html +++ b/core/templates/core/parcel_label.html @@ -3,109 +3,147 @@ - Label {{ parcel.tracking_number }} + {% trans "Label" %} {{ parcel.tracking_number }} diff --git a/core/templates/core/password_reset_form.html b/core/templates/core/password_reset_form.html index beb531f..0b19459 100644 --- a/core/templates/core/password_reset_form.html +++ b/core/templates/core/password_reset_form.html @@ -36,7 +36,7 @@
- {% trans "Back to Login" %} + {% trans "Back to Login" %}
diff --git a/core/templates/core/privacy_policy.html b/core/templates/core/privacy_policy.html index 0d8fad5..3a1921d 100644 --- a/core/templates/core/privacy_policy.html +++ b/core/templates/core/privacy_policy.html @@ -5,7 +5,7 @@
- {% trans "Back to Home" %} + {% trans "Back to Home" %}

{% trans "Privacy Policy" %}

diff --git a/core/templates/core/profile.html b/core/templates/core/profile.html index e836d7a..5bcb89e 100644 --- a/core/templates/core/profile.html +++ b/core/templates/core/profile.html @@ -11,7 +11,7 @@
- {% trans "Back to Dashboard" %} + {% trans "Back to Dashboard" %}
diff --git a/core/templates/core/rate_driver.html b/core/templates/core/rate_driver.html index bcee138..2591107 100644 --- a/core/templates/core/rate_driver.html +++ b/core/templates/core/rate_driver.html @@ -5,6 +5,13 @@
+ + +
diff --git a/core/templates/core/register.html b/core/templates/core/register.html index b8a9a96..1904d83 100644 --- a/core/templates/core/register.html +++ b/core/templates/core/register.html @@ -11,7 +11,7 @@ diff --git a/core/templates/core/scan_qr.html b/core/templates/core/scan_qr.html index dcd8f93..ebf49b2 100644 --- a/core/templates/core/scan_qr.html +++ b/core/templates/core/scan_qr.html @@ -25,7 +25,7 @@ diff --git a/core/templates/core/shipment_request.html b/core/templates/core/shipment_request.html index 93884bd..8c50555 100644 --- a/core/templates/core/shipment_request.html +++ b/core/templates/core/shipment_request.html @@ -9,7 +9,7 @@ diff --git a/core/templates/core/shipper_dashboard.html b/core/templates/core/shipper_dashboard.html index fbcaf70..f7a87a5 100644 --- a/core/templates/core/shipper_dashboard.html +++ b/core/templates/core/shipper_dashboard.html @@ -61,6 +61,17 @@
+ {% if parcel.status == 'pending' %} + + {% endif %} + {% if parcel.payment_status == 'pending' %} {% if payments_enabled %} @@ -126,6 +137,15 @@
+ {% if parcel.status == 'pending' %} + + + + + + + {% endif %} + diff --git a/core/templates/core/terms_conditions.html b/core/templates/core/terms_conditions.html index a8545cb..58ce6cf 100644 --- a/core/templates/core/terms_conditions.html +++ b/core/templates/core/terms_conditions.html @@ -5,7 +5,7 @@

{% trans "Terms and Conditions" %}

diff --git a/core/templates/core/track.html b/core/templates/core/track.html index 0dcae19..b791efa 100644 --- a/core/templates/core/track.html +++ b/core/templates/core/track.html @@ -7,6 +7,13 @@
+ + +

{% trans "Track Your Shipment" %}

diff --git a/core/templates/core/verify_otp.html b/core/templates/core/verify_otp.html index 71d3309..2b70ea5 100644 --- a/core/templates/core/verify_otp.html +++ b/core/templates/core/verify_otp.html @@ -11,7 +11,7 @@ diff --git a/core/templates/core/verify_registration.html b/core/templates/core/verify_registration.html index c35a57b..8dc9648 100644 --- a/core/templates/core/verify_registration.html +++ b/core/templates/core/verify_registration.html @@ -11,7 +11,7 @@ diff --git a/core/urls.py b/core/urls.py index 1a0424f..0286564 100644 --- a/core/urls.py +++ b/core/urls.py @@ -34,6 +34,8 @@ urlpatterns = [ path('dashboard/', views.dashboard, name='dashboard'), path('scan-qr/', views.scan_qr_view, name='scan_qr'), path('shipment-request/', views.shipment_request, name='shipment_request'), + path('parcel//edit/', views.edit_parcel, name='edit_parcel'), + path('parcel//cancel/', views.cancel_parcel, name='cancel_parcel'), path('track/', views.track_parcel, name='track'), path('accept-parcel//', views.accept_parcel, name='accept_parcel'), path('update-status//', views.update_status, name='update_status'), diff --git a/core/views.py b/core/views.py index a33f5c2..7006de7 100644 --- a/core/views.py +++ b/core/views.py @@ -848,4 +848,36 @@ def update_parcel_status_ajax(request): return JsonResponse({'success': True}) except Exception as e: - return JsonResponse({'success': False, 'error': str(e)}) \ No newline at end of file + return JsonResponse({'success': False, 'error': str(e)}) + +@login_required +def edit_parcel(request, parcel_id): + parcel = get_object_or_404(Parcel, id=parcel_id, shipper=request.user) + + if parcel.status != 'pending': + messages.error(request, _("You can only edit pending shipments.")) + return redirect('dashboard') + + if request.method == 'POST': + form = ParcelForm(request.POST, instance=parcel) + if form.is_valid(): + form.save() + messages.success(request, _("Shipment updated successfully.")) + return redirect('dashboard') + else: + form = ParcelForm(instance=parcel) + + return render(request, 'core/edit_parcel.html', {'form': form, 'parcel': parcel}) + +@login_required +def cancel_parcel(request, parcel_id): + parcel = get_object_or_404(Parcel, id=parcel_id, shipper=request.user) + + if parcel.status != 'pending': + messages.error(request, _("You can only cancel pending shipments.")) + else: + parcel.status = 'cancelled' + parcel.save() + messages.success(request, _("Shipment cancelled successfully.")) + + return redirect('dashboard') diff --git a/locale/ar/LC_MESSAGES/django.mo b/locale/ar/LC_MESSAGES/django.mo index 84a3de1..143d59f 100644 Binary files a/locale/ar/LC_MESSAGES/django.mo and b/locale/ar/LC_MESSAGES/django.mo differ diff --git a/locale/ar/LC_MESSAGES/django.po b/locale/ar/LC_MESSAGES/django.po index ec3afaf..c84ef06 100644 --- a/locale/ar/LC_MESSAGES/django.po +++ b/locale/ar/LC_MESSAGES/django.po @@ -772,7 +772,8 @@ msgstr "مرحباً،" msgid "" "You are receiving this email because you requested a password reset for your " "account at" -msgstr "تتلقى هذه الرسالة لأنك طلبت إعادة تعيين كلمة المرور لحسابك في" +msgstr "" +"تتلقى هذه الرسالة لأنك طلبت إعادة تعيين كلمة المرور لحسابك في" #: core/templates/core/emails/password_reset_email.html:11 msgid "Please click the button below to choose a new password:" @@ -879,7 +880,8 @@ msgstr "أدرج طردك" #: core/templates/core/index.html:64 msgid "" "Enter shipment details, weight, and delivery addresses. It's quick and easy." -msgstr "أدخل تفاصيل الشحنة والوزن وعناوين التوصيل. إنه سريع وسهل." +msgstr "" +"أدخل تفاصيل الشحنة والوزن وعناوين التوصيل. إنه سريع وسهل." #: core/templates/core/index.html:72 msgid "Connect with Driver" @@ -888,7 +890,8 @@ msgstr "تواصل مع السائق" #: core/templates/core/index.html:73 msgid "" "A verified car owner near you picks up the parcel and starts the journey." -msgstr "يقوم صاحب سيارة تم التحقق منه بالقرب منك باستلام الطرد وبدء الرحلة." +msgstr "" +"يقوم صاحب سيارة تم التحقق منه بالقرب منك باستلام الطرد وبدء الرحلة." #: core/templates/core/index.html:81 msgid "Secure Delivery" @@ -1330,3 +1333,60 @@ msgstr "لا توجد شحنات بعد. ابدأ الشحن الآن!" msgid "Shipments" msgstr "شحنات" + +msgid "Track Shipment" +msgstr "تتبع الشحنة" + +msgid "Track Your Shipment" +msgstr "تتبع شحنتك" + +msgid "Enter Tracking ID (e.g. TRK123456789)" +msgstr "أدخل رقم التتبع (مثال: TRK123456789)" + +msgid "Shipment Status" +msgstr "حالة الشحنة" + +msgid "Order Placed" +msgstr "تم الطلب" + +msgid "On the Way" +msgstr "في الطريق" + +msgid "Current Status" +msgstr "الحالة الحالية" + +msgid "Last Updated" +msgstr "آخر تحديث" + +msgid "Enter your tracking number above to see shipment details." +msgstr "أدخل رقم التتبع أعلاه لرؤية تفاصيل الشحنة." + +msgid "Label" +msgstr "الملصق" + +msgid "Invoice" +msgstr "الفاتورة" + +msgid "Edit" +msgstr "تعديل" + +msgid "Edit Shipment" +msgstr "تعديل الشحنة" + +msgid "Cancel Shipment" +msgstr "إلغاء الشحنة" + +msgid "Print Label" +msgstr "طباعة الملصق" + +msgid "Are you sure you want to cancel this shipment?" +msgstr "هل أنت متأكد أنك تريد إلغاء هذه الشحنة؟" + +msgid "Point your camera at the Parcel Label QR Code" +msgstr "وجه الكاميرا نحو رمز الاستجابة السريعة (QR) الخاص بالملصق" + +msgid "Scan QR Code" +msgstr "مسح رمز الاستجابة السريعة" + +msgid "Tracking No" +msgstr "رقم التتبع"