8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-25 22:22:26 +00:00

Ajout du profil et de jolis boutons

This commit is contained in:
root 2016-07-03 18:09:58 +02:00
parent 2630a462f4
commit 64373b600c
16 changed files with 171 additions and 112 deletions

View file

@ -0,0 +1,25 @@
<table class="table table-striped">
<thead>
<tr>
<th>Utilisateur</th>
<th>Designation</th>
<th>Nombre</th>
<th>Prix unitaire</th>
<th>Moyen de paiement</th>
<th>Date</th>
<th></th>
</tr>
</thead>
{% for facture in facture_list %}
<tr>
<td>{{ facture.user }}</td>
<td>{{ facture.name }}</td>
<td>{{ facture.number }}</td>
<td>{{ facture.prix }}</td>
<td>{{ facture.paiement }}</td>
<td>{{ facture.date }}</td>
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:edit-facture' facture.id %}"><i class="glyphicon glyphicon-tree-conifer"></i> Editer</a></td>
</tr>
{% endfor %}
</table>

View file

@ -4,29 +4,9 @@
{% block title %}Facture{% endblock %}
{% block content %}
<table class="table table-striped">
<thead>
<tr>
<th>Utilisateur</th>
<th>Designation</th>
<th>Nombre</th>
<th>Prix unitaire</th>
<th>Moyen de paiement</th>
<th>Date</th>
<th></th>
</tr>
</thead>
{% for facture in facture_list %}
<tr>
<td>{{ facture.user }}</td>
<td>{{ facture.name }}</td>
<td>{{ facture.number }}</td>
<td>{{ facture.prix }}</td>
<td>{{ facture.paiement }}</td>
<td>{{ facture.date }}</td>
<td><a href="{% url 'cotisations:edit-facture' facture.id %}">Editer</a></td>
</tr>
{% endfor %}
</table>
{% include "cotisations/aff_cotisations.html" with facture_list=facture_list %}
<br />
<br />
<br />
{% endblock %}

View file

@ -8,3 +8,4 @@ from users.models import User
class SearchForm(Form):
search_field = forms.CharField(label = 'Search', max_length = 100)

View file

