mirror of https://gitlab.federez.net/re2o/re2o
62 changed files with 1743 additions and 174 deletions
@ -0,0 +1,82 @@ |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load bootstrap3 %} |
|||
{% load acl %} |
|||
|
|||
{% for droit,users in stats_list.items %} |
|||
<div class="panel panel-default"> |
|||
<div class="panel-heading clearfix" data-parent="#accordion" data-toggle="collapse" data-target="#collapse{{droit.id}}"> |
|||
<h2 class="panel-title pull-left"> |
|||
<i class="fa fa-address-book"></i> |
|||
{{droit}} |
|||
<span class="badge">{{users.count}}</span> |
|||
</h2> |
|||
</div> |
|||
<div class="panel-collapse collapse" id="collapse{{droit.id}}"> |
|||
<div class="panel-body"> |
|||
<div class="table-responsive"> |
|||
<table class="table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>Pseudo</th> |
|||
<th>Adhésion</th> |
|||
<th>Derniere connexion</th> |
|||
<th>Nombre d'actions</th> |
|||
<th>Date de la dernière action</th> |
|||
<th></th> |
|||
</tr> |
|||
</thead> |
|||
{% for utilisateur in users %} |
|||
<tr> |
|||
<td>{{ utilisateur.pseudo }}</td> |
|||
{% if utilisateur.is_adherent %} |
|||
<td><p class="text-success">Adhérent</p></td> |
|||
{% elif not utilisateur.end_adhesion %} |
|||
<td><p class="text-warning">On ne s'en souvient plus...</p></td> |
|||
{% else %} |
|||
<td><p class="text-danger">Plus depuis {{ utilisateur.end_adhesion }}</p></td> |
|||
{% endif %} |
|||
<td>{{ utilisateur.last_login }}</td> |
|||
<td>{{ utilisateur.num }}</td> |
|||
{% if not utilisateur.last %} |
|||
<td><p class="text-danger">Jamais</p></td> |
|||
{% else %} |
|||
<td><p class="text-success">{{utilisateur.last}}</p></td> |
|||
{% endif %} |
|||
<td> |
|||
<a href="{% url 'users:del-group' utilisateur.id droit.id %}"> |
|||
<button type="button" class="btn btn-danger" aria-label="Left Align"> |
|||
<span class="fa fa-user-times" aria-hidden="true"></span> |
|||
</button> |
|||
</a> |
|||
</td> |
|||
</tr> |
|||
{% endfor %} |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
{% endfor %} |
|||
@ -0,0 +1,36 @@ |
|||
{% extends "logs/sidebar.html" %} |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load bootstrap3 %} |
|||
|
|||
{% block title %}Statistiques des droits{% endblock %} |
|||
|
|||
{% block content %} |
|||
<h2>Statistiques des droits</h2> |
|||
{% include "logs/aff_stats_droits.html" with stats_list=stats_list %} |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('preferences', '0030_merge_20180320_1419'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterField( |
|||
model_name='generaloption', |
|||
name='email_from', |
|||
field=models.EmailField(default='www-data@example.com', max_length=254), |
|||
), |
|||
] |
|||
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-24 19:22 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('users', '0070_auto_20180324_1906'), |
|||
('preferences', '0031_auto_20180323_0218'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='optionaluser', |
|||
name='shell_default', |
|||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='users.ListShell'), |
|||
), |
|||
] |
|||
@ -0,0 +1,47 @@ |
|||
# ⁻*- mode: python; coding: utf-8 -*- |
|||
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
# se veut agnostique au réseau considéré, de manière à être installable en |
|||
# quelques clics. |
|||
# |
|||
# Copyright © 2018 Gabriel Detraz |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; either version 2 of the License, or |
|||
# (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License along |
|||
# with this program; if not, write to the Free Software Foundation, Inc., |
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
|
|||
from django.core.management.base import BaseCommand, CommandError |
|||
from pymongo import MongoClient |
|||
from topologie.models import Borne |
|||
|
|||
class Command(BaseCommand): |
|||
help = 'Ce script donne un nom aux bornes dans le controleur unifi. |
|||
A lancer sur le serveur en local où se trouve le controleur' |
|||
|
|||
def handle(self, *args, **options): |
|||
# Connexion mongodb |
|||
client = MongoClient("mongodb://localhost:27117") |
|||
db = client.ace |
|||
device = db['device'] |
|||
|
|||
bornes = Borne.objects.all() |
|||
|
|||
def set_bornes_names(liste_bornes): |
|||
"""Met à jour les noms des bornes dans la bdd du controleur""" |
|||
for borne in liste_bornes: |
|||
if borne.ipv4 and borne.domain: |
|||
device.find_one_and_update({'ip': str(borne.ipv4)}, {'$set': {'name': str(borne.domain.name)}}) |
|||
return |
|||
|
|||
set_bornes_names(bornes) |
|||
|
|||
self.stdout.write(self.style.SUCCESS('Mise à jour de la base de donnée unifi avec succès')) |
|||
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('machines', '0076_auto_20180130_1623'), |
|||
('topologie', '0033_auto_20171231_1743'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.CreateModel( |
|||
name='Borne', |
|||
fields=[ |
|||
('interface_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='machines.Interface')), |
|||
('location', models.CharField(help_text="Détails sur la localisation de l'AP", max_length=255)), |
|||
], |
|||
options={ |
|||
'permissions': (('view_borne', 'Peut voir une borne'),), |
|||
}, |
|||
bases=('machines.interface',), |
|||
), |
|||
] |
|||
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-23 23:23 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0034_borne'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterField( |
|||
model_name='borne', |
|||
name='location', |
|||
field=models.CharField(blank=True, help_text="Détails sur la localisation de l'AP", max_length=255, null=True), |
|||
), |
|||
] |
|||
@ -0,0 +1,32 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-12-31 19:53 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0035_auto_20180324_0023'), |
|||
] |
|||
|
|||
def transfer_bornes(apps, schema_editor): |
|||
db_alias = schema_editor.connection.alias |
|||
machinetype = apps.get_model("machines", "MachineType") |
|||
borne = apps.get_model("topologie", "Borne") |
|||
interface = apps.get_model("machines", "Interface") |
|||
bornes_list = machinetype.objects.using(db_alias).filter(type__icontains='borne') |
|||
if bornes_list: |
|||
for inter in interface.objects.using(db_alias).filter(type=bornes_list.first()): |
|||
borne_object = borne() |
|||
borne_object.interface_ptr_id = inter.pk |
|||
borne_object.__dict__.update(inter.__dict__) |
|||
borne_object.save() |
|||
|
|||
def untransfer_bornes(apps, schema_editor): |
|||
return |
|||
|
|||
operations = [ |
|||
migrations.RunPython(transfer_bornes, untransfer_bornes), |
|||
] |
|||
@ -0,0 +1,33 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-25 00:27 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('machines', '0076_auto_20180130_1623'), |
|||
('topologie', '0036_transferborne'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.CreateModel( |
|||
name='NewSwitch', |
|||
fields=[ |
|||
('interface_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='machines.Interface')), |
|||
('location', models.CharField(max_length=255)), |
|||
('number', models.PositiveIntegerField()), |
|||
('stack_member_id', models.PositiveIntegerField(blank=True, null=True)), |
|||
('model', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='topologie.ModelSwitch')), |
|||
('stack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='topologie.Stack')), |
|||
], |
|||
bases=('machines.interface',), |
|||
), |
|||
migrations.AlterUniqueTogether( |
|||
name='newswitch', |
|||
unique_together=set([('stack', 'stack_member_id')]), |
|||
), |
|||
] |
|||
@ -0,0 +1,37 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-12-31 19:53 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0037_auto_20180325_0127'), |
|||
] |
|||
|
|||
def transfer_sw(apps, schema_editor): |
|||
db_alias = schema_editor.connection.alias |
|||
newswitch = apps.get_model("topologie", "NewSwitch") |
|||
switch = apps.get_model("topologie", "Switch") |
|||
interface = apps.get_model("machines", "Interface") |
|||
sw_list = switch.objects.using(db_alias).all() |
|||
for sw in sw_list: |
|||
new_sw = newswitch() |
|||
new_sw.location = sw.location |
|||
new_sw.number = sw.number |
|||
new_sw.details = sw.details |
|||
new_sw.stack = sw.stack |
|||
new_sw.stack_member_id = sw.stack_member_id |
|||
new_sw.model = sw.model |
|||
new_sw.interface_ptr_id = sw.switch_interface.pk |
|||
new_sw.__dict__.update(sw.switch_interface.__dict__) |
|||
new_sw.save() |
|||
|
|||
def untransfer_sw(apps, schema_editor): |
|||
return |
|||
|
|||
operations = [ |
|||
migrations.RunPython(transfer_sw, untransfer_sw), |
|||
] |
|||
@ -0,0 +1,21 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-25 00:52 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0038_transfersw'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='port', |
|||
name='new_switch', |
|||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='ports', to='topologie.NewSwitch'), |
|||
), |
|||
] |
|||
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-12-31 19:53 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0039_port_new_switch'), |
|||
] |
|||
|
|||
def transfer_port(apps, schema_editor): |
|||
db_alias = schema_editor.connection.alias |
|||
port = apps.get_model("topologie", "Port") |
|||
switch = apps.get_model("topologie", "NewSwitch") |
|||
port_list = port.objects.using(db_alias).all() |
|||
for p in port_list: |
|||
p.new_switch = switch.objects.filter(interface_ptr=p.switch.switch_interface).first() |
|||
p.save() |
|||
|
|||
def untransfer_port(apps, schema_editor): |
|||
return |
|||
|
|||
operations = [ |
|||
migrations.RunPython(transfer_port, untransfer_port), |
|||
] |
|||
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-12-31 19:53 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0040_transferports'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterUniqueTogether( |
|||
name='port', |
|||
unique_together=set([]), |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='port', |
|||
name='switch', |
|||
), |
|||
migrations.RenameField('Port', 'new_switch', 'switch') |
|||
] |
|||
@ -0,0 +1,18 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-12-31 19:53 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0041_transferportsw'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.DeleteModel( |
|||
name='Switch', |
|||
), |
|||
] |
|||
@ -0,0 +1,16 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-12-31 19:53 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0042_transferswitch'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RenameModel(old_name='NewSwitch', new_name='Switch'), |
|||
] |
|||
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-25 22:02 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0043_renamenewswitch'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RenameModel( |
|||
old_name='Borne', |
|||
new_name='AccessPoint', |
|||
), |
|||
migrations.AlterModelOptions( |
|||
name='accesspoint', |
|||
options={'permissions': (('view_ap', 'Peut voir une borne'),)}, |
|||
), |
|||
migrations.AlterModelOptions( |
|||
name='switch', |
|||
options={'permissions': (('view_switch', 'Peut voir un objet switch'),)}, |
|||
), |
|||
] |
|||
@ -0,0 +1,21 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-25 23:23 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0044_auto_20180326_0002'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterField( |
|||
model_name='port', |
|||
name='switch', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ports', to='topologie.Switch'), |
|||
), |
|||
] |
|||
@ -0,0 +1,19 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-25 23:29 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0045_auto_20180326_0123'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterUniqueTogether( |
|||
name='port', |
|||
unique_together=set([('switch', 'port')]), |
|||
), |
|||
] |
|||
@ -0,0 +1,26 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0046_auto_20180326_0129'), |
|||
] |
|||
|
|||
|
|||
|
|||
operations = [ |
|||
migrations.CreateModel( |
|||
name='NewAccessPoint', |
|||
fields=[ |
|||
('machine_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='machines.Machine')), |
|||
('location', models.CharField(help_text="Détails sur la localisation de l'AP", max_length=255, null=True, blank=True)), |
|||
], |
|||
bases=('machines.machine',), |
|||
), |
|||
] |
|||
@ -0,0 +1,39 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0047_ap_machine'), |
|||
] |
|||
|
|||
def transfer_ap(apps, schema_editor): |
|||
db_alias = schema_editor.connection.alias |
|||
ap = apps.get_model("topologie", "AccessPoint") |
|||
new_ap = apps.get_model("topologie", "NewAccessPoint") |
|||
ap_list = ap.objects.using(db_alias).all() |
|||
for borne in ap_list: |
|||
new_borne = new_ap() |
|||
new_borne.machine_ptr_id = borne.machine.pk |
|||
new_borne.__dict__.update(borne.machine.__dict__) |
|||
new_borne.location = borne.location |
|||
new_borne.save() |
|||
|
|||
def untransfer_ap(apps, schema_editor): |
|||
return |
|||
|
|||
operations = [ |
|||
migrations.RunPython(transfer_ap, untransfer_ap), |
|||
migrations.DeleteModel( |
|||
name='AccessPoint', |
|||
), |
|||
migrations.RenameModel( |
|||
old_name='NewAccessPoint', |
|||
new_name='AccessPoint', |
|||
), |
|||
] |
|||
@ -0,0 +1,30 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0048_ap_machine'), |
|||
] |
|||
|
|||
|
|||
|
|||
operations = [ |
|||
migrations.CreateModel( |
|||
name='NewSw', |
|||
fields=[ |
|||
('machine_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='machines.Machine')), |
|||
('location', models.CharField(max_length=255)), |
|||
('number', models.PositiveIntegerField()), |
|||
('stack_member_id', models.PositiveIntegerField(blank=True, null=True)), |
|||
('model', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='topologie.ModelSwitch')), |
|||
('stack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='topologie.Stack')), |
|||
], |
|||
bases=('machines.machine',), |
|||
), |
|||
] |
|||
@ -0,0 +1,21 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-25 00:52 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0049_switchs_machine'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='port', |
|||
name='new_sw', |
|||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='ports', to='topologie.NewSw'), |
|||
), |
|||
] |
|||
@ -0,0 +1,39 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0050_port_new_switch'), |
|||
] |
|||
|
|||
def transfer_sw(apps, schema_editor): |
|||
db_alias = schema_editor.connection.alias |
|||
newswitch = apps.get_model("topologie", "NewSw") |
|||
switch = apps.get_model("topologie", "Switch") |
|||
machine = apps.get_model("machines", "Machine") |
|||
sw_list = switch.objects.using(db_alias).all() |
|||
for sw in sw_list: |
|||
new_sw = newswitch() |
|||
new_sw.location = sw.location |
|||
new_sw.number = sw.number |
|||
new_sw.details = sw.details |
|||
new_sw.stack = sw.stack |
|||
new_sw.stack_member_id = sw.stack_member_id |
|||
new_sw.model = sw.model |
|||
new_sw.machine_ptr_id = sw.interface_ptr.machine.pk |
|||
new_sw.__dict__.update(sw.interface_ptr.machine.__dict__) |
|||
new_sw.save() |
|||
|
|||
def untransfer_sw(apps, schema_editor): |
|||
return |
|||
|
|||
|
|||
operations = [ |
|||
migrations.RunPython(transfer_sw, untransfer_sw), |
|||
] |
|||
@ -0,0 +1,37 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-12-31 19:53 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0051_switchs_machine'), |
|||
] |
|||
|
|||
def transfer_port(apps, schema_editor): |
|||
db_alias = schema_editor.connection.alias |
|||
port = apps.get_model("topologie", "Port") |
|||
switch = apps.get_model("topologie", "NewSw") |
|||
port_list = port.objects.using(db_alias).all() |
|||
for p in port_list: |
|||
p.new_sw = switch.objects.filter(machine_ptr=p.switch.machine).first() |
|||
p.save() |
|||
|
|||
def untransfer_port(apps, schema_editor): |
|||
return |
|||
|
|||
operations = [ |
|||
migrations.AlterUniqueTogether( |
|||
name='port', |
|||
unique_together=set([]), |
|||
), |
|||
migrations.RunPython(transfer_port, untransfer_port), |
|||
migrations.RemoveField( |
|||
model_name='port', |
|||
name='switch', |
|||
), |
|||
migrations.RenameField('Port', 'new_sw', 'switch') |
|||
] |
|||
@ -0,0 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0052_transferports'), |
|||
] |
|||
|
|||
|
|||
|
|||
operations = [ |
|||
migrations.DeleteModel( |
|||
name='Switch', |
|||
), |
|||
migrations.RenameModel( |
|||
old_name='NewSw', |
|||
new_name='Switch', |
|||
), |
|||
] |
|||
@ -0,0 +1,38 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-26 15:42 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0053_finalsw'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterModelOptions( |
|||
name='accesspoint', |
|||
options={'permissions': (('view_ap', 'Peut voir une borne'),)}, |
|||
), |
|||
migrations.AlterModelOptions( |
|||
name='switch', |
|||
options={'permissions': (('view_switch', 'Peut voir un objet switch'),)}, |
|||
), |
|||
migrations.AlterField( |
|||
model_name='port', |
|||
name='switch', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ports', to='topologie.Switch'), |
|||
preserve_default=False, |
|||
), |
|||
migrations.AlterUniqueTogether( |
|||
name='port', |
|||
unique_together=set([('switch', 'port')]), |
|||
), |
|||
migrations.AlterUniqueTogether( |
|||
name='switch', |
|||
unique_together=set([('stack', 'stack_member_id')]), |
|||
), |
|||
] |
|||
@ -0,0 +1,74 @@ |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load acl %} |
|||
|
|||
<div class="table-responsive"> |
|||
{% if ap_list.paginator %} |
|||
{% include "pagination.html" with list=ap_list %} |
|||
{% endif %} |
|||
|
|||
|
|||
<table class="table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>{% include "buttons/sort.html" with prefix='ap' col='name' text='Borne' %}</th> |
|||
<th>{% include "buttons/sort.html" with prefix='ap' col='mac' text='Addresse mac' %}</th> |
|||
<th>{% include "buttons/sort.html" with prefix='ap' col='ip' text='Ipv4' %}</th> |
|||
<th>Commentaire</th> |
|||
<th>Localisation</th> |
|||
<th></th> |
|||
</tr> |
|||
</thead> |
|||
{% for ap in ap_list %} |
|||
<tr> |
|||
<td>{{ap.interface_set.first}}</td> |
|||
<td>{{ap.interface_set.first.mac_address}}</td> |
|||
<td>{{ap.interface_set.first.ipv4}}</td> |
|||
<td>{{ap.interface_set.first.details}}</td> |
|||
<td>{{ap.location}}</td> |
|||
<td class="text-right"> |
|||
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'ap' ap.pk %}"> |
|||
<i class="fa fa-history"></i> |
|||
</a> |
|||
{% can_edit ap %} |
|||
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'topologie:edit-ap' ap.id %}"> |
|||
<i class="fa fa-edit"></i> |
|||
</a> |
|||
{% acl_end %} |
|||
{% can_delete ap %} |
|||
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'machines:del-machine' ap.id %}"> |
|||
<i class="fa fa-trash"></i> |
|||
</a> |
|||
{% acl_end %} |
|||
</td> |
|||
</tr> |
|||
{% endfor %} |
|||
</table> |
|||
|
|||
|
|||
{% if ap_list.paginator %} |
|||
{% include "pagination.html" with list=ap_list %} |
|||
{% endif %} |
|||
</div> |
|||
@ -0,0 +1,41 @@ |
|||
{% extends "topologie/sidebar.html" %} |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load bootstrap3 %} |
|||
{% load acl %} |
|||
|
|||
{% block title %}Bornes WiFi{% endblock %} |
|||
|
|||
{% block content %} |
|||
<h2>Points d'accès WiFi</h2> |
|||
{% can_create AccessPoint %} |
|||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-ap' %}"><i class="fa fa-plus"></i> Ajouter une borne</a> |
|||
<hr> |
|||
{% acl_end %} |
|||
{% include "topologie/aff_ap.html" with ap_list=ap_list %} |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
@ -0,0 +1,63 @@ |
|||
{% extends "topologie/sidebar.html" %} |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load bootstrap3 %} |
|||
{% load massive_bootstrap_form %} |
|||
|
|||
{% block title %}Création et modification d'un objet topologie{% endblock %} |
|||
|
|||
{% block content %} |
|||
{% if topoform %} |
|||
{% bootstrap_form_errors topoform %} |
|||
{% endif %} |
|||
{% if machineform %} |
|||
{% bootstrap_form_errors machineform %} |
|||
{% endif %} |
|||
{% if domainform %} |
|||
{% bootstrap_form_errors domainform %} |
|||
{% endif %} |
|||
|
|||
|
|||
|
|||
<form class="form" method="post"> |
|||
{% csrf_token %} |
|||
{% if topoform %} |
|||
<h3>Réglage spécifiques du {{ device }}</h3> |
|||
{% massive_bootstrap_form topoform 'ipv4,machine' mbf_param=i_mbf_param%} |
|||
{% endif %} |
|||
{% if machineform %} |
|||
<h3>Réglages généraux de la machine associée au {{ device }}</h3> |
|||
{% massive_bootstrap_form machineform 'user' %} |
|||
{% endif %} |
|||
{% if domainform %} |
|||
<h3>Nom de la machine</h3> |
|||
{% bootstrap_form domainform %} |
|||
{% endif %} |
|||
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="ok" %} |
|||
</form> |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
@ -0,0 +1,80 @@ |
|||
# ⁻*- mode: python; coding: utf-8 -*- |
|||
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
# se veut agnostique au réseau considéré, de manière à être installable en |
|||
# quelques clics. |
|||
# |
|||
# Copyright © 2018 Benjamin Graillot |
|||
# |
|||
# Copyright © 2013-2015 Raphaël-David Lasseri <lasseri@crans.org> |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; either version 2 of the License, or |
|||
# (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License along |
|||
# with this program; if not, write to the Free Software Foundation, Inc., |
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
|
|||
import sys |
|||
import re |
|||
from datetime import datetime |
|||
|
|||
from django.core.management.base import BaseCommand, CommandError |
|||
from django.utils.timezone import make_aware |
|||
|
|||
from users.models import User |
|||
|
|||
# Une liste d'expressions régulières à chercher dans les logs. |
|||
# Elles doivent contenir un groupe 'date' et un groupe 'user'. |
|||
# Pour le CAS on prend comme entrée cat ~/cas.log | grep -B 2 -A 2 "ACTION: AUTHENTICATION_SUCCESS"| grep 'WHEN\|WHO'|sed 'N;s/\n/ /' |
|||
COMPILED_REGEX = map(re.compile, [ |
|||
r'^(?P<date>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}).*(?:'r'dovecot.*Login: user=<|'r'sshd.*Accepted.*for 'r')(?P<user>[^ >]+).*$', |
|||
r'^(?P<date>.*) LOGIN INFO User logged in : (?P<user>.*)', |
|||
r'WHO: \[username: (?P<user>.*)\] WHEN: (?P<date>.* CET .*)', |
|||
r'WHO: \[username: (?P<user>.*)\] WHEN: (?P<date>.* CEST .*)' |
|||
]) |
|||
|
|||
# Les formats de date en strftime associés aux expressions ci-dessus. |
|||
DATE_FORMATS = [ |
|||
"%Y-%m-%dT%H:%M:%S", |
|||
"%d/%b/%Y:%H:%M:%S", |
|||
"%a %b %d CET %H:%M:%S%Y", |
|||
"%a %b %d CEST %H:%M:%S%Y" |
|||
] |
|||
|
|||
class Command(BaseCommand): |
|||
help = 'Update the time of the latest connection for users by matching stdin against a set of regular expressions' |
|||
|
|||
def handle(self, *args, **options): |
|||
|
|||
def parse_logs(logfile): |
|||
""" |
|||
Parse les logs sur l'entrée standard et rempli un dictionnaire |
|||
ayant pour clef le pseudo de l'adherent |
|||
""" |
|||
global COMPILED_REGEX, DATE_FORMATS |
|||
|
|||
parsed_log = {} |
|||
for line in logfile: |
|||
for i, regex in enumerate(COMPILED_REGEX): |
|||
m = regex.match(line) |
|||
if m: |
|||
parsed_log[m.group('user')] = make_aware(datetime.strptime(m.group('date'), DATE_FORMATS[i])) |
|||
return parsed_log |
|||
|
|||
parsed_log = parse_logs(sys.stdin) |
|||
|
|||
for pseudo in parsed_log: |
|||
for user in User.objects.filter(pseudo=pseudo): |
|||
last_login = parsed_log.get(user.pseudo, user.last_login) |
|||
if not user.last_login: |
|||
user.last_login = last_login |
|||
elif last_login > user.last_login: |
|||
user.last_login = last_login |
|||
user.save() |
|||
@ -0,0 +1,19 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-03-24 18:06 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('users', '0069_club_mailing'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterModelOptions( |
|||
name='listshell', |
|||
options={'permissions': (('view_listshell', "Peut voir un objet shell quelqu'il soit"),)}, |
|||
), |
|||
] |
|||
@ -0,0 +1,47 @@ |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
{% load acl %} |
|||
<table class="table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>Shell</th> |
|||
<th></th> |
|||
</tr> |
|||
</thead> |
|||
{% for shell in shell_list %} |
|||
<tr> |
|||
<td>{{ shell.shell }}</td> |
|||
<td class="text-right"> |
|||
{% can_delete shell %} |
|||
{% include 'buttons/suppr.html' with href='users:del-shell' id=shell.id %} |
|||
{% acl_end %} |
|||
{% can_edit shell %} |
|||
{% include 'buttons/edit.html' with href='users:edit-shell' id=shell.id %} |
|||
{% acl_end %} |
|||
{% include 'buttons/history.html' with href='users:history' name='shell' id=shell.id %} |
|||
</td> |
|||
</tr> |
|||
{% endfor %} |
|||
</table> |
|||
|
|||
@ -0,0 +1,41 @@ |
|||
{% extends "users/sidebar.html" %} |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load bootstrap3 %} |
|||
{% load acl %} |
|||
|
|||
{% block title %}Utilisateurs{% endblock %} |
|||
|
|||
{% block content %} |
|||
<h2>Liste des Shells</h2> |
|||
{% can_create ListShell %} |
|||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-shell' %}"><i class="fa fa-plus"></i> Ajouter un shell</a> |
|||
{% acl_end %} |
|||
{% include "users/aff_shell.html" with shell_list=shell_list %} |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
|
|||
Loading…
Reference in new issue