mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 03:13:12 +00:00
Modifie le model switch
This commit is contained in:
parent
62721032e8
commit
3442680933
8 changed files with 76 additions and 15 deletions
|
@ -100,7 +100,7 @@ class ExtensionForm(ModelForm):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ExtensionForm, self).__init__(*args, **kwargs)
|
||||
self.fields['name'].label = 'Exstension à ajouter'
|
||||
self.fields['name'].label = 'Extension à ajouter'
|
||||
|
||||
class DelExtensionForm(ModelForm):
|
||||
extensions = forms.ModelMultipleChoiceField(queryset=Extension.objects.all(), label="Extensions actuelles", widget=forms.CheckboxSelectMultiple)
|
||||
|
|
19
machines/migrations/0026_auto_20161026_1348.py
Normal file
19
machines/migrations/0026_auto_20161026_1348.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('machines', '0025_auto_20161023_0038'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='interface',
|
||||
name='dns',
|
||||
field=models.CharField(unique=True, max_length=255, help_text='Obligatoire et unique, ne doit pas comporter de points'),
|
||||
),
|
||||
]
|
|
@ -5,7 +5,7 @@ from reversion.admin import VersionAdmin
|
|||
from .models import Port, Room, Switch
|
||||
|
||||
class SwitchAdmin(VersionAdmin):
|
||||
list_display = ('building','number','details')
|
||||
list_display = ('switch_interface','location','number','details')
|
||||
|
||||
class PortAdmin(VersionAdmin):
|
||||
list_display = ('switch', 'port','room','machine_interface','details')
|
||||
|
|
|
@ -14,14 +14,19 @@ class AddPortForm(ModelForm):
|
|||
class Meta(PortForm.Meta):
|
||||
fields = ['port', 'room', 'machine_interface', 'related', 'details']
|
||||
|
||||
class SwitchForm(ModelForm):
|
||||
class EditSwitchForm(ModelForm):
|
||||
class Meta:
|
||||
model = Switch
|
||||
fields = '__all__'
|
||||
|
||||
class EditSwitchForm(ModelForm):
|
||||
class Meta(SwitchForm.Meta):
|
||||
fields = ['building', 'number', 'details']
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditSwitchForm, self).__init__(*args, **kwargs)
|
||||
self.fields['location'].label = 'Localisation'
|
||||
self.fields['number'].label = 'Nombre de ports'
|
||||
|
||||
class NewSwitchForm(ModelForm):
|
||||
class Meta(EditSwitchForm.Meta):
|
||||
fields = ['location', 'number', 'details']
|
||||
|
||||
class EditRoomForm(ModelForm):
|
||||
class Meta:
|
||||
|
|
35
topologie/migrations/0019_auto_20161026_1348.py
Normal file
35
topologie/migrations/0019_auto_20161026_1348.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('machines', '0026_auto_20161026_1348'),
|
||||
('topologie', '0018_room_details'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='switch',
|
||||
name='location',
|
||||
field=models.CharField(default='test', max_length=255),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='switch',
|
||||
name='switch_interface',
|
||||
field=models.OneToOneField(default=1, to='machines.Interface'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='switch',
|
||||
unique_together=set([]),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='switch',
|
||||
name='building',
|
||||
),
|
||||
]
|
|
@ -16,15 +16,13 @@ def clean_port_related(port):
|
|||
related_port.save()
|
||||
|
||||
class Switch(models.Model):
|
||||
building = models.CharField(max_length=10)
|
||||
switch_interface = models.OneToOneField('machines.Interface', on_delete=models.CASCADE)
|
||||
location = models.CharField(max_length=255)
|
||||
number = models.IntegerField()
|
||||
details = models.CharField(max_length=255, blank=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('building', 'number')
|
||||
|
||||
def __str__(self):
|
||||
return str(self.building) + str(self.number)
|
||||
return str(self.location)
|
||||
|
||||
class Port(models.Model):
|
||||
switch = models.ForeignKey('Switch', related_name="ports")
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bâtiment</th>
|
||||
<th>Numero</th>
|
||||
<th>Dns</th>
|
||||
<th>Ipv4</th>
|
||||
<th>Localisation</th>
|
||||
<th>Nombre de ports</th>
|
||||
<th>Détails</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for switch in switch_list %}
|
||||
<tr>
|
||||
<td>{{switch.building}}</td>
|
||||
<td>{{switch.switch_interface.dns}}</td>
|
||||
<td>{{switch.switch_interface.ipv4}}</td>
|
||||
<td>{{switch.location}}</td>
|
||||
<td>{{switch.number}}</td>
|
||||
<td>{{switch.details}}</td>
|
||||
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:index-port' switch.pk %}"><i class="glyphicon glyphicon-cog"></i> Configurer</a>
|
||||
|
|
|
@ -15,7 +15,7 @@ from re2o.settings import PAGINATION_NUMBER
|
|||
@login_required
|
||||
@permission_required('cableur')
|
||||
def index(request):
|
||||
switch_list = Switch.objects.order_by('building', 'number')
|
||||
switch_list = Switch.objects.order_by('location')
|
||||
return render(request, 'topologie/index.html', {'switch_list': switch_list})
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Reference in a new issue