@ -1,29 +1,12 @@
{% extends "search/sidebar.html" %}
{% extends "users/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Utilisateurs{% endblock %}
{% block title %}Résultats de la recherche{% endblock %}
{% block content %}
{% if users_list %}
<h2>Résultats dans les utilisateurs</h2>
<table class="table table-striped">
<thead>
<tr>
<th>Prénom</th>
<th>Nom</th>
<th>Pseudo</th>
<th>Modifier</th>
</tr>
</thead>
{% for user in users_list %}
<tr>
<td>{{ user.name }}</td>
<td>{{ user.surname }}</td>
<td>{{ user.pseudo }}</td>
<td><a href="{% url 'users:edit-info' user.id %}">Editer</a></td>
</tr>
{% endfor %}
</table>
{% include "users/aff_users.html" with users_list=users_list %}
{% endif%}
{% if machine_list %}
<h2>Résultats dans les machines : </h2>
@ -42,53 +25,11 @@
{% endif %}
{% if facture_list %}
<h2>Résultats dans les factures : </h2>
<table class="table table-striped">
<thead>
<tr>
<th>Utilisateur</th>
<th>Designation</th>
<th>Nombre</th>
<th>Prix unitaire</th>
<th>Moyen de paiement</th>
<th>Date</th>
<th></th>
</tr>
</thead>
{% for facture in facture_list %}
<tr>
<td>{{ facture.user }}</td>
<td>{{ facture.name }}</td>
<td>{{ facture.number }}</td>
<td>{{ facture.prix }}</td>
<td>{{ facture.paiement }}</td>
<td>{{ facture.date }}</td>
<td><a href="{% url 'cotisations:edit-facture' facture.id %}">Editer</a></td>
</tr>
{% endfor %}
</table>
{% include "cotisations/aff_cotisations.html" with facture_list=facture_list %}
{% endif %}
{% if ban_list %}
<h2>Résultats dans les banissements : </h2>
<table class="table table-striped">
<thead>
<tr>
<th>Utilisateur</th>
<th>Raison</th>
<th>Date de début</th>
<th>Date de fin</th>
<th></th>
</tr>
</thead>
{% for ban in ban_list %}
<tr>
<td>{{ ban.user }}</td>
<td>{{ ban.raison }}</td>
<td>{{ ban.date_start }}</td>
<td>{{ ban.date_end }}</td>
<td><a href="{% url 'users:edit-ban' ban.id %}">Editer</a></td>
</tr>
{% endfor %}
</table>
{% include "users/aff_bans.html" with ban_list=ban_list %}
{% endif %}
{% if not ban_list and not machine_list and not users_list and not facture_list%}
<h3>Aucun résultat</h3>

View file

@ -1,7 +1,7 @@
{% extends "search/sidebar.html" %}
{% extends "users/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Création et modification d'utilisateur{% endblock %}
{% block title %}Recherche{% endblock %}
{% block content %}
{% bootstrap_form_errors searchform %}

View file

@ -0,0 +1,21 @@
<table class="table table-striped">
<thead>
<tr>
<th>Utilisateur</th>
<th>Raison</th>
<th>Date de début</th>
<th>Date de fin</th>
<th></th>
</tr>
</thead>
{% for ban in ban_list %}
<tr>
<td>{{ ban.user }}</td>
<td>{{ ban.raison }}</td>
<td>{{ ban.date_start }}</td>
<td>{{ ban.date_end }}</td>
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-ban' ban.id %}"><i class="glyphicon glyphicon-grain"></i> Editer</a></td>
</tr>
{% endfor %}
</table>

View file

@ -0,0 +1,26 @@
<table class="table table-striped">
<thead>
<tr>
<th>Prénom</th>
<th>Nom</th>
<th>Pseudo</th>
<th>Inscrit le</th>
<th>Profil</th>
</tr>
</thead>
{% for user in users_list %}
<tr>
<td>{{ user.name }}</td>
<td>{{ user.surname }}</td>
<td>{{ user.pseudo }}</td>
<td>{{ user.registered }}</td>
<td><form method="POST" action="{% url "users:profil"%}">
{% csrf_token %}
<input type="hidden" name="user" id="user" value="{{ user.pseudo }}"></input>
<button class="btn btn-primary btn-sm" type="submit"><i class="glyphicon glyphicon-tree-deciduous"></i></button>
</form>
</td>
</tr>
{% endfor %}
</table>

View file

@ -4,25 +4,9 @@
{% block title %}Utilisateurs{% endblock %}
{% block content %}
<table class="table table-striped">
<thead>
<tr>
<th>Prénom</th>
<th>Nom</th>
<th>Pseudo</th>
<th>Inscrit le</th>
<th>Modifier</th>
</tr>
</thead>
{% for user in users_list %}
<tr>
<td>{{ user.name }}</td>
<td>{{ user.surname }}</td>
<td>{{ user.pseudo }}</td>
<td>{{ user.registered }}</td>
<td><a href="{% url 'users:edit-info' user.id %}">Editer</a></td>
</tr>
{% endfor %}
</table>
{% include "users/aff_users.html" with users_list=users_list %}
<br />
<br />
<br />
{% endblock %}

View file

@ -0,0 +1,63 @@
{% extends "users/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Profil{% endblock %}
{% block content %}
<h2>Adhérent</h2>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-info' user.id %}"><i class="glyphicon glyphicon-fire"></i> Editer</a>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:password' user.id %}"><i class="glyphicon glyphicon-leaf"></i> Changer le mot de passe</a>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:state' user.id %}"><i class="glyphicon glyphicon-flash"></i> Changer le statut</a>
<br />
<br />
<table class="table table-striped">
<tr>
<th>Prénom</th>
<td>{{ user.name }}</td>
<th>Nom</th>
<td>{{ user.surname }}</td>
</tr>
<tr>
<th>Pseudo</th>
<td>{{ user.pseudo }}</td>
<th>E-mail</th>
<td>{{ user.email }}</td>
</tr>
<tr>
<th>Ecole</th>
<td>{{ user.school }}</td>
<th>Promo</th>
<td>{{ user.promo }}</td>
</tr>
<tr>
<th>Chambre</th>
<td>{{ user.room }}</td>
<th>Date d'inscription</th>
<td>{{ user.registered}}</td>
</tr>
</table>
<h2>Machines :</h2>
{% if machine_list %}
<!-- {% include "machine/aff_machines.html" with machine_list=machine_list } -->
{% else %}
<p>Aucune machine</p>
{% endif %}
<h2>Cotisations :</h2>
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:new-facture' user.id %}"><i class="glyphicon glyphicon-piggy-bank"></i> Ajouter une cotisation</a></h4>
{% if facture_list %}
{% include "cotisations/aff_cotisations.html" with facture_list=facture_list %}
{% else %}
<p>Aucune facture</p>
{% endif %}
<h2>Bannissements :</h2>
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-ban' user.id %}"><i class="glyphicon glyphicon-tint"></i> Ajouter un bannissement</a></h4>
{% if ban_list %}
{% include "users/aff_bans.html" with ban_list=ban_list %}
{% else %}
<p>Aucun bannissement</p>
{% endif %}
<br />
<br />
<br />
{% endblock %}

View file

@ -11,6 +11,7 @@ urlpatterns = [
url(r'^edit_ban/(?P<banid>[0-9]+)$', views.edit_ban, name='edit-ban'),
url(r'^add_right/$', views.add_right, name='add-right'),
url(r'^del_right/$', views.del_right, name='del-right'),
url(r'^profil/$', views.profil, name='profil'),
url(r'^$', views.index, name='index'),
]

View file

@ -9,8 +9,11 @@ from django.contrib import messages
from django.db.models import Max
from django.utils import timezone
from users.models import User, Right, Ban, DelRightForm, UserForm, InfoForm, PasswordForm, StateForm, RightForm, BanForm
from users.models import User, Right, Ban, DelRightForm, UserForm, InfoForm, PasswordForm, StateForm, RightForm, BanForm, ProfilForm
from cotisations.models import Facture
from machines.models import Machine
from users.forms import PassForm
from search.models import SearchForm
from cotisations.views import is_adherent
from re2o.login import makeSecret, hashNT
@ -32,7 +35,7 @@ def is_ban(user):
def has_access(user):
""" Renvoie si un utilisateur a accès à internet"""
if user.state == 0 and not is_ban(user) and is_adherent(user):
if user.state == User.STATE_ACTIVE and not is_ban(user) and is_adherent(user):
return True
else:
return False
@ -143,3 +146,17 @@ def edit_ban(request, banid):
def index(request):
users_list = User.objects.order_by('pk')
return render(request, 'users/index.html', {'users_list': users_list})
def profil(request):
if request.method == 'POST':
profil = ProfilForm(request.POST or None)
if profil.is_valid():
profils = profil.cleaned_data['user']
users = User.objects.get(pseudo = profils)
machines = None
factures = Facture.objects.filter(user__pseudo = users)
bans = Ban.objects.filter(user__pseudo = users)
return render(request, 'users/profil.html', {'user': users, 'machine_list' :machines, 'facture_list':factures, 'ban_list':bans})
return redirect("/users/")
return redirect("/users/")