Merge branch 'thubrecht/recherche' into 'master'

Fixe la recherche dans l'annuaire

See merge request klub-dev-ens/annuaire!27
This commit is contained in:
Tom Hubrecht 2023-01-30 11:29:11 +01:00
commit 213ec87059
6 changed files with 28 additions and 18 deletions

View file

@ -48,7 +48,7 @@ a:focus,
float: right;
width: 320px;
grid-template-columns: auto;
grid-template-rows: auto auto auto auto 120px;
grid-template-rows: auto auto auto auto auto 15px;
grid-template-areas: "title" "language" "search" "menu" "account";
}
#menu #hamburger {
@ -171,7 +171,7 @@ a:focus,
#account-area {
grid-area: account;
display: block;
padding: 20px;
padding-top: 20px;
text-align: center;
}
#account-area .clipper {
@ -229,7 +229,7 @@ a:focus,
.content {
max-width: 780px;
width: 50vw;
width: 70vw;
margin: 20px;
}
.content h2 {
@ -365,7 +365,7 @@ a:focus,
}
#content-edit-profile form {
width: min(400px, 100%);
width: max(600px, 80%);
margin: 0 auto;
}
#content-edit-profile form .form-entry {
@ -471,6 +471,7 @@ a:focus,
}
#content-edit-profile #free-text-edit-form textarea {
width: 100%;
height: 100px;
padding: 5px;
resize: none;
}

View file

@ -1 +1 @@
{"version":3,"sourceRoot":"","sources":["../scss/_fonts.scss","../scss/_links.scss","../scss/_colors.scss","../scss/_header.scss","../scss/_buttons.scss","../scss/_errors.scss","../scss/_content.scss","../scss/_footer.scss","../scss/_common.scss"],"names":[],"mappings":";AASA;AACA;EACI;EACA;EACA;EACA;;AAKJ;AACA;EACI;EACA;EACA;EACA;;AAKJ;AACA;EACI;EACA;EACA;EACA;;AAUJ;AAUA;AACA;EACI;EACA;EACA;EACA;;ACzDJ;EACI;EACA,OCOQ;;;ADJZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAGI,OCEc;;;ACJlB;EACI;EACA;EACA;EAEA;EACA;EACA,qBACI;;AAMJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAIN;EACI;EAGA;EACA;EACA;EACA;;AAIA;EACI;;;AAIR;EACI;EACA;EACA;EACA,QAhDgB;E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AKE;IACE;;;EAKN;IACE;;;EAIA;IACE;;;EAIJ;AAAA;IAEE;;;EAGF;IACE;IACA;IACA;IACA,qBACE;;EAMF;IACE;;EAGF;AAAA;IAEE;;;EAIJ;IACE;IACA;IACA","file":"annuaire.css"}
{"version":3,"sourceRoot":"","sources":["../scss/_fonts.scss","../scss/_links.scss","../scss/_colors.scss","../scss/_header.scss","../scss/_buttons.scss","../scss/_errors.scss","../scss/_content.scss","../scss/_footer.scss","../scss/_common.scss"],"names":[],"mappings":";AASA;AACA;EACI;EACA;EACA;EACA;;AAKJ;AACA;EACI;EACA;EACA;EACA;;AAKJ;AACA;EACI;EACA;EACA;EACA;;AAUJ;AAUA;AACA;EACI;EACA;EACA;EACA;;ACzDJ;EACI;EACA,OCOQ;;;ADJZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAGI,OCEc;;;ACJlB;EACI;EACA;EACA;EAEA;EACA;EACA,qBACI;;AAMJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAIN;EACI;EAGA;EACA;EACA;EACA;;AAIA;EACI;;;AAIR;EACI;EACA;EACA;EACA,QAhDgB;EAiDhB;EACA;;AAGA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI,kBDzEI;;;AC6EZ;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EAEA,OD5Fc;;AC+FlB;EACI,OD7FI;EC8FJ;;AAGJ;AAAA;EAEI;EACA;EACA;EACA,ODzGc;;AC4GlB;EACI;;AAGJ;EACI;;;AAKJ;EAEI;EACA;EACA;EACA;EAEA,OD1HI;EC2HJ;;AAGJ;EAEI,OD/HU;;;ACmIlB;EAEI;EAEA;EACA,ODjIa;ECkIb;;AAEA;EAEI;EACA;EACA;EACA;EAEA,ODnJI;ECoJJ;;AAGJ;EAEI,ODxJU;;;AC4JlB;EACI;EACA;EACA;EACA;;AAIA;EACI,aH7GU;;;AIlElB;AAAA;AAAA;EACI;EACA,kBFUqB;EETrB;EACA;EACA,OFSe;EERf;EACA;EACA;;;AAGJ;AAAA;AAAA;EACI,kBFC2B;;;AGf/B;EACI;EACA;;;AAGJ;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;;;ACrBR;EACI,OJqBW;;;AIlBf;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;;AAWJ;EACI;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;;AAMJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;;AAGJ;EACI;;AAIA;EACI;;;AAYhB;EACI;EACA;EACA;EACA,qBACI;EAGJ;;AAEA;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;;AAEA;EACI;EACA,OJnGU;EIoGV;EACA;EACA;;AAIR;EACI;EACA;EACA;EACA;;AAGJ;EACI;EAEA;EACA,OJpHS;EIqHT;;AAGJ;EACI;;AAGJ;EACI;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA,kBJtHe;EIuHf;;AAEA;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA,OJvJF;EIwJE;EACA;;AAGJ;EACI;EACA;EACA;;AAGJ;EACE;;AASlB;EACI;EACA;;AAEA;EACI;;AAGJ;EACI;EACA;;;AAMR;EACI;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA,kBJpLe;EIqLf;;AAEA;EACI;;AAGJ;EACI;EACA,OJ7MC;EI8MD;EACA;EACA;;AAGJ;EACI;;AAGJ;EAGI;EACA;;AAIR;EACI;EACA;EACA;EACA,qBACI;EAEJ;EACA;EACA;;AAEA;EACI;;AAMJ;EACI;EACA;;AAEJ;EAAqB;;AACrB;EACI;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;AAAA;EAEI;;AAGJ;EACI;;AAUA;EAAqB;;AACrB;EAAqB;;AAGrB;AAAA;EAEI;;AAIR;EAEI;;AAIR;EACI;;AAGJ;EACI;;AAIA;EACI;EACA;;AAIR;EACI;EACA;;AAIA;EACI;;AAGJ;EACI;EACA;EACA;;AAMR;EACI;EACA;EACA;EACA;;AAKJ;EACI;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA;;AAKJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA,OJ3WC;EI4WD;;AASJ;EACI;;;AC7XhB;EACI;EACA;EACA,OLGkB;EKFlB;;AAEA;EACI;EACA;;;ACNR;EACI;;;AAMJ;EACI;;;AAGJ;EACI;EACA,qBACI;EAEJ,kBNnBc;EMoBd,ONdQ;EMeR,aR6CY;EQ5CZ;EACA;;;AAGJ;EACI;EACA;EACA,kBN5Be;EM6Bf;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA,kBNxCc;EMyCd;;;AAIJ;EACE;IACE;IACA,qBACI;;;EAIN;IACE;;;EAGF;AAAA;IAEE;IACA;IACA;;;EAGF;AAAA;AAAA;AAAA;IAIE;;;EAKE;IACE;;;EAKN;IACE;;;EAIA;IACE;;;EAIJ;AAAA;IAEE;;;EAGF;IACE;IACA;IACA;IACA,qBACE;;EAMF;IACE;;EAGF;AAAA;IAEE;;;EAIJ;IACE;IACA;IACA","file":"annuaire.css"}

