diff --git a/core/__pycache__/forms.cpython-311.pyc b/core/__pycache__/forms.cpython-311.pyc index 3413c54..c527124 100644 Binary files a/core/__pycache__/forms.cpython-311.pyc and b/core/__pycache__/forms.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index bd7f79b..1e2cecb 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 7e0c4eb..4be52ff 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 fff309e..aa0fd4f 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 cf0410e..f3bf8df 100644 --- a/core/forms.py +++ b/core/forms.py @@ -35,8 +35,8 @@ class TruckForm(forms.ModelForm): model = Truck fields = [ 'truck_type', 'truck_type_ar', 'model', 'model_ar', 'year', 'plate_no', - 'load_capacity', 'load_capacity_ar', 'color', 'color_ar', 'truck_picture', - 'registration_front', 'registration_back', 'driver_license' + 'load_capacity', 'load_capacity_ar', 'color', 'color_ar', 'registration_expiry_date', + 'truck_picture', 'registration_front', 'registration_back', 'driver_license' ] widgets = { 'truck_type': forms.TextInput(attrs={'class': 'form-control', 'placeholder': _('e.g. Flatbed')}), @@ -49,6 +49,7 @@ class TruckForm(forms.ModelForm): 'load_capacity_ar': forms.TextInput(attrs={'class': 'form-control'}), 'color': forms.TextInput(attrs={'class': 'form-control'}), 'color_ar': forms.TextInput(attrs={'class': 'form-control'}), + 'registration_expiry_date': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}), 'truck_picture': forms.FileInput(attrs={'class': 'form-control'}), 'registration_front': forms.FileInput(attrs={'class': 'form-control'}), 'registration_back': forms.FileInput(attrs={'class': 'form-control'}), diff --git a/core/migrations/0005_truck_registration_expiry_date.py b/core/migrations/0005_truck_registration_expiry_date.py new file mode 100644 index 0000000..ad79bfd --- /dev/null +++ b/core/migrations/0005_truck_registration_expiry_date.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.7 on 2026-01-23 10:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0004_truck_color_ar_truck_load_capacity_ar_truck_model_ar_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='truck', + name='registration_expiry_date', + field=models.DateField(blank=True, null=True, verbose_name='Registration Expiry Date'), + ), + ] diff --git a/core/migrations/__pycache__/0005_truck_registration_expiry_date.cpython-311.pyc b/core/migrations/__pycache__/0005_truck_registration_expiry_date.cpython-311.pyc new file mode 100644 index 0000000..816571b Binary files /dev/null and b/core/migrations/__pycache__/0005_truck_registration_expiry_date.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 303973b..94a9344 100644 --- a/core/models.py +++ b/core/models.py @@ -35,6 +35,7 @@ class Truck(models.Model): year = models.PositiveIntegerField(_('Year')) plate_no = models.CharField(_('Plate No'), max_length=50) + registration_expiry_date = models.DateField(_('Registration Expiry Date'), null=True, blank=True) # Pictures truck_picture = models.ImageField(_('Truck Picture'), upload_to='trucks/', blank=True, null=True) @@ -131,4 +132,4 @@ def save_user_profile(sender, instance, **kwargs): if hasattr(instance, 'profile'): instance.profile.save() else: - Profile.objects.create(user=instance) + Profile.objects.create(user=instance) \ No newline at end of file diff --git a/core/templates/core/admin_dashboard.html b/core/templates/core/admin_dashboard.html index 995f10a..7fcc93d 100644 --- a/core/templates/core/admin_dashboard.html +++ b/core/templates/core/admin_dashboard.html @@ -83,6 +83,7 @@ data-truck-capacity="{{ truck.display_load_capacity }}" data-truck-color="{{ truck.display_color }}" data-truck-owner="{{ truck.owner.username }}" + data-truck-expiry="{{ truck.registration_expiry_date }}" data-truck-picture="{% if truck.truck_picture %}{{ truck.truck_picture.url }}{% endif %}" data-reg-front="{% if truck.registration_front %}{{ truck.registration_front.url }}{% endif %}" data-reg-back="{% if truck.registration_back %}{{ truck.registration_back.url }}{% endif %}" @@ -140,6 +141,7 @@ data-truck-capacity="{{ truck.display_load_capacity }}" data-truck-color="{{ truck.display_color }}" data-truck-owner="{{ truck.owner.username }}" + data-truck-expiry="{{ truck.registration_expiry_date }}" data-truck-picture="{% if truck.truck_picture %}{{ truck.truck_picture.url }}{% endif %}" data-reg-front="{% if truck.registration_front %}{{ truck.registration_front.url }}{% endif %}" data-reg-back="{% if truck.registration_back %}{{ truck.registration_back.url }}{% endif %}" @@ -199,6 +201,10 @@ {% trans "Color" %}: + + {% trans "Expiry Date" %}: + + {% trans "Owner" %}: @@ -313,6 +319,7 @@ document.getElementById('modal-truck-capacity').textContent = data.truckCapacity; document.getElementById('modal-truck-color').textContent = data.truckColor; document.getElementById('modal-truck-owner').textContent = data.truckOwner; + document.getElementById('modal-truck-expiry').textContent = data.truckExpiry || '{% trans "N/A" %}'; // Populate images const imgFields = [ @@ -359,4 +366,4 @@ border-bottom: none; } -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/core/templates/core/truck_owner_dashboard.html b/core/templates/core/truck_owner_dashboard.html index 130904e..f51caf0 100644 --- a/core/templates/core/truck_owner_dashboard.html +++ b/core/templates/core/truck_owner_dashboard.html @@ -38,6 +38,12 @@

