8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 11:23:10 +00:00

Mark strings for translation in machines

This commit is contained in:
Laouen Fernet 2019-11-16 14:07:15 +00:00 committed by chirac
parent 07ce7bd8a7
commit ac5d8e2080
20 changed files with 129 additions and 122 deletions

View file

@ -41,6 +41,7 @@ def can_view(user):
can = user.has_module_perms("machines") can = user.has_module_perms("machines")
return ( return (
can, can,
None if can else _("You don't have the right to view this" " application."), None if can else _("You don't have the right to view this"
" application."),
("machines",), ("machines",),
) )

View file

@ -68,7 +68,7 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model):
user = models.ForeignKey("users.User", on_delete=models.CASCADE) user = models.ForeignKey("users.User", on_delete=models.CASCADE)
name = models.CharField( name = models.CharField(
max_length=255, help_text=_("Optional"), blank=True, null=True max_length=255, help_text=_("Optional."), blank=True, null=True
) )
active = models.BooleanField(default=True) active = models.BooleanField(default=True)
@ -157,7 +157,8 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model):
if user != user_request: if user != user_request:
return ( return (
False, False,
_("You don't have the right to add a machine" " to another user."), _("You don't have the right to add a machine to another"
" user."),
("machines.add_machine",), ("machines.add_machine",),
) )
if user.user_interfaces().count() >= max_lambdauser_interfaces: if user.user_interfaces().count() >= max_lambdauser_interfaces:
@ -185,7 +186,8 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model):
if not (user_request.has_perm("machines.change_interface") and can_user): if not (user_request.has_perm("machines.change_interface") and can_user):
return ( return (
False, False,
_("You don't have the right to edit a machine" " of another user."), _("You don't have the right to edit a machine of another"
" user."),
("machines.change_interface",) + permissions, ("machines.change_interface",) + permissions,
) )
return True, None, None return True, None, None
@ -223,7 +225,8 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model):
): ):
return ( return (
False, False,
_("You don't have the right to view other machines" " than yours."), _("You don't have the right to view other machines than"
" yours."),
("machines.view_machine",), ("machines.view_machine",),
) )
return True, None, None return True, None, None
@ -358,22 +361,22 @@ class IpType(RevMixin, AclMixin, models.Model):
protocol="IPv4", protocol="IPv4",
null=True, null=True,
blank=True, blank=True,
help_text=_("Network containing the domain's IPv4 range (optional)"), help_text=_("Network containing the domain's IPv4 range (optional)."),
) )
domaine_ip_netmask = models.IntegerField( domaine_ip_netmask = models.IntegerField(
default=24, default=24,
validators=[MaxValueValidator(31), MinValueValidator(8)], validators=[MaxValueValidator(31), MinValueValidator(8)],
help_text=_("Netmask for the domain's IPv4 range"), help_text=_("Netmask for the domain's IPv4 range."),
) )
reverse_v4 = models.BooleanField( reverse_v4 = models.BooleanField(
default=False, help_text=_("Enable reverse DNS for IPv4") default=False, help_text=_("Enable reverse DNS for IPv4.")
) )
prefix_v6 = models.GenericIPAddressField(protocol="IPv6", null=True, blank=True) prefix_v6 = models.GenericIPAddressField(protocol="IPv6", null=True, blank=True)
prefix_v6_length = models.IntegerField( prefix_v6_length = models.IntegerField(
default=64, validators=[MaxValueValidator(128), MinValueValidator(0)] default=64, validators=[MaxValueValidator(128), MinValueValidator(0)]
) )
reverse_v6 = models.BooleanField( reverse_v6 = models.BooleanField(
default=False, help_text=_("Enable reverse DNS for IPv6") default=False, help_text=_("Enable reverse DNS for IPv6.")
) )
vlan = models.ForeignKey("Vlan", on_delete=models.PROTECT, blank=True, null=True) vlan = models.ForeignKey("Vlan", on_delete=models.PROTECT, blank=True, null=True)
ouverture_ports = models.ForeignKey("OuverturePortList", blank=True, null=True) ouverture_ports = models.ForeignKey("OuverturePortList", blank=True, null=True)
@ -553,7 +556,8 @@ class IpType(RevMixin, AclMixin, models.Model):
for element in IpType.objects.all().exclude(pk=self.pk): for element in IpType.objects.all().exclude(pk=self.pk):
if not self.ip_set.isdisjoint(element.ip_set): if not self.ip_set.isdisjoint(element.ip_set):
raise ValidationError( raise ValidationError(
_("The specified range is not disjoint" " from existing ranges.") _("The specified range is not disjoint from existing"
" ranges.")
) )
# On formate le prefix v6 # On formate le prefix v6
if self.prefix_v6: if self.prefix_v6:
@ -604,8 +608,8 @@ class Vlan(RevMixin, AclMixin, models.Model):
arp_protect = models.BooleanField(default=False) arp_protect = models.BooleanField(default=False)
dhcp_snooping = models.BooleanField(default=False) dhcp_snooping = models.BooleanField(default=False)
dhcpv6_snooping = models.BooleanField(default=False) dhcpv6_snooping = models.BooleanField(default=False)
igmp = models.BooleanField(default=False, help_text=_("v4 multicast management")) igmp = models.BooleanField(default=False, help_text=_("v4 multicast management."))
mld = models.BooleanField(default=False, help_text=_("v6 multicast management")) mld = models.BooleanField(default=False, help_text=_("v6 multicast management."))
class Meta: class Meta:
permissions = (("view_vlan", _("Can view a VLAN object")),) permissions = (("view_vlan", _("Can view a VLAN object")),)
@ -653,30 +657,30 @@ class SOA(RevMixin, AclMixin, models.Model):
""" """
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
mail = models.EmailField(help_text=_("Contact email address for the zone")) mail = models.EmailField(help_text=_("Contact email address for the zone."))
refresh = models.PositiveIntegerField( refresh = models.PositiveIntegerField(
default=86400, # 24 hours default=86400, # 24 hours
help_text=_( help_text=_(
"Seconds before the secondary DNS have to ask the primary" "Seconds before the secondary DNS have to ask the primary"
" DNS serial to detect a modification" " DNS serial to detect a modification."
), ),
) )
retry = models.PositiveIntegerField( retry = models.PositiveIntegerField(
default=7200, # 2 hours default=7200, # 2 hours
help_text=_( help_text=_(
"Seconds before the secondary DNS ask the serial again in" "Seconds before the secondary DNS ask the serial again in"
" case of a primary DNS timeout" " case of a primary DNS timeout."
), ),
) )
expire = models.PositiveIntegerField( expire = models.PositiveIntegerField(
default=3600000, # 1000 hours default=3600000, # 1000 hours
help_text=_( help_text=_(
"Seconds before the secondary DNS stop answering requests" "Seconds before the secondary DNS stop answering requests"
" in case of primary DNS timeout" " in case of primary DNS timeout."
), ),
) )
ttl = models.PositiveIntegerField( ttl = models.PositiveIntegerField(
default=172800, help_text=_("Time to Live") # 2 days default=172800, help_text=_("Time To Live.") # 2 days
) )
class Meta: class Meta:
@ -732,7 +736,7 @@ class Extension(RevMixin, AclMixin, models.Model):
name = models.CharField( name = models.CharField(
max_length=255, max_length=255,
unique=True, unique=True,
help_text=_("Zone name, must begin with a dot (.example.org)"), help_text=_("Zone name, must begin with a dot (.example.org)."),
) )
need_infra = models.BooleanField(default=False) need_infra = models.BooleanField(default=False)
origin = models.ForeignKey( origin = models.ForeignKey(
@ -740,17 +744,17 @@ class Extension(RevMixin, AclMixin, models.Model):
on_delete=models.PROTECT, on_delete=models.PROTECT,
blank=True, blank=True,
null=True, null=True,
help_text=_("A record associated with the zone"), help_text=_("A record associated with the zone."),
) )
origin_v6 = models.GenericIPAddressField( origin_v6 = models.GenericIPAddressField(
protocol="IPv6", protocol="IPv6",
null=True, null=True,
blank=True, blank=True,
help_text=_("AAAA record associated with the zone"), help_text=_("AAAA record associated with the zone."),
) )
soa = models.ForeignKey("SOA", on_delete=models.CASCADE) soa = models.ForeignKey("SOA", on_delete=models.CASCADE)
dnssec = models.BooleanField( dnssec = models.BooleanField(
default=False, help_text=_("Should the zone be signed with DNSSEC") default=False, help_text=_("Should the zone be signed with DNSSEC.")
) )
class Meta: class Meta:
@ -819,7 +823,7 @@ class Extension(RevMixin, AclMixin, models.Model):
can = user_request.has_perm("machines.use_all_extension") can = user_request.has_perm("machines.use_all_extension")
return ( return (
can, can,
_("You cannot use all extensions.") if not can else None, _("You don't have the right to use all extensions.") if not can else None,
("machines.use_all_extension",), ("machines.use_all_extension",),
) )
@ -943,7 +947,7 @@ class Srv(RevMixin, AclMixin, models.Model):
) )
extension = models.ForeignKey("Extension", on_delete=models.PROTECT) extension = models.ForeignKey("Extension", on_delete=models.PROTECT)
ttl = models.PositiveIntegerField( ttl = models.PositiveIntegerField(
default=172800, help_text=_("Time to Live") # 2 days default=172800, help_text=_("Time To Live.") # 2 days
) )
priority = models.PositiveIntegerField( priority = models.PositiveIntegerField(
default=0, default=0,
@ -951,7 +955,7 @@ class Srv(RevMixin, AclMixin, models.Model):
help_text=_( help_text=_(
"Priority of the target server (positive integer value," "Priority of the target server (positive integer value,"
" the lower it is, the more the server will be used if" " the lower it is, the more the server will be used if"
" available)" " available)."
), ),
) )
weight = models.PositiveIntegerField( weight = models.PositiveIntegerField(
@ -959,14 +963,14 @@ class Srv(RevMixin, AclMixin, models.Model):
validators=[MaxValueValidator(65535)], validators=[MaxValueValidator(65535)],
help_text=_( help_text=_(
"Relative weight for records with the same priority" "Relative weight for records with the same priority"
" (integer value between 0 and 65535)" " (integer value between 0 and 65535)."
), ),
) )
port = models.PositiveIntegerField( port = models.PositiveIntegerField(
validators=[MaxValueValidator(65535)], help_text=_("TCP/UDP port") validators=[MaxValueValidator(65535)], help_text=_("TCP/UDP port.")
) )
target = models.ForeignKey( target = models.ForeignKey(
"Domain", on_delete=models.PROTECT, help_text=_("Target server") "Domain", on_delete=models.PROTECT, help_text=_("Target server.")
) )
class Meta: class Meta:
@ -1023,10 +1027,10 @@ class SshFp(RevMixin, AclMixin, models.Model):
) )
machine = models.ForeignKey("Machine", on_delete=models.CASCADE) machine = models.ForeignKey("Machine", on_delete=models.CASCADE)
pub_key_entry = models.TextField(help_text=_("SSH public key"), max_length=2048) pub_key_entry = models.TextField(help_text=_("SSH public key."), max_length=2048)
algo = models.CharField(choices=ALGO, max_length=32) algo = models.CharField(choices=ALGO, max_length=32)
comment = models.CharField( comment = models.CharField(
help_text=_("Comment"), max_length=255, null=True, blank=True help_text=_("Comment."), max_length=255, null=True, blank=True
) )
@cached_property @cached_property
@ -1128,7 +1132,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
oui = mac.oui oui = mac.oui
vendor = oui.registration().org vendor = oui.registration().org
except NotRegisteredError: except NotRegisteredError:
vendor = "Unknown vendor" vendor = _("Unknown vendor.")
return vendor return vendor
def sync_ipv6_dhcpv6(self): def sync_ipv6_dhcpv6(self):
@ -1201,7 +1205,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
self.ipv4 = free_ips[0] self.ipv4 = free_ips[0]
else: else:
raise ValidationError( raise ValidationError(
_("There is no IP address available in the" " slash.") _("There are no IP addresses available in the slash.")
) )
return return
@ -1214,7 +1218,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
"""Unassign ipv4 to multiple interfaces""" """Unassign ipv4 to multiple interfaces"""
with transaction.atomic(), reversion.create_revision(): with transaction.atomic(), reversion.create_revision():
interface_list.update(ipv4=None) interface_list.update(ipv4=None)
reversion.set_comment(_("IPv4 unassigning")) reversion.set_comment("IPv4 unassignment")
@classmethod @classmethod
def mass_assign_ipv4(cls, interface_list): def mass_assign_ipv4(cls, interface_list):
@ -1222,7 +1226,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
with transaction.atomic(), reversion.create_revision(): with transaction.atomic(), reversion.create_revision():
interface.assign_ipv4() interface.assign_ipv4()
interface.save() interface.save()
reversion.set_comment(_("IPv4 assigning")) reversion.set_comment("IPv4 assignment")
def update_type(self): def update_type(self):
""" Lorsque le machinetype est changé de type d'ip, on réassigne""" """ Lorsque le machinetype est changé de type d'ip, on réassigne"""
@ -1267,7 +1271,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
) )
if interfaces_similar and interfaces_similar.first() != self: if interfaces_similar and interfaces_similar.first() != self:
raise ValidationError( raise ValidationError(
_("Mac address already registered in this Machine Type/Subnet") _("MAC address already registered in this machine type/subnet.")
) )
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
@ -1276,7 +1280,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
if self.ipv4: if self.ipv4:
if self.machine_type.ip_type != self.ipv4.ip_type: if self.machine_type.ip_type != self.ipv4.ip_type:
raise ValidationError( raise ValidationError(
_("The IPv4 address and the machine type" " don't match.") _("The IPv4 address and the machine type don't match.")
) )
self.validate_unique() self.validate_unique()
super(Interface, self).save(*args, **kwargs) super(Interface, self).save(*args, **kwargs)
@ -1296,7 +1300,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
if not ( if not (
preferences.models.OptionalMachine.get_cached_value("create_machine") preferences.models.OptionalMachine.get_cached_value("create_machine")
): ):
return False, _("You can't add a machine."), ("machines.add_interface",) return False, _("You don't have the right to add a machine."), ("machines.add_interface",)
max_lambdauser_interfaces = preferences.models.OptionalMachine.get_cached_value( max_lambdauser_interfaces = preferences.models.OptionalMachine.get_cached_value(
"max_lambdauser_interfaces" "max_lambdauser_interfaces"
) )
@ -1328,7 +1332,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
can = user_request.has_perm("machines.change_interface_machine") can = user_request.has_perm("machines.change_interface_machine")
return ( return (
can, can,
_("Permission required to edit the machine.") if not can else None, _("You don't have the right to edit the machine.") if not can else None,
("machines.change_interface_machine",), ("machines.change_interface_machine",),
) )
@ -1345,7 +1349,8 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
if not (user_request.has_perm("machines.change_interface") and can_user): if not (user_request.has_perm("machines.change_interface") and can_user):
return ( return (
False, False,
_("You don't have the right to edit a machine of" " another user."), _("You don't have the right to edit a machine of another"
" user."),
("machines.change_interface",) + permissions, ("machines.change_interface",) + permissions,
) )
return True, None, None return True, None, None
@ -1363,7 +1368,8 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
if not (user_request.has_perm("machines.change_interface") and can_user): if not (user_request.has_perm("machines.change_interface") and can_user):
return ( return (
False, False,
_("You don't have the right to edit a machine of" " another user."), _("You don't have the right to edit a machine of another"
" user."),
("machines.change_interface",) + permissions, ("machines.change_interface",) + permissions,
) )
return True, None, None return True, None, None
@ -1411,7 +1417,7 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
("view_ipv6list", _("Can view an IPv6 addresses list object")), ("view_ipv6list", _("Can view an IPv6 addresses list object")),
( (
"change_ipv6list_slaac_ip", "change_ipv6list_slaac_ip",
_("Can change the SLAAC value of an" " IPv6 addresses list"), _("Can change the SLAAC value of an IPv6 addresses list"),
), ),
) )
verbose_name = _("IPv6 addresses list") verbose_name = _("IPv6 addresses list")
@ -1446,7 +1452,7 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
can = user_request.has_perm("machines.change_ipv6list_slaac_ip") can = user_request.has_perm("machines.change_ipv6list_slaac_ip")
return ( return (
can, can,
_("Permission required to change the SLAAC value of an IPv6" " address") _("You don't have the right to change the SLAAC value of an IPv6 address.")
if not can if not can
else None, else None,
("machines.change_ipv6list_slaac_ip",), ("machines.change_ipv6list_slaac_ip",),
@ -1465,7 +1471,7 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
if not (user_request.has_perm("machines.change_ipv6list") and can_user): if not (user_request.has_perm("machines.change_ipv6list") and can_user):
return ( return (
False, False,
_("You don't have the right to edit a machine of" " another user."), _("You don't have the right to edit a machine of another user."),
("machines.change_ipv6list",), ("machines.change_ipv6list",),
) )
return True, None, None return True, None, None
@ -1483,7 +1489,7 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
if not (user_request.has_perm("machines.change_ipv6list") and can_user): if not (user_request.has_perm("machines.change_ipv6list") and can_user):
return ( return (
False, False,
_("You don't have the right to edit a machine of" " another user."), _("You don't have the right to edit a machine of another user."),
("machines.change_ipv6list",) + permissions, ("machines.change_ipv6list",) + permissions,
) )
return True, None, None return True, None, None
@ -1587,7 +1593,7 @@ class Domain(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
unique_together = (("name", "extension"),) unique_together = (("name", "extension"),)
permissions = ( permissions = (
("view_domain", _("Can view a domain object")), ("view_domain", _("Can view a domain object")),
("change_ttl", _("Can change TTL of a domain object")), ("change_ttl", _("Can change the TTL of a domain object")),
) )
verbose_name = _("domain") verbose_name = _("domain")
verbose_name_plural = _("domains") verbose_name_plural = _("domains")
@ -1612,20 +1618,20 @@ class Domain(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
if self.get_extension(): if self.get_extension():
self.extension = self.get_extension() self.extension = self.get_extension()
if self.interface_parent and self.cname: if self.interface_parent and self.cname:
raise ValidationError(_("You can't create a both A and CNAME" " record.")) raise ValidationError(_("You can't create a both A and CNAME record."))
if self.cname == self: if self.cname == self:
raise ValidationError( raise ValidationError(
_("You can't create a CNAME record pointing" " to itself.") _("You can't create a CNAME record pointing to itself.")
) )
HOSTNAME_LABEL_PATTERN = re.compile(r"(?!-)[A-Z\d-]+(?<!-)$", re.IGNORECASE) HOSTNAME_LABEL_PATTERN = re.compile(r"(?!-)[A-Z\d-]+(?<!-)$", re.IGNORECASE)
dns = self.name.lower() dns = self.name.lower()
if len(dns) > 63: if len(dns) > 63:
raise ValidationError( raise ValidationError(
_("The domain name %s is too long (over 63" " characters).") % dns _("The domain name %s is too long (over 63 characters).") % dns
) )
if not HOSTNAME_LABEL_PATTERN.match(dns): if not HOSTNAME_LABEL_PATTERN.match(dns):
raise ValidationError( raise ValidationError(
_("The domain name %s contains forbidden" " characters.") % dns _("The domain name %s contains forbidden characters.") % dns
) )
self.validate_unique() self.validate_unique()
super(Domain, self).clean() super(Domain, self).clean()
@ -1753,7 +1759,8 @@ class Domain(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
): ):
return ( return (
False, False,
_("You don't have the right to view machines other than yours."), _("You don't have the right to view other machines than"
" yours."),
("machines.view_domain",), ("machines.view_domain",),
) )
return True, None, None return True, None, None
@ -1794,7 +1801,7 @@ class IpList(RevMixin, AclMixin, models.Model):
""" Erreur si l'ip_type est incorrect""" """ Erreur si l'ip_type est incorrect"""
if not str(self.ipv4) in self.ip_type.ip_set_as_str: if not str(self.ipv4) in self.ip_type.ip_set_as_str:
raise ValidationError( raise ValidationError(
_("The IPv4 address and the range of the IP" " type don't match.") _("The IPv4 address and the range of the IP type don't match.")
) )
return return
@ -1970,7 +1977,8 @@ class OuverturePortList(RevMixin, AclMixin, models.Model):
class Meta: class Meta:
permissions = ( permissions = (
("view_ouvertureportlist", _("Can view a ports opening list" " object")), ("view_ouvertureportlist", _("Can view a ports opening list"
" object")),
) )
verbose_name = _("ports opening list") verbose_name = _("ports opening list")
verbose_name_plural = _("ports opening lists") verbose_name_plural = _("ports opening lists")

View file

@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<thead> <thead>
<tr> <tr>
<th>{% trans "Extension" %}</th> <th>{% trans "Extension" %}</th>
<th>{% trans "'infra' right required" %}</th> <th>{% blocktrans %}"infra" right required{% endblocktrans %}</th>
<th>{% trans "SOA record" %}</th> <th>{% trans "SOA record" %}</th>
<th>{% trans "A record origin" %}</th> <th>{% trans "A record origin" %}</th>
{% if ipv6_enabled %} {% if ipv6_enabled %}

View file

@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr> <tr>
<th>{% trans "IP type" %}</th> <th>{% trans "IP type" %}</th>
<th>{% trans "Extension" %}</th> <th>{% trans "Extension" %}</th>
<th>{% trans "'infra' right required" %}</th> <th>{% blocktrans %}"infra" right required{% endblocktrans %}</th>
<th>{% trans "IPv4 range" %}</th> <th>{% trans "IPv4 range" %}</th>
<th>{% trans "v6 prefix" %}</th> <th>{% trans "v6 prefix" %}</th>
<th>{% trans "DNSSEC reverse v4/v6" %}</th> <th>{% trans "DNSSEC reverse v4/v6" %}</th>

View file

@ -31,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>{% trans "Service name" %}</th> <th>{% trans "Service name" %}</th>
<th>{% trans "Server" %}</th> <th>{% trans "Server" %}</th>
<th>{% trans "Last regeneration" %}</th> <th>{% trans "Last regeneration" %}</th>
<th>{% trans "Regeneration required" %}</th> <th>{% trans "Regeneration asked" %}</th>
<th>{% trans "Regeneration activated" %}</th> <th>{% trans "Regeneration needed" %}</th>
</tr> </tr>
</thead> </thead>
{% for server in servers_list %} {% for server in servers_list %}

View file

@ -47,11 +47,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div> </div>
<p> <p>
{% trans "Add a port" as value %} <input class="btn btn-primary btn-sm" role="button" value="{% trans "Add a port" %}" id="add_one">
<input class="btn btn-primary btn-sm" role="button" value="value" id="add_one">
</p> </p>
{% trans "Create or edit" as tr_create_or_edit %} {% trans "Confirm" as tr_confirm %}
{% bootstrap_button tr_create_or_edit icon='ok' button_class='btn-success' %} {% bootstrap_button tr_confirm icon='ok' button_class='btn-success' %}
</form> </form>
<script type="text/javascript"> <script type="text/javascript">
var template = `{{ports.empty_form}}`; var template = `{{ports.empty_form}}`;

View file

@ -33,8 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<h2>{% trans "List of extensions" %}</h2> <h2>{% trans "List of extensions" %}</h2>
{% can_create Extension %} {% can_create Extension %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-extension' %}"> <a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-extension' %}">
<i class="fa fa-plus"></i> <i class="fa fa-plus"></i> {% trans "Add an extension" %}</a>
{% trans " Add an extension" %}</a>
{% acl_end %} {% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-extension' %}"> <a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-extension' %}">
<i class="fa fa-trash"></i> {% trans "Delete one or several extensions" %} <i class="fa fa-trash"></i> {% trans "Delete one or several extensions" %}

View file

@ -250,7 +250,7 @@ def new_machine(request, user, **_kwargs):
"interfaceform": interface, "interfaceform": interface,
"domainform": domain, "domainform": domain,
"i_mbf_param": i_mbf_param, "i_mbf_param": i_mbf_param,
"action_name": _("Create a machine"), "action_name": _("Add"),
}, },
"machines/machine.html", "machines/machine.html",
request, request,
@ -314,7 +314,7 @@ def del_machine(request, machine, **_kwargs):
reverse("users:profil", kwargs={"userid": str(machine.user.id)}) reverse("users:profil", kwargs={"userid": str(machine.user.id)})
) )
return form( return form(
{"objet": machine, "objet_name": "machine"}, "machines/delete.html", request {"objet": machine, "objet_name": _("machine")}, "machines/delete.html", request
) )
@ -345,7 +345,7 @@ def new_interface(request, machine, **_kwargs):
"interfaceform": interface_form, "interfaceform": interface_form,
"domainform": domain_form, "domainform": domain_form,
"i_mbf_param": i_mbf_param, "i_mbf_param": i_mbf_param,
"action_name": _("Create an interface"), "action_name": _("Add"),
}, },
"machines/machine.html", "machines/machine.html",
request, request,
@ -366,7 +366,7 @@ def del_interface(request, interface, **_kwargs):
reverse("users:profil", kwargs={"userid": str(request.user.id)}) reverse("users:profil", kwargs={"userid": str(request.user.id)})
) )
return form( return form(
{"objet": interface, "objet_name": "interface"}, "machines/delete.html", request {"objet": interface, "objet_name": _("interface")}, "machines/delete.html", request
) )
@ -386,7 +386,7 @@ def new_ipv6list(request, interface, **_kwargs):
reverse("machines:index-ipv6", kwargs={"interfaceid": str(interface.id)}) reverse("machines:index-ipv6", kwargs={"interfaceid": str(interface.id)})
) )
return form( return form(
{"ipv6form": ipv6, "action_name": _("Create an IPv6 addresses list")}, {"ipv6form": ipv6, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -426,7 +426,7 @@ def del_ipv6list(request, ipv6list, **_kwargs):
reverse("machines:index-ipv6", kwargs={"interfaceid": str(interfaceid)}) reverse("machines:index-ipv6", kwargs={"interfaceid": str(interfaceid)})
) )
return form( return form(
{"objet": ipv6list, "objet_name": "ipv6"}, "machines/delete.html", request {"objet": ipv6list, "objet_name": _("IPv6 addresses list")}, "machines/delete.html", request
) )
@ -444,7 +444,7 @@ def new_sshfp(request, machine, **_kwargs):
reverse("machines:index-sshfp", kwargs={"machineid": str(machine.id)}) reverse("machines:index-sshfp", kwargs={"machineid": str(machine.id)})
) )
return form( return form(
{"sshfpform": sshfp, "action_name": _("Create a SSHFP record")}, {"sshfpform": sshfp, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -482,7 +482,7 @@ def del_sshfp(request, sshfp, **_kwargs):
reverse("machines:index-sshfp", kwargs={"machineid": str(machineid)}) reverse("machines:index-sshfp", kwargs={"machineid": str(machineid)})
) )
return form( return form(
{"objet": sshfp, "objet_name": "sshfp"}, "machines/delete.html", request {"objet": sshfp, "objet_name": _("SSHFP record")}, "machines/delete.html", request
) )
@ -498,7 +498,7 @@ def add_iptype(request):
messages.success(request, _("The IP type was created.")) messages.success(request, _("The IP type was created."))
return redirect(reverse("machines:index-iptype")) return redirect(reverse("machines:index-iptype"))
return form( return form(
{"iptypeform": iptype, "action_name": _("Create an IP type")}, {"iptypeform": iptype, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -563,7 +563,7 @@ def add_machinetype(request):
messages.success(request, _("The machine type was created.")) messages.success(request, _("The machine type was created."))
return redirect(reverse("machines:index-machinetype")) return redirect(reverse("machines:index-machinetype"))
return form( return form(
{"machinetypeform": machinetype, "action_name": _("Create a machine" " type")}, {"machinetypeform": machinetype, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -626,7 +626,7 @@ def add_extension(request):
messages.success(request, _("The extension was created.")) messages.success(request, _("The extension was created."))
return redirect(reverse("machines:index-extension")) return redirect(reverse("machines:index-extension"))
return form( return form(
{"extensionform": extension, "action_name": _("Create an extension")}, {"extensionform": extension, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -688,7 +688,7 @@ def add_soa(request):
messages.success(request, _("The SOA record was created.")) messages.success(request, _("The SOA record was created."))
return redirect(reverse("machines:index-extension")) return redirect(reverse("machines:index-extension"))
return form( return form(
{"soaform": soa, "action_name": _("Create an SOA record")}, {"soaform": soa, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -740,7 +740,7 @@ def add_mx(request):
messages.success(request, _("The MX record was created.")) messages.success(request, _("The MX record was created."))
return redirect(reverse("machines:index-extension")) return redirect(reverse("machines:index-extension"))
return form( return form(
{"mxform": mx, "action_name": _("Create an MX record")}, {"mxform": mx, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -792,7 +792,7 @@ def add_ns(request):
messages.success(request, _("The NS record was created.")) messages.success(request, _("The NS record was created."))
return redirect(reverse("machines:index-extension")) return redirect(reverse("machines:index-extension"))
return form( return form(
{"nsform": ns, "action_name": _("Create an NS record")}, {"nsform": ns, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -844,7 +844,7 @@ def add_dname(request):
messages.success(request, _("The DNAME record was created.")) messages.success(request, _("The DNAME record was created."))
return redirect(reverse("machines:index-extension")) return redirect(reverse("machines:index-extension"))
return form( return form(
{"dnameform": dname, "action_name": _("Create a DNAME record")}, {"dnameform": dname, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -899,7 +899,7 @@ def add_txt(request):
messages.success(request, _("The TXT record was created.")) messages.success(request, _("The TXT record was created."))
return redirect(reverse("machines:index-extension")) return redirect(reverse("machines:index-extension"))
return form( return form(
{"txtform": txt, "action_name": _("Create a TXT record")}, {"txtform": txt, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -951,7 +951,7 @@ def add_srv(request):
messages.success(request, _("The SRV record was created.")) messages.success(request, _("The SRV record was created."))
return redirect(reverse("machines:index-extension")) return redirect(reverse("machines:index-extension"))
return form( return form(
{"srvform": srv, "action_name": _("Create an SRV record")}, {"srvform": srv, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -1008,7 +1008,7 @@ def add_alias(request, interface, interfaceid):
reverse("machines:index-alias", kwargs={"interfaceid": str(interfaceid)}) reverse("machines:index-alias", kwargs={"interfaceid": str(interfaceid)})
) )
return form( return form(
{"aliasform": alias, "action_name": _("Create an alias")}, {"aliasform": alias, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -1069,7 +1069,7 @@ def add_role(request):
messages.success(request, _("The role was created.")) messages.success(request, _("The role was created."))
return redirect(reverse("machines:index-role")) return redirect(reverse("machines:index-role"))
return form( return form(
{"roleform": role, "action_name": _("Create a role")}, {"roleform": role, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -1121,7 +1121,7 @@ def add_service(request):
messages.success(request, _("The service was created.")) messages.success(request, _("The service was created."))
return redirect(reverse("machines:index-service")) return redirect(reverse("machines:index-service"))
return form( return form(
{"serviceform": service, "action_name": _("Create a service")}, {"serviceform": service, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -1187,7 +1187,7 @@ def add_vlan(request):
messages.success(request, _("The VLAN was created.")) messages.success(request, _("The VLAN was created."))
return redirect(reverse("machines:index-vlan")) return redirect(reverse("machines:index-vlan"))
return form( return form(
{"vlanform": vlan, "action_name": _("Create a VLAN")}, {"vlanform": vlan, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -1239,7 +1239,7 @@ def add_nas(request):
messages.success(request, _("The NAS device was created.")) messages.success(request, _("The NAS device was created."))
return redirect(reverse("machines:index-nas")) return redirect(reverse("machines:index-nas"))
return form( return form(
{"nasform": nas, "action_name": _("Create a NAS device")}, {"nasform": nas, "action_name": _("Add")},
"machines/machine.html", "machines/machine.html",
request, request,
) )
@ -1558,8 +1558,8 @@ def configure_ports(request, interface_instance, **_kwargs):
request, request,
( (
_( _(
"Warning: the IPv4 isn't public, the opening won't have effect" "Warning: the IP address is not public, the opening won't"
" in v4." " have any effect in v4."
) )
), ),
) )
@ -1572,7 +1572,7 @@ def configure_ports(request, interface_instance, **_kwargs):
messages.success(request, _("The ports configuration was edited.")) messages.success(request, _("The ports configuration was edited."))
return redirect(reverse("machines:index")) return redirect(reverse("machines:index"))
return form( return form(
{"interfaceform": interface, "action_name": _("Edit the" " configuration")}, {"interfaceform": interface, "action_name": _("Edit")},
"machines/machine.html", "machines/machine.html",
request, request,
) )