Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DH-291] Allow filtering of interactions by company ID #263

Merged
merged 1 commit into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions datahub/interaction/test/test_interaction_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ def test_modify_interaction(self):
assert response.status_code == status.HTTP_200_OK
assert response.data['subject'] == 'I am another subject'

def test_list_filtered_company(self):
"""List of interactions filtered by company"""
company1 = CompanyFactory()
company2 = CompanyFactory()

InteractionFactory.create_batch(3, company=company1)
interactions = InteractionFactory.create_batch(2, company=company2)

url = reverse('api-v1:interaction-list')
response = self.api_client.get(url, {'company_id': company2.id})

assert response.status_code == status.HTTP_200_OK
assert response.data['count'] == 2
assert {i['id'] for i in response.data['results']} == {str(i.id) for i in interactions}

def test_list_filtered_contact(self):
"""List of interactions filtered by contact"""
contact1 = ContactFactory()
Expand Down
2 changes: 1 addition & 1 deletion datahub/interaction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class InteractionViewSetV1(CoreViewSetV1):
filter_backends = (
DjangoFilterBackend,
)
filter_fields = ['contact_id', 'investment_project_id']
filter_fields = ['company_id', 'contact_id', 'investment_project_id']