{% trans "Plate No:" %} {{ truck.plate_no }}

{% trans "Model:" %} {{ truck.display_model }} ({{ truck.year }})

{% trans "Capacity:" %} {{ truck.display_load_capacity }}

+ {% if truck.registration_expiry_date %} +

{% trans "Expiry Date:" %} {{ truck.registration_expiry_date }}

+ {% endif %} + + {% trans "Edit Details" %} + -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/core/templates/core/truck_register.html b/core/templates/core/truck_register.html index 13077cd..f8a3560 100644 --- a/core/templates/core/truck_register.html +++ b/core/templates/core/truck_register.html @@ -7,7 +7,13 @@
-

{% trans "Register a Truck" %}

+

+ {% if edit_mode %} + {% trans "Update Truck Data" %} + {% else %} + {% trans "Register a Truck" %} + {% endif %} +

{% if form.errors %}
@@ -45,7 +51,7 @@
-
{% trans "Arabic Details" %}
+
{% trans "التفاصيل باللغة العربية" %}
{{ form.truck_type_ar }} @@ -72,16 +78,21 @@
{% trans "General Information" %}
-
+
{{ form.year }} {{ form.year.errors }}
-
+
{{ form.plate_no }} {{ form.plate_no.errors }}
+
+ + {{ form.registration_expiry_date }} + {{ form.registration_expiry_date.errors }} +

