People list

This commit is contained in:
Ethanell 2021-12-03 06:20:07 +01:00
parent b56da36893
commit 593fd25dc5
2 changed files with 32 additions and 3 deletions

View file

@ -1,4 +1,5 @@
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core import serializers
from django.db.models import Q from django.db.models import Q
from django.http import Http404, HttpResponseRedirect, HttpResponseBadRequest, JsonResponse from django.http import Http404, HttpResponseRedirect, HttpResponseBadRequest, JsonResponse
from django.shortcuts import render from django.shortcuts import render
@ -16,8 +17,8 @@ def get_people(people_id: int) -> People:
def index(request): def index(request):
return render(request, "people/personnes.html", { return render(request, "people/peoples.html", {
"personnes": People.objects.all() "peoples": People.objects.all()
}) })
@ -62,4 +63,4 @@ def edit(request, people_id: int):
def ajax_search(request, text: str): def ajax_search(request, text: str):
return JsonResponse(People.objects.filter(Q(first_name__icontains=text) | Q(first_name__icontains=text))) return JsonResponse(serializers.serialize("json", People.objects.filter(Q(first_name__icontains=text) | Q(first_name__icontains=text))), safe=False)

View file

@ -0,0 +1,28 @@
{% extends 'base.html' %}
{% load static %}
{% block content %}
<a href="/a/submit" class="btn-add">+</a>
<section>
<h1>Sauvetages</h1>
<div class="flex-card">
{% for people in peoples %}
<div class="card">
<div class="inner">
<div class="img-container">
<a href="/p/{{ people.pk }}/">
<img src="{% static 'images/sauvetage.png' %}">
</a>
</div>
<div class="content">
<p class="titre">{{ people }}</p>
<a class="btn" href="/p/{{ people.pk }}/">Voir la personne</a>
</div>
</div>
</div>
{% endfor %}
</div>
<a class="btn btn--blue" href="">Charger plus de personnes</a>
</section>
{% include 'quicksearch.html' %}
{% endblock %}