|
@@ -112,18 +112,19 @@ class VPNConfiguration(CoinLdapSyncMixin, Configuration):
|
|
|
If [delete] is True, then simply delete the faulty endpoints
|
|
|
instead of raising an exception.
|
|
|
"""
|
|
|
+ error = "L'IP {} n'est pas dans un réseau attribué."
|
|
|
subnets = self.ip_subnet.all()
|
|
|
is_faulty = lambda endpoint : endpoint and not any([endpoint in subnet.inet for subnet in subnets])
|
|
|
if is_faulty(self.ipv4_endpoint):
|
|
|
if delete:
|
|
|
self.ipv4_endpoint = None
|
|
|
else:
|
|
|
- raise ValidationError("Endpoint {} is not in an attributed range".format(self.ipv4_endpoint))
|
|
|
+ raise ValidationError(error.format(self.ipv4_endpoint))
|
|
|
if is_faulty(self.ipv6_endpoint):
|
|
|
if delete:
|
|
|
self.ipv6_endpoint = None
|
|
|
else:
|
|
|
- raise ValidationError("Endpoint {} is not in an attributed range".format(self.ipv6_endpoint))
|
|
|
+ raise ValidationError(error.format(self.ipv6_endpoint))
|
|
|
|
|
|
def clean(self):
|
|
|
# Generate VPN login, of the form "login-vpnX". The resulting
|
|
@@ -141,7 +142,7 @@ class VPNConfiguration(CoinLdapSyncMixin, Configuration):
|
|
|
break
|
|
|
# We may have failed.
|
|
|
if not self.login:
|
|
|
- ValidationError("Unable to allocate a VPN login.")
|
|
|
+ ValidationError("Impossible de générer un login VPN")
|
|
|
# Hash password if needed
|
|
|
self.password = utils.ldap_hash(self.password)
|
|
|
# If saving for the first time and IP endpoints are not specified,
|