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

Fix confirmation name and breakdown year in dataset for Export wins. #5356

Merged
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
4 changes: 2 additions & 2 deletions datahub/dataset/export_wins/test/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class TestExportWinsBreakdownDatasetView(BaseDatasetViewTest):

def _assert_breakdown_matches_result(self, breakdown, result):
financial_year = get_financial_year(
breakdown.win.created_on + relativedelta(years=breakdown.year - 1),
breakdown.win.date + relativedelta(years=breakdown.year - 1),
)
assert result == {
'created_on': format_date_or_datetime(breakdown.created_on),
Expand Down Expand Up @@ -209,7 +209,7 @@ def _assert_win_matches_result(
win.customer_response.interventions_were_prerequisite if has_responded else None,
'confirmation__involved_state_enterprise':
win.customer_response.involved_state_enterprise if has_responded else None,
'confirmation__name': win.customer_response.name,
'confirmation__name': contact.name,
'confirmation__other_marketing_source':
win.customer_response.other_marketing_source if has_responded else None,
'confirmation__our_support':
Expand Down
10 changes: 5 additions & 5 deletions datahub/dataset/export_wins/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def get_dataset(self):
return (
Breakdown.objects.select_related('win, breakdown_type')
.annotate(
created_year=ExtractYear('win__created_on'),
created_month=ExtractMonth('win__created_on'),
won_year=ExtractYear('win__date'),
won_month=ExtractMonth('win__date'),
provisional_financial_year=Case(
When(created_month__gte=4, then=F('created_year')),
When(won_month__gte=4, then=F('won_year')),
default=ExpressionWrapper(
F('created_year') - 1,
F('won_year') - 1,
output_field=IntegerField(),
),
output_field=IntegerField(),
Expand Down Expand Up @@ -278,7 +278,7 @@ def get_dataset(self):
default=F('customer_response__involved_state_enterprise'),
output_field=BooleanField(),
),
confirmation__name=F('customer_response__name'),
confirmation__name=F('customer_details__name'),
confirmation__other_marketing_source=F(
'customer_response__other_marketing_source',
),
Expand Down
1 change: 1 addition & 0 deletions datahub/export_win/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ class CustomerResponse(BaseModel):
default='',
verbose_name='Other comments or changes to the win details',
)
# name is a legacy field. Should only be used when importing legacy data.
name = models.CharField(max_length=256, verbose_name='Your name')
marketing_source = models.ForeignKey(
MarketingSource,
Expand Down
Loading