mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +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):
|
||||
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 Meta(EditInterfaceForm.Meta):
|
||||
fields = ['mac_address','dns','details']
|
||||
|
||||
|
||||
class MachineTypeForm(ModelForm):
|
||||
class Meta:
|
||||
model = MachineType
|
||||
|
|
|
@ -9,14 +9,15 @@
|
|||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for machine in machine_list %}
|
||||
{% for interface in interfaces_list %}
|
||||
<tr>
|
||||
<td>{{ machine.dns }}</td>
|
||||
<td>{{ machine.machine.user }}</td>
|
||||
<td>{{ machine.machine.type }}</td>
|
||||
<td>{{ machine.mac_address }}</td>
|
||||
<td>{{ machine.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>{{ interface.dns }}</td>
|
||||
<td>{{ interface.machine.user }}</td>
|
||||
<td>{{ interface.machine.type }}</td>
|
||||
<td>{{ interface.mac_address }}</td>
|
||||
<td>{{ interface.ipv4 }}</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>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{% block title %}Machines{% endblock %}
|
||||
|
||||
{% 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 />
|
||||
|
|
|
@ -97,6 +97,10 @@ def new_interface(request, machineid):
|
|||
machine_form.save()
|
||||
new_interface = interface_form.save(commit=False)
|
||||
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()
|
||||
messages.success(request, "L'interface a été ajoutée")
|
||||
return redirect("/machines/")
|
||||
|
@ -124,5 +128,5 @@ def del_machinetype(request):
|
|||
return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request)
|
||||
|
||||
def index(request):
|
||||
machine_list = Interface.objects.order_by('pk')
|
||||
return render(request, 'machines/index.html', {'machine_list': machine_list})
|
||||
interfaces_list = Interface.objects.order_by('pk')
|
||||
return render(request, 'machines/index.html', {'interfaces_list': interfaces_list})
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
<h2>Résultats dans les utilisateurs</h2>
|
||||
{% include "users/aff_users.html" with users_list=users_list %}
|
||||
{% endif%}
|
||||
{% if machine_list %}
|
||||
{% if interfaces_list %}
|
||||
<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 %}
|
||||
{% if facture_list %}
|
||||
<h2>Résultats dans les factures : </h2>
|
||||
|
@ -32,7 +32,7 @@
|
|||
<h2>Résultats dans les ports : </h2>
|
||||
{% include "topologie/aff_port.html" with port_list=port_list %}
|
||||
{% 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>
|
||||
{% endif %}
|
||||
<br />
|
||||
|
|
|
@ -78,7 +78,7 @@ def search_result(search, type):
|
|||
portlist = Port.objects.filter(details__icontains = search)
|
||||
if i == '6':
|
||||
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):
|
||||
if request.method == 'POST':
|
||||
|
|
|
@ -81,8 +81,8 @@
|
|||
</table>
|
||||
<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>
|
||||
{% if machine_list %}
|
||||
{% include "machines/aff_machines.html" with machine_list=machine_list %}
|
||||
{% if interfaces_list %}
|
||||
{% include "machines/aff_machines.html" with interfaces_list=interfaces_list %}
|
||||
{% else %}
|
||||
<p>Aucune machine</p>
|
||||
{% endif %}
|
||||
|
|
|
@ -275,5 +275,5 @@ def profil(request, userid):
|
|||
if(is_whitelisted(users)):
|
||||
end_whitelists=end_whitelist(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