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

Stop overriding dit_adviser for new interactions #253

Merged
merged 2 commits into from
Jun 13, 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
10 changes: 6 additions & 4 deletions datahub/interaction/test/test_interaction_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ def test_interaction_detail_view(self):
@freeze_time('2017-04-18 13:25:30.986208+00:00')
def test_add_interaction(self):
"""Test add new interaction."""
adviser = AdviserFactory()
url = reverse('api-v1:interaction-list')
response = self.api_client.post(url, {
'interaction_type': constants.InteractionType.business_card.value.id,
'subject': 'whatever',
'date': now().isoformat(),
'dit_adviser': AdviserFactory().pk,
'dit_adviser': adviser.pk,
'notes': 'hello',
'company': CompanyFactory().pk,
'contact': ContactFactory().pk,
Expand All @@ -40,20 +41,21 @@ def test_add_interaction(self):

assert response.status_code == status.HTTP_201_CREATED
response_data = response.json()
assert response_data['dit_adviser'] == str(self.user.pk)
assert response_data['dit_adviser'] == str(adviser.pk)
assert response_data['modified_on'] == '2017-04-18T13:25:30.986208'
assert response_data['created_on'] == '2017-04-18T13:25:30.986208'

@freeze_time('2017-04-18 13:25:30.986208+00:00')
def test_add_interaction_project(self):
"""Test add new interaction for an investment project."""
project = InvestmentProjectFactory()
adviser = AdviserFactory()
url = reverse('api-v1:interaction-list')
response = self.api_client.post(url, {
'interaction_type': constants.InteractionType.business_card.value.id,
'subject': 'whatever',
'date': now().isoformat(),
'dit_adviser': AdviserFactory().pk,
'dit_adviser': adviser.pk,
'notes': 'hello',
'investment_project': project.pk,
'service': constants.Service.trade_enquiry.value.id,
Expand All @@ -62,7 +64,7 @@ def test_add_interaction_project(self):

assert response.status_code == status.HTTP_201_CREATED
response_data = response.json()
assert response_data['dit_adviser'] == str(self.user.pk)
assert response_data['dit_adviser'] == str(adviser.pk)
assert response_data['investment_project'] == str(project.pk)
assert response_data['modified_on'] == '2017-04-18T13:25:30.986208'
assert response_data['created_on'] == '2017-04-18T13:25:30.986208'
Expand Down
7 changes: 0 additions & 7 deletions datahub/interaction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,3 @@ class InteractionViewSetV1(CoreViewSetV1):
DjangoFilterBackend,
)
filter_fields = ['contact_id', 'investment_project_id']

def get_additional_data(self, create):
"""Set dit_adviser to the user on model instance creation."""
data = {}
if create:
data['dit_adviser'] = self.request.user
return data