-
Notifications
You must be signed in to change notification settings - Fork 4
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
TP2000-1537 Bulk create QuotaDefinitionPeriods #1320
base: master
Are you sure you want to change the base?
Conversation
…fixing form links & next steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just some small comments
</h1> | ||
<p class="govuk-body"> | ||
You can create up to 20 quota definition periods for the same quota order number. | ||
Subsequent periodswill be calculated from the first date range entered and the data will be duplicated across all definition periods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a space
super().__init__(*args, **kwargs) | ||
self.init_layout() | ||
self.init_layout(self.request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does self.request get used in init_layout()?
|
||
# Set these as the default values | ||
self.fields["quota_critical"].initial = False | ||
self.fields["end_date"].help_text = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help text saying end date is optional is removed here but it is still optional as far as the code realises - a user not inputting an end date will need to be handled as the ValidityPeriodForm currently allows that
cleaned_data = super().clean() | ||
for field in self.required_fields: | ||
if field not in cleaned_data: | ||
raise ValidationError(f"A value for {field} must be provided") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these not handled by the fields having required=True? This just adds a second error message for the same thing e.g. both [Enter the number of definition periods to create] and [A value for instance_count must be provided]
|
||
|
||
def serialize_definition_data(definition): | ||
# Serializes data and returns a JSON dict that can be saved to session |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would these comments be better as docstrings if describing what the function does
<li><a class="govuk-link" href="{{ url('quota_definition-ui-create', args=[object.sid]) }}">Create definition period</a></li> | ||
<strong class="govuk-heading-xs">Create quota data</strong> | ||
<li><a class="govuk-link" href="{{ url('quota_definition-ui-create', args=[object.sid]) }}?order_number={{object.order_number}}">Create definition period</a></li> | ||
<li><a class="govuk-link" href="{{ url('quota_definition-ui-bulk-create', args=[object.sid]) }}">The bulk creator</a></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the name but I have a feeling it wouldn't pass the GDS naming conventions - is it clear what is being bulk created here? (Seems obvious to us)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
@@ -156,9 +156,14 @@ class Meta: | |||
"maximum_precision", | |||
] | |||
|
|||
order_number = forms.ModelChoiceField( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for adding this field in? What was happening before to get the order number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seem to be getting an error in this form that order number doesn't have a value when I submit but can't figure out why as you are assigning it an initial value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the error, but do double check it's working for you as well!
As discussed on Teams, there was an issue testing this due to inherited forms using transaction.atomic
. This was fixed by passing in the quota_order_number
in the query string and then extracting it here. The error you encountered was that, while the initial value was being set, the order_number
widget was still showing as missing a value (this error doesn't occur on the bulk creator).
The fix for this was to check if an empty value for the order_number
widget is in the form.errors
when form.clean()
is called, assign the value of cleaned_data['order_number']
as the quota_order_number
and then remove the error.
</span> | ||
</h1> | ||
<p class="govuk-body">You can create one new quota definition period using this form. Alternatively, you can <a class="govuk-link" href="{{ url('quota_definition-ui-bulk-create') }}">create multiple quota definition periods</a> for a chose quota order number.</p> | ||
{% call django_form() %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chosen*
{% block breadcrumb %} | ||
{{ breadcrumbs(request, [ | ||
{"text": "Find and edit quotas", "href": url("quota-ui-list")}, | ||
{"text": "Quota order number", "href": url("quota-ui-detail", args=[view.kwargs.sid]) ~ "#definitions"}, | ||
{"text": "Quota order number", "href": url("quota-ui-detail", args=[quota_sid]) ~ "#definitions"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate it was already like that but I'm not sure #definitions is a real anchor tag for that page. Maybe #definition-details or none at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
TP2000-1537 Bulk create QuotaDefinitionPeriods
Why
What
Following the figma design linked on the ticket and [here](Single and multiple journeys), this PR
There are four stages to the journey:
Beginning the journey from the Edit Workbasket View
submit
and the QuotaDefinitionPeriods are created and the user is taken to a standard success page.On success, the user is redirected to a standard success page with Next steps and Further actions
Design changes: