mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-19 14:03:52 -04:00
Add property to construct account type string
This allows us to start decoupling the form fields from the final, hyphenated string, which we'll do in the next commits. Note that I've also removed the conditional that changes the data of the network field as part of validating it. We shouldn't change data in validations, and having the new property directly above makes it clear there's no need for this code.
This commit is contained in:
@@ -2430,11 +2430,18 @@ class ServiceBroadcastNetworkForm(StripWhitespaceForm):
|
||||
thing='a mobile network',
|
||||
)
|
||||
|
||||
@property
|
||||
def account_type(self):
|
||||
if self.network_variant.data == f'live-{self.broadcast_channel}-all':
|
||||
provider = 'all'
|
||||
else:
|
||||
provider = self.network.provider_restriction
|
||||
|
||||
return f'live-{self.broadcast_channel}-{provider}'
|
||||
|
||||
def validate_network(self, field):
|
||||
if not self.network_variant.data and not field.data:
|
||||
raise ValidationError('Select a mobile network')
|
||||
if self.network_variant.data == 'all':
|
||||
field.data = ''
|
||||
|
||||
|
||||
class ServiceBroadcastAccountTypeForm(StripWhitespaceForm):
|
||||
|
||||
Reference in New Issue
Block a user