Add a form to set priority of top 2 providers

Their priority should always add up to 100%. Currently we have to ensure
this by hand. Adding this form means there’s no way to not set their
combined priorities to 100%. And it’s a bit more of an intuitive UI than
two textboxes on separate pages.
This commit is contained in:
Chris Hill-Scott
2019-12-02 18:15:00 +00:00
parent 16ebdfeb8b
commit 5233ee4bd9
9 changed files with 164 additions and 6 deletions

View File

@@ -952,6 +952,22 @@ class ProviderForm(StripWhitespaceForm):
priority = IntegerField('Priority', [validators.NumberRange(min=1, max=100, message="Must be between 1 and 100")])
class ProviderRatioForm(StripWhitespaceForm):
ratio = RadioField(choices=[
(str(value), '{}% / {}%'.format(value, 100 - value))
for value in range(100, -10, -10)
])
@property
def percentage_left(self):
return int(self.ratio.data)
@property
def percentage_right(self):
return 100 - self.percentage_left
class ServiceContactDetailsForm(StripWhitespaceForm):
contact_details_type = RadioField(
'Type of contact details',