View file

@ -8,7 +8,7 @@
.content {
max-width: 780px;
width: 50vw;
width: 70vw;
margin: 20px;
h2 {
@ -195,7 +195,7 @@
#content-edit-profile {
form {
width: min(400px, 100%);
width: max(600px, 80%);
margin: 0 auto;
.form-entry {

View file

@ -12,7 +12,7 @@ $account-area-height: 120px;
width: 320px;
// height: 100%;
grid-template-columns: auto;
grid-template-rows: auto auto auto auto $account-area-height;
grid-template-rows: auto auto auto auto auto 15px;
grid-template-areas:
"title"
"language"
@ -169,7 +169,7 @@ $account-area-height: 120px;
#account-area {
grid-area: account;
display: block;
padding: 20px;
padding-top: 20px;
text-align: center;
@extend %menu-link;

View file

@ -1,10 +1,11 @@
from django.urls import path
from . import views
urlpatterns = [
path("", views.HomeView.as_view(), name="home"),
path("fiche/edit", views.EditView.as_view(), name="fiche_modif"),
path("fiche/reset", views.ResetView.as_view(), name="fiche_reset"),
path("fiche/<user>", views.FicheView.as_view(), name="fiche"),
path("fiche/_edit", views.EditView.as_view(), name="fiche_modif"),
path("fiche/_reset", views.ResetView.as_view(), name="fiche_reset"),
path("fiche/<slug:slug>", views.FicheView.as_view(), name="fiche"),
path("birthday", views.BirthdayView.as_view(), name="birthday"),
]

View file

@ -4,7 +4,6 @@ from django.contrib.auth.decorators import login_required
from django.core.mail import send_mail
from django.db.models import DateTimeField, Q, Value
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
from django.urls import reverse, reverse_lazy
from django.utils import timezone
@ -29,9 +28,7 @@ from fiches.utils import get_ldap_infos
class FicheView(DetailView):
model = Profile
template_name = "fiches/fiche.html"
def get_object(self):
return get_object_or_404(Profile, user__username=self.kwargs.get("user"))
slug_field = "user__username"
@method_decorator(login_required, name="dispatch")
@ -131,10 +128,21 @@ class HomeView(FormView):
form_class = SearchForm
def form_valid(self, form):
name = form.cleaned_data["name"]
promotion = form.cleaned_data["year"]
depts = form.cleaned_data["department"]
result = Profile.objects.filter(
Q(full_name__icontains=form.cleaned_data["name"])
| Q(nickname__icontains=form.cleaned_data["name"])
Q(full_name__icontains=name)
| Q(nickname__icontains=name)
| Q(user__username__icontains=name)
)
if depts:
result = result.filter(department__in=depts)
if promotion:
result = result.filter(promotion=promotion)
return self.render_to_response(self.get_context_data(result=result))