Skip to content

Commit

Permalink
Add NN Status to Query Form (#779)
Browse files Browse the repository at this point in the history
* Add nn status

* Add option to query by member name to query form

* lint

* Add test
  • Loading branch information
WillNilges authored Dec 12, 2024
1 parent 1931b2a commit 03f75b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/meshapi/serializers/query_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Meta:
"additional_email_addresses",
"notes",
"network_number",
"network_number_status",
"status",
)

Expand All @@ -42,6 +43,7 @@ class Meta:
)

network_number = serializers.IntegerField(source="node.network_number", allow_null=True)
network_number_status = serializers.CharField(source="node.status", allow_null=True)

primary_email_address = serializers.CharField(source="member.primary_email_address")
stripe_email_address = serializers.CharField(source="member.stripe_email_address")
Expand Down
3 changes: 3 additions & 0 deletions src/meshapi/tests/test_query_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ def test_query_address(self):
def test_query_email(self):
self.query("members", "email_address", self.install.member.primary_email_address)

def test_query_name(self):
self.query("members", "name", self.install.member.name)

def test_query_nn(self):
self.query("installs", "network_number", self.install.node.network_number)
5 changes: 4 additions & 1 deletion src/meshapi/views/query_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@


class QueryMemberFilter(filters.FilterSet):
name = filters.CharFilter(field_name="member.name", lookup_expr="icontains")
name = filters.CharFilter(method="filter_on_member_name")
email_address = filters.CharFilter(method="filter_on_all_emails")
phone_number = filters.CharFilter(method="filter_on_all_phone_numbers")

def filter_on_member_name(self, queryset: QuerySet[Member], field_name: str, value: str) -> QuerySet[Member]:
return queryset.filter(Q(member__name__icontains=value))

def filter_on_all_emails(self, queryset: QuerySet[Member], field_name: str, value: str) -> QuerySet[Member]:
return queryset.filter(
Q(member__primary_email_address__icontains=value)
Expand Down

0 comments on commit 03f75b1

Please sign in to comment.