dem10
This commit is contained in:
parent
e6e1b4b0ec
commit
1f36b3f0bd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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'}),
|
||||
|
||||
18
core/migrations/0005_truck_registration_expiry_date.py
Normal file
18
core/migrations/0005_truck_registration_expiry_date.py
Normal file
@ -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'),
|
||||
),
|
||||
]
|
||||
Binary file not shown.
@ -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)
|
||||
@ -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 @@
|
||||
<td class="text-muted">{% trans "Color" %}:</td>
|
||||
<td class="fw-bold" id="modal-truck-color"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-muted">{% trans "Expiry Date" %}:</td>
|
||||
<td class="fw-bold" id="modal-truck-expiry"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-muted">{% trans "Owner" %}:</td>
|
||||
<td class="fw-bold" id="modal-truck-owner"></td>
|
||||
@ -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;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@ -38,6 +38,12 @@
|
||||
<p class="card-text mb-1"><strong>{% trans "Plate No:" %}</strong> {{ truck.plate_no }}</p>
|
||||
<p class="card-text mb-1"><strong>{% trans "Model:" %}</strong> {{ truck.display_model }} ({{ truck.year }})</p>
|
||||
<p class="card-text mb-1"><strong>{% trans "Capacity:" %}</strong> {{ truck.display_load_capacity }}</p>
|
||||
{% if truck.registration_expiry_date %}
|
||||
<p class="card-text mb-1"><strong>{% trans "Expiry Date:" %}</strong> {{ truck.registration_expiry_date }}</p>
|
||||
{% endif %}
|
||||
<a href="{% url 'edit_truck' truck.id %}" class="btn btn-outline-primary btn-sm mt-3">
|
||||
<i class="fa-solid fa-edit me-1"></i> {% trans "Edit Details" %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-footer bg-white border-0">
|
||||
<span class="badge bg-success w-100 py-2">{% trans "Approved" %}</span>
|
||||
@ -63,6 +69,9 @@
|
||||
<h5 class="card-title text-muted">{{ truck.display_truck_type }}</h5>
|
||||
<p class="card-text mb-1"><strong>{% trans "Plate No:" %}</strong> {{ truck.plate_no }}</p>
|
||||
<p class="card-text">{% trans "Submitted on:" %} {{ truck.created_at|date }}</p>
|
||||
<a href="{% url 'edit_truck' truck.id %}" class="btn btn-outline-secondary btn-sm mt-3">
|
||||
<i class="fa-solid fa-edit me-1"></i> {% trans "Edit Details" %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-footer bg-white border-0">
|
||||
<span class="badge bg-warning text-dark w-100 py-2">{% trans "Waiting for Admin Review" %}</span>
|
||||
@ -115,4 +124,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@ -7,7 +7,13 @@
|
||||
<div class="col-md-10">
|
||||
<div class="card shadow">
|
||||
<div class="card-body p-5">
|
||||
<h2 class="mb-4">{% trans "Register a Truck" %}</h2>
|
||||
<h2 class="mb-4">
|
||||
{% if edit_mode %}
|
||||
{% trans "Update Truck Data" %}
|
||||
{% else %}
|
||||
{% trans "Register a Truck" %}
|
||||
{% endif %}
|
||||
</h2>
|
||||
|
||||
{% if form.errors %}
|
||||
<div class="alert alert-danger">
|
||||
@ -45,7 +51,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<h5 class="mb-3 text-success">{% trans "Arabic Details" %}</h5>
|
||||
<h5 class="mb-3 text-success">{% trans "التفاصيل باللغة العربية" %}</h5>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">{{ form.truck_type_ar.label }}</label>
|
||||
{{ form.truck_type_ar }}
|
||||
@ -72,16 +78,21 @@
|
||||
<hr class="my-4">
|
||||
<h5 class="mb-3">{% trans "General Information" %}</h5>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label">{{ form.year.label }}</label>
|
||||
{{ form.year }}
|
||||
{{ form.year.errors }}
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label">{{ form.plate_no.label }}</label>
|
||||
{{ form.plate_no }}
|
||||
{{ form.plate_no.errors }}
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label">{{ form.registration_expiry_date.label }}</label>
|
||||
{{ form.registration_expiry_date }}
|
||||
{{ form.registration_expiry_date.errors }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="my-4">
|
||||
@ -90,11 +101,21 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">{% trans "Truck Picture" %}</label>
|
||||
{% if truck.truck_picture %}
|
||||
<div class="mb-2">
|
||||
<img src="{{ truck.truck_picture.url }}" class="img-thumbnail" style="height: 100px;">
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ form.truck_picture }}
|
||||
{{ form.truck_picture.errors }}
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">{% trans "Driver License" %}</label>
|
||||
{% if truck.driver_license %}
|
||||
<div class="mb-2">
|
||||
<img src="{{ truck.driver_license.url }}" class="img-thumbnail" style="height: 100px;">
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ form.driver_license }}
|
||||
{{ form.driver_license.errors }}
|
||||
</div>
|
||||
@ -102,21 +123,37 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">{% trans "Registration (Front Face)" %}</label>
|
||||
{% if truck.registration_front %}
|
||||
<div class="mb-2">
|
||||
<img src="{{ truck.registration_front.url }}" class="img-thumbnail" style="height: 100px;">
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ form.registration_front }}
|
||||
{{ form.registration_front.errors }}
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">{% trans "Registration (Back Face)" %}</label>
|
||||
{% if truck.registration_back %}
|
||||
<div class="mb-2">
|
||||
<img src="{{ truck.registration_back.url }}" class="img-thumbnail" style="height: 100px;">
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ form.registration_back }}
|
||||
{{ form.registration_back.errors }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100 py-3 mt-4">{% trans "Submit Registration" %}</button>
|
||||
<button type="submit" class="btn btn-primary w-100 py-3 mt-4">
|
||||
{% if edit_mode %}
|
||||
{% trans "Update and Submit for Approval" %}
|
||||
{% else %}
|
||||
{% trans "Submit Registration" %}
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@ -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/<int:truck_id>/edit/", views.edit_truck, name="edit_truck"),
|
||||
path("truck/<int:truck_id>/approve/", views.approve_truck, name="approve_truck"),
|
||||
path("truck/<int:truck_id>/suspend/", views.suspend_truck, name="suspend_truck"),
|
||||
path("shipment/post/", views.post_shipment, name="post_shipment"),
|
||||
|
||||
@ -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):
|
||||
|
||||
Binary file not shown.
@ -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 "حدث خطأ أثناء تحديث شاحنتك. يرجى التحقق من النموذج."
|
||||
Loading…
x
Reference in New Issue
Block a user