Skip to content

Commit

Permalink
add consultant contact points to contact list
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalfox committed Aug 4, 2023
1 parent e13f1c6 commit 752500d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions crm/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

class ContactTableDT(PydiciNonPublicdMixin, ThirdPartyMixin, BaseDatatableView):
"""Contact tables backend for datatables"""
columns = ("name", "companies", "function", "email", "phone", "mobile_phone", "fax")
columns = ("name", "companies", "function", "email", "phone", "mobile_phone", "contacts")
order_columns = columns
max_display_length = 500


def get_initial_queryset(self):
return Contact.objects.all()
return Contact.objects.all().prefetch_related("contact_points")

def filter_queryset(self, qs):
""" simple search on some attributes"""
Expand All @@ -33,6 +33,8 @@ def filter_queryset(self, qs):
Q(email__icontains=search) |
Q(mobile_phone__icontains=search) |
Q(fax__icontains=search) |
Q(contact_points__name__icontains=search) |
Q(contact_points__trigramme__icontains=search) |
Q(phone__icontains=search) |
Q(client__organisation__company__name__icontains=search)
).distinct()
Expand All @@ -41,6 +43,8 @@ def filter_queryset(self, qs):
def render_column(self, row, column):
if column == "companies":
return row.companies(html=True)
elif column == "contacts":
return ", ".join([c.name for c in row.contact_points.all()])
else:
return super(ContactTableDT, self).render_column(row, column)

2 changes: 1 addition & 1 deletion templates/crm/contact_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<th>{% trans "email" %}</th>
<th>{% trans "phone" %}</th>
<th>{% trans "mobile phone" %}</th>
<th>{% trans "fax" %}</th>
<th>{% trans "contacts" %}</th>
</tr>
</thead>
<tbody>
Expand Down

0 comments on commit 752500d

Please sign in to comment.