People list
This commit is contained in:
parent
b56da36893
commit
593fd25dc5
2 changed files with 32 additions and 3 deletions
|
@ -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)
|
||||||
|
|
28
templates/people/peoples.html
Normal file
28
templates/people/peoples.html
Normal 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 %}
|
Loading…
Reference in a new issue