@@ -90,11 +101,21 @@
+ {% if truck.truck_picture %} +
+ +
+ {% endif %} {{ form.truck_picture }} {{ form.truck_picture.errors }}
+ {% if truck.driver_license %} +
+ +
+ {% endif %} {{ form.driver_license }} {{ form.driver_license.errors }}
@@ -102,21 +123,37 @@
+ {% if truck.registration_front %} +
+ +
+ {% endif %} {{ form.registration_front }} {{ form.registration_front.errors }}
+ {% if truck.registration_back %} +
+ +
+ {% endif %} {{ form.registration_back }} {{ form.registration_back.errors }}
- +
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/core/urls.py b/core/urls.py index f04db88..4a39602 100644 --- a/core/urls.py +++ b/core/urls.py @@ -9,6 +9,7 @@ urlpatterns = [ path("logout/", auth_views.LogoutView.as_view(), name="logout"), path("dashboard/", views.dashboard, name="dashboard"), path("truck/register/", views.truck_register, name="truck_register"), + path("truck//edit/", views.edit_truck, name="edit_truck"), path("truck//approve/", views.approve_truck, name="approve_truck"), path("truck//suspend/", views.suspend_truck, name="suspend_truck"), path("shipment/post/", views.post_shipment, name="post_shipment"), diff --git a/core/views.py b/core/views.py index f30c2dc..e95fd1a 100644 --- a/core/views.py +++ b/core/views.py @@ -86,6 +86,25 @@ def truck_register(request): return render(request, 'core/truck_register.html', {'form': form}) +@login_required +def edit_truck(request, truck_id): + truck = get_object_or_404(Truck, id=truck_id, owner=request.user) + + if request.method == 'POST': + form = TruckForm(request.POST, request.FILES, instance=truck) + if form.is_valid(): + truck = form.save(commit=False) + truck.is_approved = False # Reset approval status on update + truck.save() + messages.success(request, _("Truck data updated successfully! It will be reviewed by admin again.")) + return redirect('dashboard') + else: + messages.error(request, _("There was an error updating your truck. Please check the form.")) + else: + form = TruckForm(instance=truck) + + return render(request, 'core/truck_register.html', {'form': form, 'edit_mode': True, 'truck': truck}) + @login_required def approve_truck(request, truck_id): if not (request.user.profile.role == 'ADMIN' or request.user.is_superuser): diff --git a/locale/ar/LC_MESSAGES/django.mo b/locale/ar/LC_MESSAGES/django.mo index 637a85b..014effb 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 abf656b..866b078 100644 --- a/locale/ar/LC_MESSAGES/django.po +++ b/locale/ar/LC_MESSAGES/django.po @@ -469,10 +469,8 @@ msgstr "محلياً ودولياً" #: core/templates/core/index.html:15 -msgid """The most reliable platform connecting shippers with truck owners across the ""region. Transparent, fast, and secure." -msgstr "" -"المنصة الأكثر موثوقية لربط الشاحنين مع أسطول الشاحنات في جميع أنحاء المنطقة. " -"شفافة، سريعة، وآمنة." +msgid "The most reliable platform connecting shippers with truck owners across the region. Transparent, fast, and secure." +msgstr "المنصة الأكثر موثوقية لربط الشاحنين مع أسطول الشاحنات في جميع أنحاء المنطقة. شفافة، سريعة، وآمنة." #: core/templates/core/index.html:18 @@ -501,10 +499,8 @@ msgstr "أنا شاحن" #: core/templates/core/index.html:45 -msgid """I need to move goods locally or abroad. Post your shipment, receive offers ""from verified drivers, and track your cargo in real-time." -msgstr "" -"أريد نقل بضائع محلياً أو دولياً. انشر شحنتك، واستقبل عروضاً من سائقين موثقين، " -"وتتبع شحنتك في الوقت الفعلي." +msgid "I need to move goods locally or abroad. Post your shipment, receive offers from verified drivers, and track your cargo in real-time." +msgstr "أريد نقل بضائع محلياً أو دولياً. انشر شحنتك، واستقبل عروضاً من سائقين موثقين، وتتبع شحنتك في الوقت الفعلي." #: core/templates/core/index.html:48 @@ -533,10 +529,8 @@ msgstr "أنا صاحب شاحنة" #: core/templates/core/index.html:63 -msgid """I have trucks and want to find cargo to transport. Register your fleet, bid ""on available jobs, and grow your business." -msgstr "" -"لدي شاحنات وأريد العثور على بضائع لنقلها. سجل أسطولك، وقدم عروضك على الوظائف " -"المتاحة، ونمِ عملك." +msgid "I have trucks and want to find cargo to transport. Register your fleet, bid on available jobs, and grow your business." +msgstr "لدي شاحنات وأريد العثور على بضائع لنقلها. سجل أسطولك، وقدم عروضك على الوظائف المتاحة، ونمِ عملك." #: core/templates/core/index.html:66 @@ -998,3 +992,33 @@ msgstr "خطأ في تقديم العرض. يرجى التحقق من النمو #: core/views.py:195 msgid "Bid accepted! Shipment is now in progress." msgstr "تم قبول العرض! الشحنة قيد التنفيذ الآن." + +msgid "Update Truck Data" +msgstr "تحديث بيانات الشاحنة" + +msgid "Update and Submit for Approval" +msgstr "تحديث وإرسال للاعتماد" + +msgid "Edit Details" +msgstr "تعديل التفاصيل" + +msgid "Registration Expiry Date" +msgstr "تاريخ انتهاء التسجيل" + +msgid "Expiry Date" +msgstr "تاريخ الانتهاء" + +msgid "Expiry Date:" +msgstr "تاريخ الانتهاء:" + +msgid "التفاصيل باللغة العربية" +msgstr "التفاصيل باللغة العربية" + +msgid "Edit Truck" +msgstr "تعديل الشاحنة" + +msgid "Truck data updated successfully! It will be reviewed by admin again." +msgstr "تم تحديث بيانات الشاحنة بنجاح! سيتم مراجعتها من قبل المسؤول مرة أخرى." + +msgid "There was an error updating your truck. Please check the form." +msgstr "حدث خطأ أثناء تحديث شاحنتك. يرجى التحقق من النموذج." \ No newline at end of file