Skip to content

Commit

Permalink
fix - missing names
Browse files Browse the repository at this point in the history
  • Loading branch information
gfavre committed Aug 25, 2021
1 parent 919b278 commit 65d6e32
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
16 changes: 16 additions & 0 deletions beyondtheadmin/clients/models.py
Expand Up @@ -41,6 +41,12 @@ class Client(UUIDModel):
class Meta:
ordering = ('company_name', 'contact_last_name', 'country')

@property
def name(self):
if self.is_company:
return self.company_name
return self.contact_fullname

@property
def contact_fullname(self):
if self.contact_last_name:
Expand All @@ -52,13 +58,23 @@ def full_contact_email(self):
if self.contact_fullname:
return "{} <{}>".format(self.contact_fullname, self.contact_email)

@property
def is_company(self):
return self.client_type == self.TYPES.company

@property
def is_person(self):
return self.client_type == self.TYPES.person

@property
def last_invoice_date(self):
last_invoice = self.invoices.order_by('displayed_date').last()
if last_invoice:
return last_invoice.displayed_date
return None



def get_absolute_url(self):
return reverse_lazy('clients:update', kwargs={'pk': self.pk})

Expand Down
3 changes: 1 addition & 2 deletions beyondtheadmin/invoices/views/api.py
Expand Up @@ -27,8 +27,7 @@ class InvoiceLineViewSet(viewsets.ModelViewSet):
def get_queryset(self):
if 'invoice_pk' not in self.kwargs:
raise Http404()
return InvoiceLine.objects.filter(company__users=self.request.user,
invoice_id=self.kwargs['invoice_pk'])
return InvoiceLine.objects.filter(invoice_id=self.kwargs['invoice_pk'])

def perform_create(self, serializer):
serializer.save(invoice_id=self.kwargs['invoice_pk'])
2 changes: 1 addition & 1 deletion beyondtheadmin/templates/base.html
Expand Up @@ -6,7 +6,7 @@
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">

<!-- Sidebar - Brand -->
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="{% comment %}{% url 'dashboard' %}{% endcomment %}">
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="{% url 'dashboard' %}">
<div class="sidebar-brand-icon rotate-n-15">
<i class="bi bi-emoji-laughing"></i>
</div>
Expand Down

0 comments on commit 65d6e32

Please sign in to comment.