diff --git a/cotisations/templates/cotisations/aff_cotisations.html b/cotisations/templates/cotisations/aff_cotisations.html new file mode 100644 index 00000000..cfb7f25c --- /dev/null +++ b/cotisations/templates/cotisations/aff_cotisations.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + {% for facture in facture_list %} + + + + + + + + + + {% endfor %} +
UtilisateurDesignationNombrePrix unitaireMoyen de paiementDate
{{ facture.user }}{{ facture.name }}{{ facture.number }}{{ facture.prix }}{{ facture.paiement }}{{ facture.date }} Editer
+ diff --git a/cotisations/templates/cotisations/index.html b/cotisations/templates/cotisations/index.html index 0248920c..d715972a 100644 --- a/cotisations/templates/cotisations/index.html +++ b/cotisations/templates/cotisations/index.html @@ -4,29 +4,9 @@ {% block title %}Facture{% endblock %} {% block content %} - - - - - - - - - - - - - {% for facture in facture_list %} - - - - - - - - - - {% endfor %} -
UtilisateurDesignationNombrePrix unitaireMoyen de paiementDate
{{ facture.user }}{{ facture.name }}{{ facture.number }}{{ facture.prix }}{{ facture.paiement }}{{ facture.date }}Editer
+ {% include "cotisations/aff_cotisations.html" with facture_list=facture_list %} +
+
+
{% endblock %} diff --git a/search/__pycache__/models.cpython-34.pyc b/search/__pycache__/models.cpython-34.pyc index a3d7cea6..103fb5a6 100644 Binary files a/search/__pycache__/models.cpython-34.pyc and b/search/__pycache__/models.cpython-34.pyc differ diff --git a/search/models.py b/search/models.py index fee5f7ef..8de5d9ba 100644 --- a/search/models.py +++ b/search/models.py @@ -8,3 +8,4 @@ from users.models import User class SearchForm(Form): search_field = forms.CharField(label = 'Search', max_length = 100) + diff --git a/search/templates/search/index.html b/search/templates/search/index.html index d0568fc9..30b9f8e6 100644 --- a/search/templates/search/index.html +++ b/search/templates/search/index.html @@ -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 %}

Résultats dans les utilisateurs

- - - - - - - - - - {% for user in users_list %} - - - - - - - {% endfor %} -
PrénomNomPseudoModifier
{{ user.name }}{{ user.surname }}{{ user.pseudo }}Editer
+ {% include "users/aff_users.html" with users_list=users_list %} {% endif%} {% if machine_list %}

Résultats dans les machines :

@@ -42,53 +25,11 @@ {% endif %} {% if facture_list %}

Résultats dans les factures :

- - - - - - - - - - - - - {% for facture in facture_list %} - - - - - - - - - - {% endfor %} -
UtilisateurDesignationNombrePrix unitaireMoyen de paiementDate
{{ facture.user }}{{ facture.name }}{{ facture.number }}{{ facture.prix }}{{ facture.paiement }}{{ facture.date }}Editer
+ {% include "cotisations/aff_cotisations.html" with facture_list=facture_list %} {% endif %} {% if ban_list %}

Résultats dans les banissements :

- - - - - - - - - - - {% for ban in ban_list %} - - - - - - - - {% endfor %} -
UtilisateurRaisonDate de débutDate de fin
{{ ban.user }}{{ ban.raison }}{{ ban.date_start }}{{ ban.date_end }}Editer
+ {% 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%}

Aucun résultat

