mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-25 00:13:45 +00:00
Permet d'ajouter une interface à une machine
This commit is contained in:
parent
3c98885d7b
commit
5f70142c68
8 changed files with 26 additions and 18 deletions
|
@ -31,11 +31,14 @@ class AddInterfaceForm(EditInterfaceForm):
|
||||||
class Meta(EditInterfaceForm.Meta):
|
class Meta(EditInterfaceForm.Meta):
|
||||||
fields = ['ipv4','mac_address','dns','details']
|
fields = ['ipv4','mac_address','dns','details']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(AddInterfaceForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['ipv4'].empty_label = "Assignation automatique de l'ipv4"
|
||||||
|
|
||||||
class NewInterfaceForm(EditInterfaceForm):
|
class NewInterfaceForm(EditInterfaceForm):
|
||||||
class Meta(EditInterfaceForm.Meta):
|
class Meta(EditInterfaceForm.Meta):
|
||||||
fields = ['mac_address','dns','details']
|
fields = ['mac_address','dns','details']
|
||||||
|
|
||||||
|
|
||||||
class MachineTypeForm(ModelForm):
|
class MachineTypeForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = MachineType
|
model = MachineType
|
||||||
|
|
|
@ -9,14 +9,15 @@
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for machine in machine_list %}
|
{% for interface in interfaces_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ machine.dns }}</td>
|
<td>{{ interface.dns }}</td>
|
||||||
<td>{{ machine.machine.user }}</td>
|
<td>{{ interface.machine.user }}</td>
|
||||||
<td>{{ machine.machine.type }}</td>
|
<td>{{ interface.machine.type }}</td>
|
||||||
<td>{{ machine.mac_address }}</td>
|
<td>{{ interface.mac_address }}</td>
|
||||||
<td>{{ machine.ipv4 }}</td>
|
<td>{{ interface.ipv4 }}</td>
|
||||||
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:edit-machine' machine.id %}"><i class="glyphicon glyphicon-hdd"></i> Editer</a></td>
|
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:edit-machine' interface.id %}"><i class="glyphicon glyphicon-hdd"></i> Editer</a>
|
||||||
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-interface' interface.machine.id %}"><i class="glyphicon glyphicon-plus"></i> Ajouter une interface</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{% block title %}Machines{% endblock %}
|
{% block title %}Machines{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include "machines/aff_machines.html" with machines_list=machines_list %}
|
{% include "machines/aff_machines.html" with interfaces_list=interfaces_list %}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -97,6 +97,10 @@ def new_interface(request, machineid):
|
||||||
machine_form.save()
|
machine_form.save()
|
||||||
new_interface = interface_form.save(commit=False)
|
new_interface = interface_form.save(commit=False)
|
||||||
new_interface.machine = machine
|
new_interface.machine = machine
|
||||||
|
if free_ip() and not new_interface.ipv4:
|
||||||
|
new_interface = assign_ipv4(new_interface)
|
||||||
|
elif not new_interface.ipv4:
|
||||||
|
messages.error(request, u"Il n'y a plus d'ip disponibles")
|
||||||
new_interface.save()
|
new_interface.save()
|
||||||
messages.success(request, "L'interface a été ajoutée")
|
messages.success(request, "L'interface a été ajoutée")
|
||||||
return redirect("/machines/")
|
return redirect("/machines/")
|
||||||
|
@ -124,5 +128,5 @@ def del_machinetype(request):
|
||||||
return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request)
|
return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request)
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
machine_list = Interface.objects.order_by('pk')
|
interfaces_list = Interface.objects.order_by('pk')
|
||||||
return render(request, 'machines/index.html', {'machine_list': machine_list})
|
return render(request, 'machines/index.html', {'interfaces_list': interfaces_list})
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
<h2>Résultats dans les utilisateurs</h2>
|
<h2>Résultats dans les utilisateurs</h2>
|
||||||
{% include "users/aff_users.html" with users_list=users_list %}
|
{% include "users/aff_users.html" with users_list=users_list %}
|
||||||
{% endif%}
|
{% endif%}
|
||||||
{% if machine_list %}
|
{% if interfaces_list %}
|
||||||
<h2>Résultats dans les machines : </h2>
|
<h2>Résultats dans les machines : </h2>
|
||||||
{% include "machines/aff_machines.html" with machine_list=machine_list %}
|
{% include "machines/aff_machines.html" with interfaces_list=interfaces_list %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if facture_list %}
|
{% if facture_list %}
|
||||||
<h2>Résultats dans les factures : </h2>
|
<h2>Résultats dans les factures : </h2>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<h2>Résultats dans les ports : </h2>
|
<h2>Résultats dans les ports : </h2>
|
||||||
{% include "topologie/aff_port.html" with port_list=port_list %}
|
{% include "topologie/aff_port.html" with port_list=port_list %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not ban_list and not machine_list and not users_list and not facture_list and not white_list and not port_list and not switch_list%}
|
{% if not ban_list and not interfaces_list and not users_list and not facture_list and not white_list and not port_list and not switch_list%}
|
||||||
<h3>Aucun résultat</h3>
|
<h3>Aucun résultat</h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -78,7 +78,7 @@ def search_result(search, type):
|
||||||
portlist = Port.objects.filter(details__icontains = search)
|
portlist = Port.objects.filter(details__icontains = search)
|
||||||
if i == '6':
|
if i == '6':
|
||||||
switchlist = Switch.objects.filter(details__icontains = search)
|
switchlist = Switch.objects.filter(details__icontains = search)
|
||||||
return {'users_list': connexion, 'machine_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist}
|
return {'users_list': connexion, 'interfaces_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist}
|
||||||
|
|
||||||
def search(request):
|
def search(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
|
@ -81,8 +81,8 @@
|
||||||
</table>
|
</table>
|
||||||
<h2>Machines :</h2>
|
<h2>Machines :</h2>
|
||||||
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' user.id %}"><i class="glyphicon glyphicon-phone"></i> Ajouter une machine</a></h4>
|
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' user.id %}"><i class="glyphicon glyphicon-phone"></i> Ajouter une machine</a></h4>
|
||||||
{% if machine_list %}
|
{% if interfaces_list %}
|
||||||
{% include "machines/aff_machines.html" with machine_list=machine_list %}
|
{% include "machines/aff_machines.html" with interfaces_list=interfaces_list %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Aucune machine</p>
|
<p>Aucune machine</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -275,5 +275,5 @@ def profil(request, userid):
|
||||||
if(is_whitelisted(users)):
|
if(is_whitelisted(users)):
|
||||||
end_whitelists=end_whitelist(users)
|
end_whitelists=end_whitelist(users)
|
||||||
list_droits = Right.objects.filter(user=users)
|
list_droits = Right.objects.filter(user=users)
|
||||||
return render(request, 'users/profil.html', {'user': users, 'machine_list' :machines, 'facture_list':factures, 'ban_list':bans, 'white_list':whitelists,'end_ban':end_bans,'end_whitelist':end_whitelists, 'end_adhesion':end_adhesion(users), 'actif':has_access(users), 'list_droits': list_droits})
|
return render(request, 'users/profil.html', {'user': users, 'interfaces_list' :machines, 'facture_list':factures, 'ban_list':bans, 'white_list':whitelists,'end_ban':end_bans,'end_whitelist':end_whitelists, 'end_adhesion':end_adhesion(users), 'actif':has_access(users), 'list_droits': list_droits})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue