mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Merge branch 'master' of https://gitlab.rezometz.org/rezo/re2o
This commit is contained in:
commit
87c9b21711
14 changed files with 70 additions and 65 deletions
|
@ -19,7 +19,8 @@ Avec apt (recommandé):
|
|||
* python3-dateutil (jessie-backports)
|
||||
* texlive-latex-base (jessie)
|
||||
* texlive-fonts-recommended (jessie)
|
||||
* python3-djangorestframework (stretch)
|
||||
* python3-djangorestframework (jessie)
|
||||
* python3-django-reversion (stretch)
|
||||
|
||||
Avec pip3:
|
||||
* django-bootstrap3 (pip install)
|
||||
|
@ -28,9 +29,12 @@ Avec pip3:
|
|||
Moteur de db conseillé (mysql), postgresql fonctionne également.
|
||||
Pour mysql, il faut installer :
|
||||
|
||||
* mysql-server (jessie)
|
||||
* python3-mysqldb (jessie-backports)
|
||||
|
||||
Sur le serveur mysql :
|
||||
* mysql-server (jessie)
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Le site est prêt a fonctionner, il faut simplement créer la base de donnée (par défaut re2o), et régler les variables présentes dans setting_local.py
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
{% if facture_list.paginator %}
|
||||
<ul class="pagination nav navbar-nav">
|
||||
{% if facture_list.has_previous %}
|
||||
<li><a href="?page={{ facture_list.previous_page_number }}">Suivantes</a></li>
|
||||
{% endif %}
|
||||
{% for page in facture_list.paginator.page_range %}
|
||||
<li class="{% if facture_list.number == page %}active{% endif %}"><a href="?page={{page }}">{{ page }}</a></li>
|
||||
{% endfor %}
|
||||
|
||||
{% if facture_list.has_next %}
|
||||
<li> <a href="?page={{ facture_list.next_page_number }}">Précédentes</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% include "pagination.html" with list=facture_list %}
|
||||
{% endif %}
|
||||
|
||||
<table class="table table-striped">
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.dispatch import receiver
|
|||
from django.forms import ValidationError
|
||||
from macaddress.fields import MACAddressField
|
||||
|
||||
|
||||
from re2o.settings import MAIN_EXTENSION
|
||||
|
||||
|
||||
class Machine(models.Model):
|
||||
|
@ -35,7 +35,7 @@ class Interface(models.Model):
|
|||
machine = models.ForeignKey('Machine', on_delete=models.CASCADE)
|
||||
type = models.ForeignKey('MachineType', on_delete=models.PROTECT)
|
||||
details = models.CharField(max_length=255, blank=True)
|
||||
dns = models.CharField(help_text="Obligatoire et unique, doit se terminer en %s et ne pas comporter d'autres points" % ", ".join(Extension.objects.values_list('name', flat=True)), max_length=255, unique=True)
|
||||
dns = models.CharField(help_text="Obligatoire et unique, doit se terminer par exemple en %s et ne pas comporter d'autres points" % MAIN_EXTENSION, max_length=255, unique=True)
|
||||
|
||||
def is_active(self):
|
||||
""" Renvoie si une interface doit avoir accès ou non """
|
||||
|
@ -43,11 +43,6 @@ class Interface(models.Model):
|
|||
user = self.machine.user
|
||||
return machine.active and user.has_access()
|
||||
|
||||
#def save(self, *args, **kwargs):
|
||||
# user = self.machine.user
|
||||
# user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
|
||||
# super(Interface, self).save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return self.dns
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from machines.models import Interface
|
|||
class InterfaceSerializer( serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Interface
|
||||
fields = ('ipv4', 'mac_address', 'dns')
|
||||
fields = ('ipv4', 'mac_address', 'dns', 'type')
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
{% if machines_list.paginator %}
|
||||
<ul class="pagination nav navbar-nav">
|
||||
{% if machines_list.has_previous %}
|
||||
<li><a href="?page={{ machines_list.previous_page_number }}">Suivants</a></li>
|
||||
{% endif %}
|
||||
{% for page in machines_list.paginator.page_range %}
|
||||
<li class="{% if machines_list.number == page %}active{% endif %}"><a href="?page={{page }}">{{ page }}</a></li>
|
||||
{% endfor %}
|
||||
|
||||
{% if machines_list.has_next %}
|
||||
<li> <a href="?page={{ machines_list.next_page_number }}">Précédents</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% include "pagination.html" with list=machines_list %}
|
||||
{% endif %}
|
||||
|
||||
<table class="table table-striped">
|
||||
|
|
|
@ -22,5 +22,5 @@ urlpatterns = [
|
|||
url(r'^history/(?P<object>extension)/(?P<id>[0-9]+)$', views.history, name='history'),
|
||||
url(r'^$', views.index, name='index'),
|
||||
url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'),
|
||||
url(r'^rest/dns-ip/$', views.dns_ip, name='dns-ip'),
|
||||
url(r'^rest/mac-ip-dns/$', views.mac_ip_dns, name='mac-ip-dns'),
|
||||
]
|
||||
|
|
|
@ -415,8 +415,7 @@ def mac_ip(request):
|
|||
s.pop('dns')
|
||||
return JSONResponse(seria)
|
||||
|
||||
def dns_ip(request):
|
||||
def mac_ip_dns(request):
|
||||
seria = interface_list(request)
|
||||
for s in seria:
|
||||
s.pop('mac_address')
|
||||
return JSONResponse(seria)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
|
|||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
import os
|
||||
from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP
|
||||
from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP, MAIN_EXTENSION, UID_RANGES
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
{% 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 %}
|
||||
<h6>(Seulement les 15 premiers résultats sont affichés dans chaque catégorie)</h6>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -54,21 +54,21 @@ def search_result(search, type, request):
|
|||
|
||||
for i in aff:
|
||||
if i == '0':
|
||||
users = User.objects.filter((Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query)
|
||||
users = User.objects.filter((Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query)[:15]
|
||||
query = Q(user__pseudo__icontains = search) | Q(user__name__icontains = search) | Q(user__surname__icontains = search)
|
||||
if i == '1':
|
||||
machines = Interface.objects.filter(machine=Machine.objects.filter(query)) | Interface.objects.filter(Q(dns__icontains = search))
|
||||
machines = Machine.objects.filter(query)[:15]
|
||||
if i == '2':
|
||||
factures = Facture.objects.filter(query & date_query)
|
||||
factures = Facture.objects.filter(query & date_query)[:15]
|
||||
if i == '3':
|
||||
bans = Ban.objects.filter(query)
|
||||
bans = Ban.objects.filter(query)[:15]
|
||||
if i == '4':
|
||||
whitelists = Whitelist.objects.filter(query)
|
||||
whitelists = Whitelist.objects.filter(query)[:15]
|
||||
if i == '5':
|
||||
portlist = Port.objects.filter(details__icontains = search)
|
||||
portlist = Port.objects.filter(details__icontains = search)[:15]
|
||||
if i == '6':
|
||||
switchlist = Switch.objects.filter(details__icontains = search)
|
||||
return {'users_list': users, 'interfaces_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist}
|
||||
switchlist = Switch.objects.filter(details__icontains = search)[:15]
|
||||
return {'users_list': users, 'machines_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist}
|
||||
|
||||
@login_required
|
||||
def search(request):
|
||||
|
|
17
templates/pagination.html
Normal file
17
templates/pagination.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<ul class="pagination nav navbar-nav">
|
||||
{% if list.has_previous %}
|
||||
<li><a href="?page=1"> << </a></li>
|
||||
<li><a href="?page={{ list.previous_page_number }}"> < </a></li>
|
||||
{% endif %}
|
||||
{% for page in list.paginator.page_range %}
|
||||
{% if list.number <= page|add:"3" and list.number >= page|add:"-3" %}
|
||||
<li class="{% if list.number == page %}active{% endif %}"><a href="?page={{page }}">{{ page }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if list.has_next %}
|
||||
<li><a href="?page={{ list.next_page_number }}"> > </a></li>
|
||||
<li><a href="?page={{ list.paginator.page_range|length }}"> >> </a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
19
users/migrations/0038_user_rezo_rez_uid.py
Normal file
19
users/migrations/0038_user_rezo_rez_uid.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 = [
|
||||
('users', '0037_ldapuser_login_shell'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='rezo_rez_uid',
|
||||
field=models.IntegerField(null=True, blank=True, unique=True),
|
||||
),
|
||||
]
|
|
@ -116,6 +116,7 @@ class User(AbstractBaseUser):
|
|||
state = models.IntegerField(choices=STATES, default=STATE_ACTIVE)
|
||||
registered = models.DateTimeField(auto_now_add=True)
|
||||
uid_number = models.IntegerField(default=auto_uid, unique=True)
|
||||
rezo_rez_uid = models.IntegerField(unique=True, blank=True, null=True)
|
||||
|
||||
USERNAME_FIELD = 'pseudo'
|
||||
REQUIRED_FIELDS = ['name', 'surname', 'email']
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
{% if users_list.paginator %}
|
||||
<ul class="pagination nav navbar-nav">
|
||||
{% if users_list.has_previous %}
|
||||
<li><a href="?page={{ users_list.previous_page_number }}">Suivants</a></li>
|
||||
{% endif %}
|
||||
{% for page in users_list.paginator.page_range %}
|
||||
<li class="{% if users_list.number == page %}active{% endif %}"><a href="?page={{page }}">{{ page }}</a></li>
|
||||
{% endfor %}
|
||||
|
||||
{% if users_list.has_next %}
|
||||
<li> <a href="?page={{ users_list.next_page_number }}">Précédents</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% include "pagination.html" with list=users_list %}
|
||||
{% endif %}
|
||||
|
||||
<table class="table table-striped">
|
||||
|
@ -19,6 +8,7 @@
|
|||
<th>Prénom</th>
|
||||
<th>Nom</th>
|
||||
<th>Pseudo</th>
|
||||
<th>Uid</th>
|
||||
<th>Fin de cotisation le</th>
|
||||
<th>Connexion</th>
|
||||
<th>Profil</th>
|
||||
|
@ -29,6 +19,7 @@
|
|||
<td>{{ user.name }}</td>
|
||||
<td>{{ user.surname }}</td>
|
||||
<td>{{ user.pseudo }}</td>
|
||||
<td>{{ user.uid_number }}</td>
|
||||
<td>{% if user.is_adherent %}{{ user.end_adhesion }}{% else %}Non adhérent{% endif %}</td>
|
||||
<td>{% if user.has_access == True %}
|
||||
<font color="green">Active</font>
|
||||
|
|
Loading…
Reference in a new issue