8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 00:43:46 +00:00

Ajout de l'état de la connexion dans les affichages d'utilisateur

This commit is contained in:
Dalahro 2016-07-03 21:35:50 +02:00
parent 2aa8138187
commit 1e6f59eaf1
6 changed files with 19 additions and 14 deletions

View file

@ -11,6 +11,7 @@ from users.models import User, Ban
from machines.models import Machine from machines.models import Machine
from cotisations.models import Facture from cotisations.models import Facture
from search.models import SearchForm from search.models import SearchForm
from users.views import has_access
def form(ctx, template, request): def form(ctx, template, request):
c = ctx c = ctx
@ -23,11 +24,14 @@ def search(request):
if search.is_valid(): if search.is_valid():
search = search.cleaned_data['search_field'] search = search.cleaned_data['search_field']
users = User.objects.filter(Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) users = User.objects.filter(Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search))
connexion = []
for user in users:
connexion.append([user, has_access(user)])
machines = None machines = None
query = Q(user__pseudo__icontains = search) | Q(user__name__icontains = search) | Q(user__surname__icontains = search) query = Q(user__pseudo__icontains = search) | Q(user__name__icontains = search) | Q(user__surname__icontains = search)
factures = Facture.objects.filter(query) factures = Facture.objects.filter(query)
bans = Ban.objects.filter(query) bans = Ban.objects.filter(query)
return form({'users_list': users, 'machine_list' : machines, 'facture_list' : factures, 'ban_list' : bans}, 'search/index.html',request) return form({'users_list': connexion, 'machine_list' : machines, 'facture_list' : factures, 'ban_list' : bans}, 'search/index.html',request)
return form({'searchform' : search}, 'search/search.html', request) return form({'searchform' : search}, 'search/search.html', request)
else: else:
search = SearchForm(request.POST or None) search = SearchForm(request.POST or None)

View file

@ -5,27 +5,25 @@
<th>Nom</th> <th>Nom</th>
<th>Pseudo</th> <th>Pseudo</th>
<th>Inscrit le</th> <th>Inscrit le</th>
<th>Etat</th> <th>Connexion</th>
<th>Profil</th> <th>Profil</th>
</tr> </tr>
</thead> </thead>
{% for user in users_list %} {% for donnee in users_list %}
<tr> <tr>
<td>{{ user.name }}</td> <td>{{ donnee.0.name }}</td>
<td>{{ user.surname }}</td> <td>{{ donnee.0.surname }}</td>
<td>{{ user.pseudo }}</td> <td>{{ donnee.0.pseudo }}</td>
<td>{{ user.registered }}</td> <td>{{ donnee.0.registered }}</td>
<td>{% if user.state == 0 %} <td>{% if donnee.1 == True %}
<font color="green">Actif</font> <font color="green">Active</font>
{% elif user.state == 1 %}
<font color="red">Désactivé</font>
{% else %} {% else %}
<font color="orange">Archivé</font> <font color="red">Désactivée</font>
{% endif %} {% endif %}
</td> </td>
<td><form method="POST" action="{% url "users:profil"%}"> <td><form method="POST" action="{% url "users:profil"%}">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="user" id="user" value="{{ user.pseudo }}"></input> <input type="hidden" name="user" id="user" value="{{ donnee.0.pseudo }}"></input>
<button class="btn btn-primary btn-sm" type="submit"><i class="glyphicon glyphicon-tree-deciduous"></i></button> <button class="btn btn-primary btn-sm" type="submit"><i class="glyphicon glyphicon-tree-deciduous"></i></button>
</form> </form>
</td> </td>

View file

@ -145,7 +145,10 @@ def edit_ban(request, banid):
def index(request): def index(request):
users_list = User.objects.order_by('pk') users_list = User.objects.order_by('pk')
return render(request, 'users/index.html', {'users_list': users_list}) connexion = []
for user in users_list:
connexion.append([user, has_access(user)])
return render(request, 'users/index.html', {'users_list': connexion})
def profil(request): def profil(request):
if request.method == 'POST': if request.method == 'POST':