changing shipment form

This commit is contained in:
Flatlogic Bot 2026-01-24 07:29:53 +00:00
parent 3c28f6ef41
commit cdda269c57
7 changed files with 40 additions and 5 deletions

View File

@ -63,12 +63,12 @@ class Profile(models.Model):
is_subscription_active = models.BooleanField(default=False)
def is_expired(self):
if self.subscription_plan == "NONE":
return False
if not self.is_subscription_active:
return True
if not self.subscription_expiry:
return True
return self.subscription_expiry < timezone.now().date()
def days_until_expiry(self):
if not self.subscription_expiry:
return 0
delta = self.subscription_expiry - timezone.now().date()

View File

@ -46,6 +46,11 @@
<small class="text-muted">{% trans "Owner" %}: {{ truck.owner.username }} | {% trans "Plate" %}: {{ truck.plate_no }}</small>
</div>
</div>
<div class="mb-3">
<label class="form-label fw-bold">{{ form.required_truck_type_link.label }}</label>
{{ form.required_truck_type_link }}
{{ form.required_truck_type_link.errors }}
</div>
</div>
</div>

View File

@ -44,7 +44,21 @@
</div>
</div>
</div>
<!-- Add more stats here if needed -->
<div class="col-md-3 mb-3">
<div class="card shadow-sm border-0 h-100">
<div class="card-body">
<h6 class="text-uppercase small text-muted">{% trans "Subscription" %}</h6>
{% if request.user.profile.is_subscription_active %}
<h4 class="mb-1 text-success">{% trans "Active" %}</h4>
<small class="text-muted d-block mb-3">{% trans "Expires:" %} {{ request.user.profile.subscription_expiry }}</small>
{% else %}
<h4 class="mb-1 text-danger">{% trans "Inactive" %}</h4>
<small class="text-muted d-block mb-3">{% trans "Payment required" %}</small>
{% endif %}
<a href="{% url 'renew_subscription' %}" class="btn btn-outline-primary btn-sm">{% trans "Manage" %}</a>
</div>
</div>
</div>
</div>
<!-- Active Offers -->
@ -158,4 +172,4 @@
</div>
</div>
</div>
{% endblock %}
{% endblock %}

View File

@ -40,6 +40,21 @@
</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="card shadow-sm border-0 h-100">
<div class="card-body">
<h6 class="text-uppercase small text-muted">{% trans "Subscription" %}</h6>
{% if request.user.profile.is_subscription_active %}
<h4 class="mb-1 text-success">{% trans "Active" %}</h4>
<small class="text-muted d-block mb-3">{% trans "Expires:" %} {{ request.user.profile.subscription_expiry }}</small>
{% else %}
<h4 class="mb-1 text-danger">{% trans "Inactive" %}</h4>
<small class="text-muted d-block mb-3">{% trans "Payment required" %}</small>
{% endif %}
<a href="{% url 'renew_subscription' %}" class="btn btn-outline-primary btn-sm">{% trans "Manage" %}</a>
</div>
</div>
</div>
</div>
<!-- Incoming Offers Section -->
@ -148,4 +163,4 @@
{% endfor %}
</div>
</div>
{% endblock %}
{% endblock %}

View File

@ -354,6 +354,7 @@ def place_bid(request, truck_id):
shipment = Shipment.objects.create(
shipper=request.user,
description=form.cleaned_data['description'],
required_truck_type_link=form.cleaned_data["required_truck_type_link"],
weight=form.cleaned_data['weight'],
origin_country=form.cleaned_data['origin_country'],
origin_city=form.cleaned_data['origin_city'],