From 255c08b74b688e67b554c7d2d06d99564751bf04 Mon Sep 17 00:00:00 2001 From: ismail Date: Wed, 10 Sep 2025 15:45:23 +0300 Subject: [PATCH] update pricing --- inventory/forms.py | 3 +- inventory/urls.py | 1 + inventory/views.py | 25 +++++++---- templates/plans/payment_failed.html | 50 +++++++++++++++++++++ templates/plans/payment_success.html | 50 +++++++++++++++++++++ templates/pricing_page.html | 66 +++++++++++++++++----------- 6 files changed, 159 insertions(+), 36 deletions(-) create mode 100644 templates/plans/payment_failed.html create mode 100644 templates/plans/payment_success.html diff --git a/inventory/forms.py b/inventory/forms.py index 5235df73..3c88aed5 100644 --- a/inventory/forms.py +++ b/inventory/forms.py @@ -2133,7 +2133,8 @@ class VatRateForm(forms.ModelForm): label="VAT Rate", max_digits=5, decimal_places=2, - validators=[vat_rate_validator] + validators=[vat_rate_validator], + help_text=_("VAT rate as decimal between 0 and 1 (e.g., 0.2 for 20%)"), ) class Meta: diff --git a/inventory/urls.py b/inventory/urls.py index 440ce88a..d3b39132 100644 --- a/inventory/urls.py +++ b/inventory/urls.py @@ -1332,6 +1332,7 @@ urlpatterns = [ path('/help_center/tickets//', views.ticket_detail, name='ticket_detail'), path('help_center/tickets//update/', views.ticket_update, name='ticket_update'), # path('help_center/tickets//ticket_mark_resolved/', views.ticket_mark_resolved, name='ticket_mark_resolved'), + path('payment_results/', views.payment_result, name='payment_result'), ] diff --git a/inventory/views.py b/inventory/views.py index d053a04c..c9ac5324 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -2336,28 +2336,28 @@ class DealerDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView): return context -from .forms import VatRateForm +from .forms import VatRateForm @login_required def dealer_vat_rate_update(request, slug): dealer = get_object_or_404(models.Dealer, slug=slug) - + vat_rate_instance, created = models.VatRate.objects.get_or_create(dealer=dealer) if request.method == "POST": - + form = VatRateForm(request.POST, instance=vat_rate_instance) - + if form.is_valid(): form.save() messages.success(request, _("VAT rate updated successfully")) return redirect("dealer_detail", slug=slug) else: - + messages.error(request, _("Please enter valid vat rate between 0 and 1.")) redirect("dealer_detail", slug=slug) return redirect("dealer_detail", slug=slug) - + class DealerUpdateView( LoginRequiredMixin, PermissionRequiredMixin, SuccessMessageMixin, UpdateView @@ -9867,7 +9867,8 @@ def payment_callback(request, dealer_slug): payment_status = request.GET.get("status") logger.info(f"Received payment callback for dealer_slug: {dealer_slug}, payment_id: {payment_id}, status: {payment_status}") order = Order.objects.filter(user=dealer.user, status=1).first() # Status 1 = NEW - + if history.status == "paid": + return redirect('home') if payment_status == "paid": logger.info(f"Payment successful for transaction ID {payment_id}. Processing order completion.") @@ -10764,7 +10765,7 @@ class PurchaseOrderListView(LoginRequiredMixin, PermissionRequiredMixin, ListVie context = super().get_context_data(**kwargs) context["entity_slug"] = dealer.entity.slug context["vendors"] = vendors - context["empty_state_value"] = _("purchase order") + context["empty_state_value"] = _("purchase order") return context @@ -11762,4 +11763,10 @@ class CarDealershipSignUpView(CreateView): def form_valid(self, form): response = super().form_valid(form) messages.success(self.request, _('Your request has been submitted. We will contact you soon.')) - return response \ No newline at end of file + return response + +def payment_result(request): + s = request.GET.get("status") + if s == "success": + return render(request, 'plans/payment_success.html') + return render(request, 'plans/payment_failed.html') diff --git a/templates/plans/payment_failed.html b/templates/plans/payment_failed.html new file mode 100644 index 00000000..52346f1d --- /dev/null +++ b/templates/plans/payment_failed.html @@ -0,0 +1,50 @@ +{% extends "base.html" %} +{% load i18n static %} +{% block content %} +
+
+
+

{% trans "Payment Failed" %}

+ +
+
+ +
+
+
+
+
+ +
+ +

{% trans "Payment Failed" %}

+ + {% if message %} +

{{ message }}.

+ {% else %} +

+ {% trans "We couldn't process your payment. Please review your information and try again." %} +

+ {% endif %} + + +
+
+
+
+
+{% endblock content %} \ No newline at end of file diff --git a/templates/plans/payment_success.html b/templates/plans/payment_success.html new file mode 100644 index 00000000..397eeb4f --- /dev/null +++ b/templates/plans/payment_success.html @@ -0,0 +1,50 @@ +{% extends "base.html" %} +{% load i18n static %} + +{% block content %} +
+
+
+

{% trans "Payment Successful" %}

+ +
+
+ +
+
+
+
+
+ +
+ +

{{ _("Thank You") }}!

+ +

+ {{ _("Your payment was successful") }}. {{ _("Your order is being processed") }}. +

+ + +
+
+
+
+
+{% endblock content %} \ No newline at end of file diff --git a/templates/pricing_page.html b/templates/pricing_page.html index ea6fb80a..af0b8223 100644 --- a/templates/pricing_page.html +++ b/templates/pricing_page.html @@ -8,7 +8,7 @@ {% block customCSS %} {% endblock customCSS %} + {% block content %}

{{ _("Choose Your Plan") }}

@@ -256,6 +256,7 @@
+

{{ _("2. Enter Your Information") }}

@@ -335,6 +336,7 @@
+

{{ _("3. Payment Information") }}

@@ -414,6 +416,7 @@
+

{{ _("4. Confirm Your Information") }}

@@ -423,10 +426,10 @@

{{ _("Plan") }}:

-

{{ _("Price") }}:

+

{{ _("Price (excl. VAT)") }}:

-

{{ _("VAT") }} (15%): 0.00

+

{{ _("VAT") }} (15%):


@@ -458,6 +461,7 @@
+
-{% endblock content %} +{% endblock content %} {% block customJS %}