diff --git a/search/templates/search/search.html b/search/templates/search/search.html index 063ee55d..9be85b89 100644 --- a/search/templates/search/search.html +++ b/search/templates/search/search.html @@ -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 %} diff --git a/users/__pycache__/admin.cpython-34.pyc b/users/__pycache__/admin.cpython-34.pyc index ad9c167d..3053cd1e 100644 Binary files a/users/__pycache__/admin.cpython-34.pyc and b/users/__pycache__/admin.cpython-34.pyc differ diff --git a/users/__pycache__/models.cpython-34.pyc b/users/__pycache__/models.cpython-34.pyc index d62f0a89..3c8d3f85 100644 Binary files a/users/__pycache__/models.cpython-34.pyc and b/users/__pycache__/models.cpython-34.pyc differ diff --git a/users/__pycache__/urls.cpython-34.pyc b/users/__pycache__/urls.cpython-34.pyc index 8eea11c0..6ebcd722 100644 Binary files a/users/__pycache__/urls.cpython-34.pyc and b/users/__pycache__/urls.cpython-34.pyc differ diff --git a/users/__pycache__/views.cpython-34.pyc b/users/__pycache__/views.cpython-34.pyc index 4bef2323..517008a2 100644 Binary files a/users/__pycache__/views.cpython-34.pyc and b/users/__pycache__/views.cpython-34.pyc differ diff --git a/users/templates/users/aff_bans.html b/users/templates/users/aff_bans.html new file mode 100644 index 00000000..cc94a24b --- /dev/null +++ b/users/templates/users/aff_bans.html @@ -0,0 +1,21 @@ + + + + + + + + + + + {% for ban in ban_list %} + + + + + + + + {% endfor %} +
UtilisateurRaisonDate de débutDate de fin
{{ ban.user }}{{ ban.raison }}{{ ban.date_start }}{{ ban.date_end }} Editer
+ diff --git a/users/templates/users/aff_users.html b/users/templates/users/aff_users.html new file mode 100644 index 00000000..106fc3e8 --- /dev/null +++ b/users/templates/users/aff_users.html @@ -0,0 +1,26 @@ + + + + + + + + + + + {% for user in users_list %} + + + + + + + + {% endfor %} +
PrénomNomPseudoInscrit leProfil
{{ user.name }}{{ user.surname }}{{ user.pseudo }}{{ user.registered }}
+ {% csrf_token %} + + +
+
+ diff --git a/users/templates/users/index.html b/users/templates/users/index.html index 651ca085..34a4f3d7 100644 --- a/users/templates/users/index.html +++ b/users/templates/users/index.html @@ -4,25 +4,9 @@ {% block title %}Utilisateurs{% endblock %} {% block content %} - - - - - - - - - - - {% for user in users_list %} - - - - - - - - {% endfor %} -
PrénomNomPseudoInscrit leModifier
{{ user.name }}{{ user.surname }}{{ user.pseudo }}{{ user.registered }}Editer
+ {% include "users/aff_users.html" with users_list=users_list %} +
+
+
{% endblock %} diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html new file mode 100644 index 00000000..2ea0f583 --- /dev/null +++ b/users/templates/users/profil.html @@ -0,0 +1,63 @@ +{% extends "users/sidebar.html" %} +{% load bootstrap3 %} + +{% block title %}Profil{% endblock %} + +{% block content %} +

Adhérent

+ Editer + Changer le mot de passe + Changer le statut +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Prénom{{ user.name }}Nom{{ user.surname }}
Pseudo{{ user.pseudo }}E-mail{{ user.email }}
Ecole{{ user.school }}Promo{{ user.promo }}
Chambre{{ user.room }}Date d'inscription{{ user.registered}}
+

Machines :

+ {% if machine_list %} + + {% else %} +

Aucune machine

+ {% endif %} +

Cotisations :

+

Ajouter une cotisation

+ {% if facture_list %} + {% include "cotisations/aff_cotisations.html" with facture_list=facture_list %} + {% else %} +

Aucune facture

+ {% endif %} +

Bannissements :

+

Ajouter un bannissement

+ {% if ban_list %} + {% include "users/aff_bans.html" with ban_list=ban_list %} + {% else %} +

Aucun bannissement

+ {% endif %} +
+
+
+{% endblock %} + diff --git a/users/urls.py b/users/urls.py index 9e435547..4006d639 100644 --- a/users/urls.py +++ b/users/urls.py @@ -11,6 +11,7 @@ urlpatterns = [ url(r'^edit_ban/(?P[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'), ] diff --git a/users/views.py b/users/views.py index 7b63fae3..8c1fa7b8 100644 --- a/users/views.py +++ b/users/views.py @@ -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/") +