mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 11:53:12 +00:00
L'affichage et l'accès au menu port sont possible que si ip publique
This commit is contained in:
parent
98cc1808da
commit
3147066a85
3 changed files with 8 additions and 3 deletions
|
@ -280,13 +280,13 @@ class Interface(models.Model):
|
||||||
return str(domain)
|
return str(domain)
|
||||||
|
|
||||||
def has_private_ip(self):
|
def has_private_ip(self):
|
||||||
if hasattr(self, 'ipv4'):
|
if self.ipv4:
|
||||||
return IPAddress(str(self.ipv4)).is_private()
|
return IPAddress(str(self.ipv4)).is_private()
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def may_have_port_open(self):
|
def may_have_port_open(self):
|
||||||
return hasattr(self, 'ipv4') and self.has_private_ip()
|
return self.ipv4 and not self.has_private_ip()
|
||||||
|
|
||||||
class Domain(models.Model):
|
class Domain(models.Model):
|
||||||
PRETTY_NAME = "Domaine dns"
|
PRETTY_NAME = "Domaine dns"
|
||||||
|
@ -497,7 +497,7 @@ def interface_post_save(sender, **kwargs):
|
||||||
interface = kwargs['instance']
|
interface = kwargs['instance']
|
||||||
user = interface.machine.user
|
user = interface.machine.user
|
||||||
user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
|
user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
|
||||||
if interface.may_have_port_open() and interface.port_lists.all():
|
if not interface.may_have_port_open() and interface.port_lists.all():
|
||||||
interface.port_lists.clear()
|
interface.port_lists.clear()
|
||||||
# Regen services
|
# Regen services
|
||||||
regen('dhcp')
|
regen('dhcp')
|
||||||
|
|
|
@ -91,11 +91,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<i class="glyphicon glyphicon-edit"></i> Gerer les alias
|
<i class="glyphicon glyphicon-edit"></i> Gerer les alias
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if interface.may_have_port_open %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'machines:port-config' interface.id%}">
|
<a href="{% url 'machines:port-config' interface.id%}">
|
||||||
<i class="glyphicon glyphicon-edit"></i> Gerer la configuration des ports
|
<i class="glyphicon glyphicon-edit"></i> Gerer la configuration des ports
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'machines:history' 'interface' interface.id %}">
|
<a href="{% url 'machines:history' 'interface' interface.id %}">
|
||||||
<i class="glyphicon glyphicon-time"></i> Historique
|
<i class="glyphicon glyphicon-time"></i> Historique
|
||||||
|
|
|
@ -1001,6 +1001,9 @@ def configure_ports(request, pk):
|
||||||
except Interface.DoesNotExist:
|
except Interface.DoesNotExist:
|
||||||
messages.error(request, u"Interface inexistante" )
|
messages.error(request, u"Interface inexistante" )
|
||||||
return redirect("/machines")
|
return redirect("/machines")
|
||||||
|
if not interface_instance.may_have_port_open():
|
||||||
|
messages.error(request, "L'ip de cette interface n'est pas publique ou non assignée")
|
||||||
|
return redirect("/machines")
|
||||||
interface = EditOuverturePortConfigForm(request.POST or None, instance=interface_instance)
|
interface = EditOuverturePortConfigForm(request.POST or None, instance=interface_instance)
|
||||||
if interface.is_valid():
|
if interface.is_valid():
|
||||||
interface.save()
|
interface.save()
|
||||||
|
|
Loading…
Reference in a new issue