Skip to content

Commit

Permalink
fix(sage_invoice): solve slug problem
Browse files Browse the repository at this point in the history
  • Loading branch information
sepehr-akbarzadeh committed Sep 8, 2024
1 parent 00ab052 commit 1dad1a5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions sage_invoice/models/invoice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.urls import reverse
from sage_tools.mixins.models import TitleSlugMixin

from sage_invoice.helpers.choice import InvoiceStatus
Expand Down Expand Up @@ -101,6 +102,9 @@ def clean(self):
if self.due_date < self.invoice_date:
raise ValidationError(_("Due Date must be later than Invoice Date."))

def get_absolute_url(self):
return reverse('invoice_detail', kwargs={'slug': self.slug})

class Meta:
verbose_name = _("Invoice")
verbose_name_plural = _("Invoices")
Expand Down
2 changes: 1 addition & 1 deletion sage_invoice/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

urlpatterns = [
path(
"invoice/<str:invoice_slug>/",
"invoice/<slug:slug>/",
InvoiceDetailView.as_view(),
name="invoice_detail",
),
Expand Down
2 changes: 1 addition & 1 deletion sage_invoice/views/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class InvoiceDetailView(TemplateView):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
invoice_slug = self.kwargs.get("invoice_slug")
invoice_slug = self.kwargs.get("slug")
invoice = Invoice.objects.filter(slug=invoice_slug)
service = QuotationService()
rendered_content = service.render_contax(invoice)
Expand Down

0 comments on commit 1dad1a5

Please sign in to comment.