mirror of https://gitlab.federez.net/re2o/re2o
49 changed files with 842 additions and 141 deletions
@ -1,4 +1,4 @@ |
|||
settings.py |
|||
settings* |
|||
settings_local.py |
|||
*.swp |
|||
*.pyc |
|||
__pycache__ |
|||
|
|||
@ -0,0 +1,88 @@ |
|||
from django import forms |
|||
from django.forms import ModelForm |
|||
from .models import Article, Paiement, Facture, Banque |
|||
|
|||
class NewFactureForm(ModelForm): |
|||
article = forms.ModelMultipleChoiceField(queryset=Article.objects.all(), label="Article") |
|||
|
|||
def __init__(self, *args, **kwargs): |
|||
super(NewFactureForm, self).__init__(*args, **kwargs) |
|||
self.fields['number'].label = 'Quantité' |
|||
self.fields['cheque'].required = False |
|||
self.fields['banque'].required = False |
|||
self.fields['cheque'].label = 'Numero de chèque' |
|||
self.fields['banque'].empty_label = "Non renseigné" |
|||
self.fields['paiement'].empty_label = "Séléctionner un moyen de paiement" |
|||
|
|||
class Meta: |
|||
model = Facture |
|||
fields = ['paiement','banque','cheque','number'] |
|||
|
|||
def clean(self): |
|||
cleaned_data=super(NewFactureForm, self).clean() |
|||
paiement = cleaned_data.get("paiement") |
|||
cheque = cleaned_data.get("cheque") |
|||
banque = cleaned_data.get("banque") |
|||
if paiement.moyen=="chèque" and not (cheque and banque): |
|||
raise forms.ValidationError("Le numero de chèque et la banque sont obligatoires") |
|||
return cleaned_data |
|||
|
|||
class EditFactureForm(NewFactureForm): |
|||
class Meta(NewFactureForm.Meta): |
|||
fields = '__all__' |
|||
|
|||
def __init__(self, *args, **kwargs): |
|||
super(EditFactureForm, self).__init__(*args, **kwargs) |
|||
self.fields['user'].label = 'Adherent' |
|||
self.fields['name'].label = 'Designation' |
|||
self.fields['prix'].label = 'Prix unitaire' |
|||
self.fields['user'].empty_label = "Séléctionner l'adhérent propriétaire" |
|||
self.fields.pop('article') |
|||
|
|||
class ArticleForm(ModelForm): |
|||
class Meta: |
|||
model = Article |
|||
fields = '__all__' |
|||
|
|||
def __init__(self, *args, **kwargs): |
|||
super(ArticleForm, self).__init__(*args, **kwargs) |
|||
self.fields['name'].label = "Désignation de l'article" |
|||
|
|||
class DelArticleForm(ModelForm): |
|||
articles = forms.ModelMultipleChoiceField(queryset=Article.objects.all(), label="Articles actuels", widget=forms.CheckboxSelectMultiple) |
|||
|
|||
class Meta: |
|||
fields = ['articles'] |
|||
model = Article |
|||
|
|||
class PaiementForm(ModelForm): |
|||
class Meta: |
|||
model = Paiement |
|||
fields = ['moyen'] |
|||
|
|||
def __init__(self, *args, **kwargs): |
|||
super(PaiementForm, self).__init__(*args, **kwargs) |
|||
self.fields['moyen'].label = 'Moyen de paiement à ajouter' |
|||
|
|||
class DelPaiementForm(ModelForm): |
|||
paiements = forms.ModelMultipleChoiceField(queryset=Paiement.objects.all(), label="Moyens de paiement actuels", widget=forms.CheckboxSelectMultiple) |
|||
|
|||
class Meta: |
|||
exclude = ['moyen'] |
|||
model = Paiement |
|||
|
|||
class BanqueForm(ModelForm): |
|||
class Meta: |
|||
model = Banque |
|||
fields = ['name'] |
|||
|
|||
def __init__(self, *args, **kwargs): |
|||
super(BanqueForm, self).__init__(*args, **kwargs) |
|||
self.fields['name'].label = 'Banque à ajouter' |
|||
|
|||
class DelBanqueForm(ModelForm): |
|||
banques = forms.ModelMultipleChoiceField(queryset=Banque.objects.all(), label="Banques actuelles", widget=forms.CheckboxSelectMultiple) |
|||
|
|||
class Meta: |
|||
exclude = ['name'] |
|||
model = Banque |
|||
@ -1,7 +1,11 @@ |
|||
{% extends "base.html" %} |
|||
|
|||
{% block sidebar %} |
|||
<p><a href="{% url "search:search" %}">Créer une facture</a></p> |
|||
<p><a href="{% url "search:search" %}">Editer une facture</a></p> |
|||
<p><a href="{% url "cotisations:index" %}">Liste des factures</a></p> |
|||
<p><a href="{% url "cotisations:add-article" %}">Ajouter un article</a></p> |
|||
<p><a href="{% url "cotisations:del-article" %}">Retirer un article</a></p> |
|||
<p><a href="{% url "cotisations:add-paiement" %}">Ajouter un moyen de paiement</a></p> |
|||
<p><a href="{% url "cotisations:del-paiement" %}">Retirer un moyen de paiement</a></p> |
|||
<p><a href="{% url "cotisations:add-banque" %}">Ajouter une banque</a></p> |
|||
<p><a href="{% url "cotisations:del-banque" %}">Retirer une banque</a></p> |
|||
{% endblock %} |
|||
|
|||
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('machines', '0012_auto_20160704_0118'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='machine', |
|||
name='active', |
|||
field=models.BooleanField(default=True), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='interface', |
|||
name='dns', |
|||
field=models.CharField(max_length=255, unique=True, help_text='Obligatoire et unique, doit se terminer en .rez et ne pas comporter de points'), |
|||
), |
|||
] |
|||
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import machines.models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('machines', '0013_auto_20160705_1014'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterField( |
|||
model_name='interface', |
|||
name='dns', |
|||
field=models.CharField(unique=True, validators=[machines.models.full_domain_validator], max_length=255, help_text="Obligatoire et unique, doit se terminer en .rez et ne pas comporter d'autres points"), |
|||
), |
|||
] |
|||
@ -1,5 +1,4 @@ |
|||
{% extends "base.html" %} |
|||
|
|||
{% block sidebar %} |
|||
<p><a href="{% url "search:search" %}">Nouvelle machine</a></p> |
|||
{% endblock %} |
|||
|
|||
@ -0,0 +1,108 @@ |
|||
""" |
|||
Django settings for re2o project. |
|||
|
|||
Generated by 'django-admin startproject' using Django 1.8.13. |
|||
|
|||
For more information on this file, see |
|||
https://docs.djangoproject.com/en/1.8/topics/settings/ |
|||
|
|||
For the full list of settings and their values, see |
|||
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, ALLOWED_EXTENSIONS |
|||
|
|||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
|||
|
|||
|
|||
# Quick-start development settings - unsuitable for production |
|||
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ |
|||
|
|||
# Application definition |
|||
|
|||
INSTALLED_APPS = ( |
|||
'django.contrib.admin', |
|||
'django.contrib.auth', |
|||
'django.contrib.contenttypes', |
|||
'django.contrib.sessions', |
|||
'django.contrib.messages', |
|||
'django.contrib.staticfiles', |
|||
'bootstrap3', |
|||
'users', |
|||
'machines', |
|||
'cotisations', |
|||
'topologie', |
|||
'search', |
|||
'logs', |
|||
) |
|||
|
|||
MIDDLEWARE_CLASSES = ( |
|||
'django.contrib.sessions.middleware.SessionMiddleware', |
|||
'django.middleware.common.CommonMiddleware', |
|||
'django.middleware.csrf.CsrfViewMiddleware', |
|||
'django.contrib.auth.middleware.AuthenticationMiddleware', |
|||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
|||
'django.contrib.messages.middleware.MessageMiddleware', |
|||
'django.middleware.clickjacking.XFrameOptionsMiddleware', |
|||
'django.middleware.security.SecurityMiddleware', |
|||
) |
|||
|
|||
ROOT_URLCONF = 're2o.urls' |
|||
|
|||
TEMPLATES = [ |
|||
{ |
|||
'BACKEND': 'django.template.backends.django.DjangoTemplates', |
|||
'DIRS': [ |
|||
os.path.join(BASE_DIR, 'templates').replace('\\', '/'), |
|||
], |
|||
'APP_DIRS': True, |
|||
'OPTIONS': { |
|||
'context_processors': [ |
|||
'django.template.context_processors.debug', |
|||
'django.template.context_processors.request', |
|||
'django.contrib.auth.context_processors.auth', |
|||
'django.contrib.messages.context_processors.messages', |
|||
], |
|||
}, |
|||
}, |
|||
] |
|||
|
|||
WSGI_APPLICATION = 're2o.wsgi.application' |
|||
|
|||
|
|||
# Internationalization |
|||
# https://docs.djangoproject.com/en/1.8/topics/i18n/ |
|||
|
|||
LANGUAGE_CODE = 'fr-fr' |
|||
|
|||
TIME_ZONE = 'Europe/Paris' |
|||
|
|||
USE_I18N = True |
|||
|
|||
USE_L10N = True |
|||
|
|||
USE_TZ = True |
|||
|
|||
|
|||
# django-bootstrap3 config dictionnary |
|||
BOOTSTRAP3 = { |
|||
'jquery_url': '/static/js/jquery-2.2.4.min.js', |
|||
'base_url': '/static/bootstrap/', |
|||
'include_jquery': True, |
|||
} |
|||
|
|||
BOOTSTRAP_BASE_URL = '/static/bootstrap/' |
|||
|
|||
STATICFILES_DIRS = ( |
|||
# Put strings here, like "/home/html/static" or "C:/www/django/static". |
|||
# Always use forward slashes, even on Windows. |
|||
# Don't forget to use absolute paths, not relative paths. |
|||
os.path.join( |
|||
BASE_DIR, |
|||
'static', |
|||
), |
|||
) |
|||
|
|||
STATIC_URL = '/static/' |
|||
@ -0,0 +1,20 @@ |
|||
SECRET_KEY = 'SUPER_SECRET' |
|||
|
|||
DB_PASSWORD = 'SUPER_SECRET' |
|||
|
|||
# SECURITY WARNING: don't run with debug turned on in production! |
|||
DEBUG = False |
|||
|
|||
ALLOWED_HOSTS = [] |
|||
|
|||
DATABASES = { |
|||
'default': { |
|||
'ENGINE': 'django.db.backends.mysql', |
|||
'NAME': 're2o', |
|||
'USER': 're2o', |
|||
'PASSWORD': DB_PASSWORD, |
|||
'HOST': 'localhost', |
|||
} |
|||
} |
|||
|
|||
ALLOWED_EXTENSIONS = ['.example'] |
|||
@ -0,0 +1,11 @@ |
|||
from .models import Port |
|||
from django.forms import ModelForm, Form |
|||
|
|||
class PortForm(ModelForm): |
|||
class Meta: |
|||
model = Port |
|||
fields = '__all__' |
|||
|
|||
class EditPortForm(ModelForm): |
|||
class Meta(PortForm.Meta): |
|||
fields = ['room', 'machine_interface', 'related', 'details'] |
|||
@ -0,0 +1,21 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('machines', '0014_auto_20160706_1220'), |
|||
('topologie', '0011_auto_20160704_2153'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='port', |
|||
name='machine_interface', |
|||
field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, null=True, blank=True, to='machines.Interface'), |
|||
), |
|||
] |
|||
@ -0,0 +1,19 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0012_port_machine_interface'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='port', |
|||
name='related', |
|||
field=models.OneToOneField(null=True, to='topologie.Port', blank=True, related_name='related_port'), |
|||
), |
|||
] |
|||
@ -0,0 +1,26 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0013_port_related'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterUniqueTogether( |
|||
name='port', |
|||
unique_together=set([('switch', 'port')]), |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='port', |
|||
name='_content_type', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='port', |
|||
name='_object_id', |
|||
), |
|||
] |
|||
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0014_auto_20160706_1238'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RemoveField( |
|||
model_name='port', |
|||
name='related', |
|||
), |
|||
migrations.AddField( |
|||
model_name='port', |
|||
name='related', |
|||
field=models.ManyToManyField(related_name='_port_related_+', to='topologie.Port', blank=True), |
|||
), |
|||
] |
|||
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0015_auto_20160706_1452'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RemoveField( |
|||
model_name='port', |
|||
name='related', |
|||
), |
|||
migrations.AddField( |
|||
model_name='port', |
|||
name='related', |
|||
field=models.OneToOneField(blank=True, to='topologie.Port', related_name='related_port', null=True), |
|||
), |
|||
] |
|||
Binary file not shown.
@ -0,0 +1,23 @@ |
|||
<h2>Switch {% if port_list.0 %}{{ port_list.0.switch }}{% endif %}</h2> |
|||
<table class="table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>Port</th> |
|||
<th>Room</th> |
|||
<th>Interface machine</th> |
|||
<th>Related</th> |
|||
<th>Détails</th> |
|||
<th></th> |
|||
</tr> |
|||
</thead> |
|||
{% for port in port_list %} |
|||
<tr> |
|||
<td>{{ port.port }}</td> |
|||
<td>{{ port.room }}</td> |
|||
<td>{{ port.machine_interface }}</td> |
|||
<td>{{ port.related }}</td> |
|||
<td>{{ port.details }}</td> |
|||
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:edit-port' port.id %}"><i class="glyphicon glyphicon-random"></i> Editer</a></td> |
|||
</tr> |
|||
{% endfor %} |
|||
</table> |
|||
@ -0,0 +1,18 @@ |
|||
<table class="table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>Bâtiment</th> |
|||
<th>Numero</th> |
|||
<th>Détails</th> |
|||
<th></th> |
|||
</tr> |
|||
</thead> |
|||
{% for switch in switch_list %} |
|||
<tr> |
|||
<td>{{switch.building}}</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-list-alt"></i> Editer</a></td> |
|||
</tr> |
|||
{% endfor %} |
|||
</table> |
|||
@ -0,0 +1,11 @@ |
|||
{% extends "topologie/sidebar.html" %} |
|||
{% load bootstrap3 %} |
|||
|
|||
{% block title %}Switchs{% endblock %} |
|||
|
|||
{% block content %} |
|||
{% include "topologie/aff_switch.html" with switch_list=switch_list %} |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
@ -0,0 +1,11 @@ |
|||
{% extends "topologie/sidebar.html" %} |
|||
{% load bootstrap3 %} |
|||
|
|||
{% block title %}Ports du switch{% endblock %} |
|||
|
|||
{% block content %} |
|||
{% include "topologie/aff_port.html" with port_list=port_list %} |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
@ -0,0 +1,17 @@ |
|||
{% extends "topologie/sidebar.html" %} |
|||
{% load bootstrap3 %} |
|||
|
|||
{% block title %}Création et modificationd 'utilisateur{% endblock %} |
|||
|
|||
{% block content %} |
|||
{% bootstrap_form_errors topoform %} |
|||
|
|||
<form class="form" method="post"> |
|||
{% csrf_token %} |
|||
{% bootstrap_form topoform %} |
|||
{%bootstrap_button "Créer ou modifier" button_type="submit" icon="ok" %} |
|||
</form> |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
@ -0,0 +1,5 @@ |
|||
{% extends "base.html" %} |
|||
|
|||
{% block sidebar %} |
|||
<p><a href="{% url "topologie:index" %}">Liste des switchs</a></p> |
|||
{% endblock %} |
|||
@ -0,0 +1,10 @@ |
|||
from django.conf.urls import url |
|||
|
|||
from . import views |
|||
|
|||
urlpatterns = [ |
|||
url(r'^$', views.index, name='index'), |
|||
url(r'^switch/(?P<switch_id>[0-9]+)$', views.index_port, name='index-port'), |
|||
url(r'^edit_port/(?P<port_id>[0-9]+)$', views.edit_port, name='edit-port'), |
|||
] |
|||
|
|||
@ -1,3 +1,35 @@ |
|||
from django.shortcuts import render |
|||
from django.shortcuts import render, redirect |
|||
from django.contrib import messages |
|||
|
|||
# Create your views here. |
|||
|
|||
from topologie.models import Switch, Port |
|||
from topologie.forms import EditPortForm |
|||
from users.views import form |
|||
|
|||
|
|||
def index(request): |
|||
switch_list = Switch.objects.order_by('building', 'number') |
|||
return render(request, 'topologie/index.html', {'switch_list': switch_list}) |
|||
|
|||
def index_port(request, switch_id): |
|||
try: |
|||
switch = Switch.objects.get(pk=switch_id) |
|||
except Switch.DoesNotExist: |
|||
messages.error(request, u"Switch inexistant") |
|||
return redirect("/topologie/") |
|||
port_list = Port.objects.filter(switch = switch).order_by('port') |
|||
return render(request, 'topologie/index_p.html', {'port_list':port_list}) |
|||
|
|||
def edit_port(request, port_id): |
|||
try: |
|||
port = Port.objects.get(pk=port_id) |
|||
except Port.DoesNotExist: |
|||
messages.error(request, u"Port inexistant") |
|||
return redirect("/topologie/") |
|||
port = EditPortForm(request.POST or None, instance=port) |
|||
if port.is_valid(): |
|||
port.save() |
|||
messages.success(request, "Le port a bien été modifié") |
|||
return redirect("/topologie") |
|||
return form({'topoform':port}, 'topologie/port.html', request) |
|||
|
|||
|
|||
@ -0,0 +1,30 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import users.models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('users', '0015_whitelist'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterField( |
|||
model_name='ban', |
|||
name='date_end', |
|||
field=models.DateTimeField(help_text='%d/%m/%y %H:%M:%S'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='user', |
|||
name='pseudo', |
|||
field=models.CharField(unique=True, validators=[users.models.linux_user_validator], max_length=32, help_text='Doit contenir uniquement des lettres, chiffres, ou tirets'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='whitelist', |
|||
name='date_end', |
|||
field=models.DateTimeField(help_text='%d/%m/%y %H:%M:%S'), |
|||
), |
|||
] |
|||
@ -0,0 +1,13 @@ |
|||
{% extends "users/sidebar.html" %} |
|||
{% load bootstrap3 %} |
|||
|
|||
{% block title %}Utilisateurs{% endblock %} |
|||
|
|||
{% block content %} |
|||
<h2>Bannissements</h2> |
|||
{% include "users/aff_bans.html" with ban_list=ban_list %} |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
|
|||
@ -0,0 +1,13 @@ |
|||
{% extends "users/sidebar.html" %} |
|||
{% load bootstrap3 %} |
|||
|
|||
{% block title %}Utilisateurs{% endblock %} |
|||
|
|||
{% block content %} |
|||
<h2>Accès à titre gracieux</h2> |
|||
{% include "users/aff_whitelists.html" with white_list=white_list %} |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
{% endblock %} |
|||
|
|||
Loading…
Reference in new issue