Merge branch 'Pagination' into 'master'

Pagination + améliorations de la recherche

See merge request klub-dev-ens/experiENS!3
This commit is contained in:
Robin Champenois 2018-12-26 20:35:07 +01:00
commit 4dc201e572
15 changed files with 606 additions and 417 deletions

View file

@ -94,7 +94,7 @@ def create_user_profile(sender, instance, created, **kwargs):
profil.save() profil.save()
except ldap.LDAPError: except ldap.LDAPError:
pass pass
post_save.connect(create_user_profile, sender=User) #post_save.connect(create_user_profile, sender=User)
# #
# Lieu de stage # Lieu de stage

View file

@ -0,0 +1,62 @@
header {
z-index: 40;
position: fixed;
top: 0px;
left: 0px;
width: 100%;
display: block;
max-height:100vh;
overflow-y: auto;
h1 {
padding: 10px;
}
#showmenu {
display: block;
float: right;
padding: 10px;
img {
width: 35px;
}
}
nav {
clear: both;
text-align: right;
ul {
display: none;
li {
display: block;
a {
display: block;
padding: 10px 20px;
height: auto;
text-align:right;
br {
display: none;
}
.username:after {
content: " | ";
}
}
}
}
}
}
header.expanded {
nav ul {
display:block;
}
}
h1 {
font-size: 2em;
}
h2 {
font-size: 1.6em;
}

View file

@ -1,93 +1,96 @@
section.content.recherche { body.recherche {
form.recherche {
.generale {
display: inline-block;
text-align: right;
position: relative;
left: 50%;
transform: translateX(-50%);
width: 500px;
max-width: 100%;
white-space: nowrap;
span { section.content {
display:flex; form.recherche {
} .generale {
display: inline-block;
input[type="text"] { text-align: right;
max-width: 500px; position: relative;
padding: 10px; left: 50%;
border: 1px solid $fond; transform: translateX(-50%);
margin:0 5px; width: 500px;
} max-width: 100%;
input { white-space: nowrap;
display: inline;
}
}
.avancee { span {
background: #fff; display:flex;
display: none; }
padding: 15px;
margin-bottom: 15px;
&.expanded {
display:block;
}
.help_text {
font-style: italic;
font-size: 0.9em;
}
ul {
margin: 0 -5px;
display: flexbox;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 100%;
li { input[type="text"] {
flex-grow: 1; max-width: 500px;
width: 22%; padding: 10px;
min-width: 150px; border: 1px solid $fond;
margin: 5px 0; margin:0 5px;
padding: 0 10px; }
input {
display: inline;
}
}
label { .avancee {
font-weight: bold; background: #fff;
font-size: 0.9em; display: none;
} padding: 15px;
margin-bottom: 15px;
&.expanded {
display:block;
}
.help_text {
font-style: italic;
font-size: 0.9em;
}
ul {
margin: 0 -5px;
display: flexbox;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 100%;
input[type="text"], input[type='number'], select { li {
display: block; flex-grow: 1;
width: 22%;
min-width: 150px; min-width: 150px;
display: inline-block; margin: 5px 0;
width: 100%; padding: 0 10px;
font-size: 0.9em;
background-color: #f8f8f8; label {
font-weight: bold;
font-size: 0.9em;
}
input[type="text"], input[type='number'], select {
display: block;
min-width: 150px;
display: inline-block;
width: 100%;
font-size: 0.9em;
background-color: #f8f8f8;
}
&.btnsubmit {
text-align:right;
}
&.field__sujet, &.field__contexte {
width:45%;
min-width: 300px;
}
} }
&.btnsubmit {
text-align:right;
}
&.field__sujet, &.field__contexte {
width:45%;
min-width: 300px;
}
} }
} }
} }
}
.recherche-carte, .recherche-liste { .recherche-carte, .recherche-liste {
position:relative; position:relative;
} }
.numresults { .numresults {
font-size: 0.9em; font-size: 0.9em;
font-weight: bold; font-weight: bold;
}
} }
&.vue-hybride #voir_hybride, &.vue-hybride #voir_hybride,
@ -124,14 +127,14 @@ section.content.recherche {
left: 60px; left: 60px;
} }
&.vue-hybride, &.vue-carte { &.vue-hybride section.content,
&.vue-carte section.content {
width: 100%; width: 100%;
min-width: unset; min-width: unset;
max-width: unset; max-width: unset;
min-height: unset; min-height: unset;
max-height: unset; max-height: unset;
height: 90vh; height: 100vh;
height: calc(100vh - 30px);
padding: 0; padding: 0;
margin: 0; margin: 0;
@ -145,7 +148,8 @@ section.content.recherche {
} }
&.vue-liste .recherche-carte, &.vue-liste .recherche-carte,
&.vue-carte .recherche-liste { &.vue-carte .recherche-liste,
&.vue-carte header {
display: none; display: none;
} }
@ -156,31 +160,41 @@ section.content.recherche {
} }
&.vue-hybride { &.vue-hybride {
display: flex;
@import "_miniheader.scss";
header {
position: fixed;
top: 0;
left: 0;
width: 500px;
z-index: 15;
}
section.content {
display: flex;
.recherche-liste { .recherche-liste {
width: 100%; padding-top: 60px;
min-width: 400px; width: 500px;
max-width: 500px;
flex: 1; .dates {
display:none;
.dates { }
display:none; ul.infos li {
} font-size: 0.8em;
ul.infos li { font-weight: normal;
font-size: 0.8em; &.year {
font-weight: normal; display: inline-block;
&.year { }
display: inline-block;
} }
} }
} .recherche-carte {
.recherche-carte { flex: 1.5;
flex: 1.5; width: 100%;
width: 100%;
.vue-options { .vue-options {
display:none; display:none;
}
} }
} }
} }

View file

@ -18,67 +18,7 @@
} }
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
header { @import "_miniheader.scss";
z-index: 40;
position: fixed;
top: 0px;
left: 0px;
width: 100%;
display: block;
max-height:100vh;
overflow-y: auto;
h1 {
padding: 10px;
}
#showmenu {
display: block;
float: right;
padding: 10px;
img {
width: 35px;
}
}
nav {
clear: both;
text-align: right;
ul {
display: none;
li {
display: block;
a {
display: block;
padding: 10px 20px;
height: auto;
text-align:right;
br {
display: none;
}
.username:after {
content: " | ";
}
}
}
}
}
}
header.expanded {
nav ul {
display:block;
}
}
h1 {
font-size: 2em;
}
h2 {
font-size: 1.6em;
}
#feedback-button { #feedback-button {
transform: unset; transform: unset;

View file

@ -1225,8 +1225,8 @@ table.stats td, table.stats th {
text-align: center; text-align: center;
} }
/* line 3, ../../sass/_recherche.scss */ /* line 5, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale { body.recherche section.content form.recherche .generale {
display: inline-block; display: inline-block;
text-align: right; text-align: right;
position: relative; position: relative;
@ -1236,39 +1236,39 @@ section.content.recherche form.recherche .generale {
max-width: 100%; max-width: 100%;
white-space: nowrap; white-space: nowrap;
} }
/* line 13, ../../sass/_recherche.scss */ /* line 15, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale span { body.recherche section.content form.recherche .generale span {
display: flex; display: flex;
} }
/* line 17, ../../sass/_recherche.scss */ /* line 19, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale input[type="text"] { body.recherche section.content form.recherche .generale input[type="text"] {
max-width: 500px; max-width: 500px;
padding: 10px; padding: 10px;
border: 1px solid #8fcc33; border: 1px solid #8fcc33;
margin: 0 5px; margin: 0 5px;
} }
/* line 23, ../../sass/_recherche.scss */ /* line 25, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale input { body.recherche section.content form.recherche .generale input {
display: inline; display: inline;
} }
/* line 28, ../../sass/_recherche.scss */ /* line 30, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee { body.recherche section.content form.recherche .avancee {
background: #fff; background: #fff;
display: none; display: none;
padding: 15px; padding: 15px;
margin-bottom: 15px; margin-bottom: 15px;
} }
/* line 34, ../../sass/_recherche.scss */ /* line 36, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee.expanded { body.recherche section.content form.recherche .avancee.expanded {
display: block; display: block;
} }
/* line 38, ../../sass/_recherche.scss */ /* line 40, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee .help_text { body.recherche section.content form.recherche .avancee .help_text {
font-style: italic; font-style: italic;
font-size: 0.9em; font-size: 0.9em;
} }
/* line 43, ../../sass/_recherche.scss */ /* line 45, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul { body.recherche section.content form.recherche .avancee ul {
margin: 0 -5px; margin: 0 -5px;
display: flexbox; display: flexbox;
display: flex; display: flex;
@ -1276,21 +1276,21 @@ section.content.recherche form.recherche .avancee ul {
justify-content: space-between; justify-content: space-between;
width: 100%; width: 100%;
} }
/* line 51, ../../sass/_recherche.scss */ /* line 53, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul li { body.recherche section.content form.recherche .avancee ul li {
flex-grow: 1; flex-grow: 1;
width: 22%; width: 22%;
min-width: 150px; min-width: 150px;
margin: 5px 0; margin: 5px 0;
padding: 0 10px; padding: 0 10px;
} }
/* line 58, ../../sass/_recherche.scss */ /* line 60, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul li label { body.recherche section.content form.recherche .avancee ul li label {
font-weight: bold; font-weight: bold;
font-size: 0.9em; font-size: 0.9em;
} }
/* line 63, ../../sass/_recherche.scss */ /* line 65, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul li input[type="text"], section.content.recherche form.recherche .avancee ul li input[type='number'], section.content.recherche form.recherche .avancee ul li select { body.recherche section.content form.recherche .avancee ul li input[type="text"], body.recherche section.content form.recherche .avancee ul li input[type='number'], body.recherche section.content form.recherche .avancee ul li select {
display: block; display: block;
min-width: 150px; min-width: 150px;
display: inline-block; display: inline-block;
@ -1298,152 +1298,222 @@ section.content.recherche form.recherche .avancee ul li input[type="text"], sect
font-size: 0.9em; font-size: 0.9em;
background-color: #f8f8f8; background-color: #f8f8f8;
} }
/* line 71, ../../sass/_recherche.scss */ /* line 73, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul li.btnsubmit { body.recherche section.content form.recherche .avancee ul li.btnsubmit {
text-align: right; text-align: right;
} }
/* line 74, ../../sass/_recherche.scss */ /* line 76, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul li.field__sujet, section.content.recherche form.recherche .avancee ul li.field__contexte { body.recherche section.content form.recherche .avancee ul li.field__sujet, body.recherche section.content form.recherche .avancee ul li.field__contexte {
width: 45%; width: 45%;
min-width: 300px; min-width: 300px;
} }
/* line 84, ../../sass/_recherche.scss */ /* line 86, ../../sass/_recherche.scss */
section.content.recherche .recherche-carte, section.content.recherche .recherche-liste { body.recherche section.content .recherche-carte, body.recherche section.content .recherche-liste {
position: relative; position: relative;
} }
/* line 88, ../../sass/_recherche.scss */ /* line 90, ../../sass/_recherche.scss */
section.content.recherche .numresults { body.recherche section.content .numresults {
font-size: 0.9em; font-size: 0.9em;
font-weight: bold; font-weight: bold;
} }
/* line 93, ../../sass/_recherche.scss */ /* line 96, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride #voir_hybride, section.content.recherche.vue-carte #voir_carte, section.content.recherche.vue-liste #voir_liste { body.recherche.vue-hybride #voir_hybride, body.recherche.vue-carte #voir_carte, body.recherche.vue-liste #voir_liste {
background: #d2ebad; background: #d2ebad;
color: #000; color: #000;
} }
/* line 100, ../../sass/_recherche.scss */ /* line 103, ../../sass/_recherche.scss */
section.content.recherche .vue-options { body.recherche .vue-options {
text-align: center; text-align: center;
} }
/* line 102, ../../sass/_recherche.scss */ /* line 105, ../../sass/_recherche.scss */
section.content.recherche .vue-options ul { body.recherche .vue-options ul {
display: inline-block; display: inline-block;
border-radius: 5px; border-radius: 5px;
overflow: hidden; overflow: hidden;
} }
/* line 107, ../../sass/_recherche.scss */ /* line 110, ../../sass/_recherche.scss */
section.content.recherche .vue-options ul li { body.recherche .vue-options ul li {
display: inline-block; display: inline-block;
background: #fff; background: #fff;
padding: 10px; padding: 10px;
} }
/* line 111, ../../sass/_recherche.scss */ /* line 114, ../../sass/_recherche.scss */
section.content.recherche .vue-options ul li a { body.recherche .vue-options ul li a {
display: block; display: block;
padding: 10px; padding: 10px;
margin: -10px; margin: -10px;
} }
/* line 120, ../../sass/_recherche.scss */ /* line 123, ../../sass/_recherche.scss */
section.content.recherche .recherche-carte .vue-options { body.recherche .recherche-carte .vue-options {
position: absolute; position: absolute;
z-index: 3; z-index: 3;
top: 15px; top: 15px;
left: 60px; left: 60px;
} }
/* line 127, ../../sass/_recherche.scss */ /* line 130, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride, section.content.recherche.vue-carte { body.recherche.vue-hybride section.content, body.recherche.vue-carte section.content {
width: 100%; width: 100%;
min-width: unset; min-width: unset;
max-width: unset; max-width: unset;
min-height: unset; min-height: unset;
max-height: unset; max-height: unset;
height: 90vh; height: 100vh;
height: calc(100vh - 30px);
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
/* line 138, ../../sass/_recherche.scss */ /* line 141, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-carte, section.content.recherche.vue-hybride .recherche-liste, section.content.recherche.vue-carte .recherche-carte, section.content.recherche.vue-carte .recherche-liste { body.recherche.vue-hybride section.content .recherche-carte, body.recherche.vue-hybride section.content .recherche-liste, body.recherche.vue-carte section.content .recherche-carte, body.recherche.vue-carte section.content .recherche-liste {
height: 100%; height: 100%;
} }
/* line 141, ../../sass/_recherche.scss */ /* line 144, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-liste, section.content.recherche.vue-carte .recherche-liste { body.recherche.vue-hybride section.content .recherche-liste, body.recherche.vue-carte section.content .recherche-liste {
overflow-y: auto; overflow-y: auto;
padding: 15px; padding: 15px;
} }
/* line 147, ../../sass/_recherche.scss */ /* line 150, ../../sass/_recherche.scss */
section.content.recherche.vue-liste .recherche-carte, section.content.recherche.vue-carte .recherche-liste { body.recherche.vue-liste .recherche-carte, body.recherche.vue-carte .recherche-liste, body.recherche.vue-carte header {
display: none; display: none;
} }
/* line 152, ../../sass/_recherche.scss */ /* line 156, ../../sass/_recherche.scss */
section.content.recherche.vue-carte .recherche-carte, section.content.recherche.vue-liste .recherche-liste { body.recherche.vue-carte .recherche-carte, body.recherche.vue-liste .recherche-liste {
display: block; display: block;
width: 100%; width: 100%;
} }
/* line 158, ../../sass/_recherche.scss */ /* line 2, ../../sass/_miniheader.scss */
section.content.recherche.vue-hybride { body.recherche.vue-hybride header {
display: flex; z-index: 40;
} position: fixed;
/* line 161, ../../sass/_recherche.scss */ top: 0px;
section.content.recherche.vue-hybride .recherche-liste { left: 0px;
width: 100%; width: 100%;
min-width: 400px; display: block;
max-width: 500px; max-height: 100vh;
flex: 1; overflow-y: auto;
} }
/* line 167, ../../sass/_recherche.scss */ /* line 12, ../../sass/_miniheader.scss */
section.content.recherche.vue-hybride .recherche-liste .dates { body.recherche.vue-hybride header h1 {
padding: 10px;
}
/* line 15, ../../sass/_miniheader.scss */
body.recherche.vue-hybride header #showmenu {
display: block;
float: right;
padding: 10px;
}
/* line 20, ../../sass/_miniheader.scss */
body.recherche.vue-hybride header #showmenu img {
width: 35px;
}
/* line 24, ../../sass/_miniheader.scss */
body.recherche.vue-hybride header nav {
clear: both;
text-align: right;
}
/* line 28, ../../sass/_miniheader.scss */
body.recherche.vue-hybride header nav ul {
display: none; display: none;
} }
/* line 170, ../../sass/_recherche.scss */ /* line 31, ../../sass/_miniheader.scss */
section.content.recherche.vue-hybride .recherche-liste ul.infos li { body.recherche.vue-hybride header nav ul li {
display: block;
}
/* line 33, ../../sass/_miniheader.scss */
body.recherche.vue-hybride header nav ul li a {
display: block;
padding: 10px 20px;
height: auto;
text-align: right;
}
/* line 39, ../../sass/_miniheader.scss */
body.recherche.vue-hybride header nav ul li a br {
display: none;
}
/* line 42, ../../sass/_miniheader.scss */
body.recherche.vue-hybride header nav ul li a .username:after {
content: " | ";
}
/* line 51, ../../sass/_miniheader.scss */
body.recherche.vue-hybride header.expanded nav ul {
display: block;
}
/* line 56, ../../sass/_miniheader.scss */
body.recherche.vue-hybride h1 {
font-size: 2em;
}
/* line 60, ../../sass/_miniheader.scss */
body.recherche.vue-hybride h2 {
font-size: 1.6em;
}
/* line 166, ../../sass/_recherche.scss */
body.recherche.vue-hybride header {
position: fixed;
top: 0;
left: 0;
width: 500px;
z-index: 15;
}
/* line 173, ../../sass/_recherche.scss */
body.recherche.vue-hybride section.content {
display: flex;
}
/* line 176, ../../sass/_recherche.scss */
body.recherche.vue-hybride section.content .recherche-liste {
padding-top: 60px;
width: 500px;
}
/* line 180, ../../sass/_recherche.scss */
body.recherche.vue-hybride section.content .recherche-liste .dates {
display: none;
}
/* line 183, ../../sass/_recherche.scss */
body.recherche.vue-hybride section.content .recherche-liste ul.infos li {
font-size: 0.8em; font-size: 0.8em;
font-weight: normal; font-weight: normal;
} }
/* line 173, ../../sass/_recherche.scss */ /* line 186, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-liste ul.infos li.year { body.recherche.vue-hybride section.content .recherche-liste ul.infos li.year {
display: inline-block; display: inline-block;
} }
/* line 178, ../../sass/_recherche.scss */ /* line 191, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-carte { body.recherche.vue-hybride section.content .recherche-carte {
flex: 1.5; flex: 1.5;
width: 100%; width: 100%;
} }
/* line 182, ../../sass/_recherche.scss */ /* line 195, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-carte .vue-options { body.recherche.vue-hybride section.content .recherche-carte .vue-options {
display: none; display: none;
} }
/* line 188, ../../sass/_recherche.scss */ /* line 202, ../../sass/_recherche.scss */
section.content.recherche #carte { body.recherche #carte {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
/* line 193, ../../sass/_recherche.scss */ /* line 207, ../../sass/_recherche.scss */
section.content.recherche .recherche-liste.recherche-details { body.recherche .recherche-liste.recherche-details {
display: none !important; display: none !important;
} }
/* line 196, ../../sass/_recherche.scss */ /* line 210, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride.vue-details .recherche-liste { body.recherche.vue-hybride.vue-details .recherche-liste {
display: none; display: none;
} }
/* line 199, ../../sass/_recherche.scss */ /* line 213, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-details { body.recherche.vue-hybride.vue-details .recherche-liste.recherche-details {
display: block !important; display: block !important;
} }
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
/* line 207, ../../sass/_recherche.scss */ /* line 221, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride, section.content.recherche.vue-carte { section.content.recherche.vue-hybride, section.content.recherche.vue-carte {
height: calc(100vh - 60px); height: calc(100vh - 60px);
margin-top: 60px; margin-top: 60px;
} }
/* line 214, ../../sass/_recherche.scss */ /* line 228, ../../sass/_recherche.scss */
section.content.recherche .recherche-liste ul li.stage:not(.expanded) ul.infos { section.content.recherche .recherche-liste ul li.stage:not(.expanded) ul.infos {
max-height: 115px; max-height: 115px;
overflow-y: hidden; overflow-y: hidden;
position: relative; position: relative;
} }
/* line 219, ../../sass/_recherche.scss */ /* line 233, ../../sass/_recherche.scss */
section.content.recherche .recherche-liste ul li.stage:not(.expanded) ul.infos:after { section.content.recherche .recherche-liste ul li.stage:not(.expanded) ul.infos:after {
position: absolute; position: absolute;
content: "⋅⋅⋅"; content: "⋅⋅⋅";
@ -1456,35 +1526,35 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
text-align: center; text-align: center;
border-top: 1px solid #ccc; border-top: 1px solid #ccc;
} }
/* line 233, ../../sass/_recherche.scss */ /* line 247, ../../sass/_recherche.scss */
section.content.recherche .recherche-liste ul li.stage:not(.expanded) a.hoverlink { section.content.recherche .recherche-liste ul li.stage:not(.expanded) a.hoverlink {
display: none; display: none;
} }
/* line 237, ../../sass/_recherche.scss */ /* line 251, ../../sass/_recherche.scss */
section.content.recherche .recherche-liste .dates .detail { section.content.recherche .recherche-liste .dates .detail {
display: none; display: none;
} }
/* line 243, ../../sass/_recherche.scss */ /* line 257, ../../sass/_recherche.scss */
ul.messages { ul.messages {
display: none; display: none;
} }
} }
@media screen and (max-width: 500px), screen and (max-width: 800px) and (orientation: portrait) { @media screen and (max-width: 500px), screen and (max-width: 800px) and (orientation: portrait) {
/* line 251, ../../sass/_recherche.scss */ /* line 265, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale span input { section.content.recherche form.recherche .generale span input {
font-size: 0.9em; font-size: 0.9em;
flex: 1; flex: 1;
} }
/* line 255, ../../sass/_recherche.scss */ /* line 269, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale span input[type=submit] { section.content.recherche form.recherche .generale span input[type=submit] {
white-space: normal; white-space: normal;
} }
/* line 259, ../../sass/_recherche.scss */ /* line 273, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride, section.content.recherche.vue-carte { section.content.recherche.vue-hybride, section.content.recherche.vue-carte {
flex-direction: column; flex-direction: column;
} }
/* line 260, ../../sass/_recherche.scss */ /* line 274, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-liste, section.content.recherche.vue-carte .recherche-liste { section.content.recherche.vue-hybride .recherche-liste, section.content.recherche.vue-carte .recherche-liste {
max-width: 100vw; max-width: 100vw;
min-width: unset; min-width: unset;
@ -1512,76 +1582,7 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
} }
} }
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
/* line 21, ../../sass/_responsive.scss */ /* line 23, ../../sass/_responsive.scss */
header {
z-index: 40;
position: fixed;
top: 0px;
left: 0px;
width: 100%;
display: block;
max-height: 100vh;
overflow-y: auto;
}
/* line 31, ../../sass/_responsive.scss */
header h1 {
padding: 10px;
}
/* line 34, ../../sass/_responsive.scss */
header #showmenu {
display: block;
float: right;
padding: 10px;
}
/* line 39, ../../sass/_responsive.scss */
header #showmenu img {
width: 35px;
}
/* line 43, ../../sass/_responsive.scss */
header nav {
clear: both;
text-align: right;
}
/* line 47, ../../sass/_responsive.scss */
header nav ul {
display: none;
}
/* line 50, ../../sass/_responsive.scss */
header nav ul li {
display: block;
}
/* line 52, ../../sass/_responsive.scss */
header nav ul li a {
display: block;
padding: 10px 20px;
height: auto;
text-align: right;
}
/* line 58, ../../sass/_responsive.scss */
header nav ul li a br {
display: none;
}
/* line 61, ../../sass/_responsive.scss */
header nav ul li a .username:after {
content: " | ";
}
/* line 70, ../../sass/_responsive.scss */
header.expanded nav ul {
display: block;
}
/* line 75, ../../sass/_responsive.scss */
h1 {
font-size: 2em;
}
/* line 79, ../../sass/_responsive.scss */
h2 {
font-size: 1.6em;
}
/* line 83, ../../sass/_responsive.scss */
#feedback-button { #feedback-button {
transform: unset; transform: unset;
top: 0px; top: 0px;
@ -1592,79 +1593,79 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
} }
/* line 92, ../../sass/_responsive.scss */ /* line 32, ../../sass/_responsive.scss */
.content { .content {
margin-top: 70px; margin-top: 70px;
padding: 15px 3vw; padding: 15px 3vw;
} }
/* line 97, ../../sass/_responsive.scss */ /* line 37, ../../sass/_responsive.scss */
article.stage h3 { article.stage h3 {
margin-top: 10px; margin-top: 10px;
} }
/* line 101, ../../sass/_responsive.scss */ /* line 41, ../../sass/_responsive.scss */
article.stage section .avis-texte, article.stage section .chapo { article.stage section .avis-texte, article.stage section .chapo {
padding: 3px 10px; padding: 3px 10px;
} }
/* line 107, ../../sass/_responsive.scss */ /* line 47, ../../sass/_responsive.scss */
article.stage section #stage-map { article.stage section #stage-map {
height: 200px; height: 200px;
width: 100%; width: 100%;
} }
/* line 113, ../../sass/_responsive.scss */ /* line 53, ../../sass/_responsive.scss */
article.stage section.misc .misc-content.withmap { article.stage section.misc .misc-content.withmap {
display: block; display: block;
} }
/* line 116, ../../sass/_responsive.scss */ /* line 56, ../../sass/_responsive.scss */
article.stage section.misc .misc-content.withmap > div { article.stage section.misc .misc-content.withmap > div {
display: block; display: block;
vertical-align: top; vertical-align: top;
} }
/* line 120, ../../sass/_responsive.scss */ /* line 60, ../../sass/_responsive.scss */
article.stage section.misc .misc-content.withmap .map { article.stage section.misc .misc-content.withmap .map {
width: 80%; width: 80%;
min-width: 250px; min-width: 250px;
min-height: 200px; min-height: 200px;
margin: 0 auto; margin: 0 auto;
} }
/* line 126, ../../sass/_responsive.scss */ /* line 66, ../../sass/_responsive.scss */
article.stage section.misc .misc-content.withmap .desc { article.stage section.misc .misc-content.withmap .desc {
padding: 5px; padding: 5px;
} }
/* line 134, ../../sass/_responsive.scss */ /* line 74, ../../sass/_responsive.scss */
article.stage section .plusmoins > div { article.stage section .plusmoins > div {
display: block; display: block;
} }
/* line 137, ../../sass/_responsive.scss */ /* line 77, ../../sass/_responsive.scss */
article.stage section .plusmoins > div > *, article.stage section .plusmoins > div:before { article.stage section .plusmoins > div > *, article.stage section .plusmoins > div:before {
display: block; display: block;
} }
/* line 141, ../../sass/_responsive.scss */ /* line 81, ../../sass/_responsive.scss */
article.stage section .plusmoins > div:before { article.stage section .plusmoins > div:before {
text-align: left; text-align: left;
width: 100%; width: 100%;
font-size: 1.5em; font-size: 1.5em;
} }
/* line 146, ../../sass/_responsive.scss */ /* line 86, ../../sass/_responsive.scss */
article.stage section .plusmoins > div.moins:before { article.stage section .plusmoins > div.moins:before {
text-align: right; text-align: right;
margin-top: 5px; margin-top: 5px;
} }
/* line 155, ../../sass/_responsive.scss */ /* line 95, ../../sass/_responsive.scss */
article.stage .section-wrapper { article.stage .section-wrapper {
display: block; display: block;
margin-left: 0; margin-left: 0;
} }
/* line 159, ../../sass/_responsive.scss */ /* line 99, ../../sass/_responsive.scss */
article.stage .section-wrapper .toc-wrapper, article.stage .section-wrapper > section { article.stage .section-wrapper .toc-wrapper, article.stage .section-wrapper > section {
display: block; display: block;
} }
/* line 162, ../../sass/_responsive.scss */ /* line 102, ../../sass/_responsive.scss */
article.stage .section-wrapper .toc-wrapper { article.stage .section-wrapper .toc-wrapper {
max-width: unset; max-width: unset;
width: unset; width: unset;
} }
/* line 166, ../../sass/_responsive.scss */ /* line 106, ../../sass/_responsive.scss */
article.stage .section-wrapper .toc { article.stage .section-wrapper .toc {
display: none; display: none;
position: relative; position: relative;
@ -1673,65 +1674,65 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
padding: 4px; padding: 4px;
} }
/* line 176, ../../sass/_responsive.scss */ /* line 116, ../../sass/_responsive.scss */
.homeh1 { .homeh1 {
display: block; display: block;
} }
/* line 178, ../../sass/_responsive.scss */ /* line 118, ../../sass/_responsive.scss */
.homeh1 > * { .homeh1 > * {
display: block; display: block;
} }
/* line 183, ../../sass/_responsive.scss */ /* line 123, ../../sass/_responsive.scss */
article.promo .explications { article.promo .explications {
display: block; display: block;
} }
/* line 185, ../../sass/_responsive.scss */ /* line 125, ../../sass/_responsive.scss */
article.promo .explications div { article.promo .explications div {
max-width: 100%; max-width: 100%;
display: block; display: block;
} }
/* line 192, ../../sass/_responsive.scss */ /* line 132, ../../sass/_responsive.scss */
.condensed-stages { .condensed-stages {
display: block; display: block;
} }
/* line 195, ../../sass/_responsive.scss */ /* line 135, ../../sass/_responsive.scss */
.condensed-stages li:before, .condensed-stages li, .condensed-stages a { .condensed-stages li:before, .condensed-stages li, .condensed-stages a {
display: block; display: block;
width: auto; width: auto;
max-width: auto; max-width: auto;
} }
/* line 201, ../../sass/_responsive.scss */ /* line 141, ../../sass/_responsive.scss */
.condensed-stages li:before { .condensed-stages li:before {
padding: 3px 15px; padding: 3px 15px;
} }
/* line 205, ../../sass/_responsive.scss */ /* line 145, ../../sass/_responsive.scss */
.condensed-stages li.stage-ajout:before { .condensed-stages li.stage-ajout:before {
display: none; display: none;
} }
/* line 210, ../../sass/_responsive.scss */ /* line 150, ../../sass/_responsive.scss */
ul.infos { ul.infos {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
} }
/* line 219, ../../sass/_responsive.scss */ /* line 159, ../../sass/_responsive.scss */
.stage-liste li .misc-hdr .dates .detail { .stage-liste li .misc-hdr .dates .detail {
display: inline; display: inline;
} }
/* line 222, ../../sass/_responsive.scss */ /* line 162, ../../sass/_responsive.scss */
.stage-liste li .misc-hdr .dates .year { .stage-liste li .misc-hdr .dates .year {
padding: 0; padding: 0;
} }
/* line 230, ../../sass/_responsive.scss */ /* line 170, ../../sass/_responsive.scss */
form .field { form .field {
display: block; display: block;
} }
/* line 233, ../../sass/_responsive.scss */ /* line 173, ../../sass/_responsive.scss */
form .field label, form .field .label { form .field label, form .field .label {
display: block; display: block;
text-align: left; text-align: left;
@ -1740,18 +1741,18 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
margin-top: 0; margin-top: 0;
width: auto; width: auto;
} }
/* line 242, ../../sass/_responsive.scss */ /* line 182, ../../sass/_responsive.scss */
form .field .help_text { form .field .help_text {
text-align: right; text-align: right;
color: #395214; color: #395214;
} }
/* line 247, ../../sass/_responsive.scss */ /* line 187, ../../sass/_responsive.scss */
form .field .input { form .field .input {
padding-left: 20px; padding-left: 20px;
display: block; display: block;
text-align: right; text-align: right;
} }
/* line 253, ../../sass/_responsive.scss */ /* line 193, ../../sass/_responsive.scss */
form .field input, form .field textarea, form .field div.tinymce, form .field select { form .field input, form .field textarea, form .field div.tinymce, form .field select {
background: #f4faeb; background: #f4faeb;
} }

View file

@ -1,7 +1,8 @@
function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) { function InterfaceRecherche(STATIC_ROOT, API_LIEU, ITEMS_URL, lieux) {
var interface_mode, main_container; var interface_mode, main_container;
var lieux_map = {}, lieux_list = [], stages_map = {}, lieux_db = {}; var lieux_map = {}, lieux_list = [], stages_map = {}, lieux_db = {};
var stages_data = {}; var stages_db = {};
var details_liste_data;
var marqueurs = L.markerClusterGroup(); var marqueurs = L.markerClusterGroup();
var marqueurs_db = {}; var marqueurs_db = {};
var changevue; var changevue;
@ -13,8 +14,10 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
// TODO se souvenir des préférences d'affichage // TODO se souvenir des préférences d'affichage
function initInterface() { function initInterface() {
main_container = $(".content.recherche"); main_container = $("body");
if (main_container.hasClass("vue-liste")) { if (sessionStorage && sessionStorage.interface_mode) {
interface_mode = sessionStorage.interface_mode;
} else if (main_container.hasClass("vue-liste")) {
interface_mode = "liste"; interface_mode = "liste";
} else if (main_container.hasClass("vue-carte")) { } else if (main_container.hasClass("vue-carte")) {
interface_mode = "carte"; interface_mode = "carte";
@ -43,6 +46,17 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
}); });
changeInterface(interface_mode); changeInterface(interface_mode);
initLoadMoreAJAX();
referenceStageItems($("#resultats").children());
}
function referenceStageItems (stages, hard) {
$.each(stages, function(i, item) {
if (item.id === undefined) return;
var iid = Number(item.id.split("-")[2]);
if (stages_db[iid] !== undefined && !hard) return;
stages_db[iid] = $(item);
});
} }
// Changement d'affichage : mise à jour des classes et démarrage de la carte si nécessaire // Changement d'affichage : mise à jour des classes et démarrage de la carte si nécessaire
@ -53,8 +67,11 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
function changeInterface(mode) { function changeInterface(mode) {
interface_mode = mode; interface_mode = mode;
$(".content.recherche").removeClass("vue-carte vue-hybride vue-liste") main_container.removeClass("vue-carte vue-hybride vue-liste")
.addClass("vue-"+mode); .addClass("vue-"+mode);
if (sessionStorage) {
sessionStorage.interface_mode = mode;
}
if (mode=="hybride" || mode=="carte") { if (mode=="hybride" || mode=="carte") {
initCarte(); initCarte();
map.invalidateSize(); map.invalidateSize();
@ -84,7 +101,7 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
var greenIcon = makeIcon('red'); var greenIcon = makeIcon('red');
var blueIcon = makeIcon('blue', 1.2); var blueIcon = makeIcon('blue', 1.2);
// Chargeùent des infos // Chargement des infos
function onLoadLieux(data){ function onLoadLieux(data){
console.log(data); console.log(data);
var lieux = data.objects; var lieux = data.objects;
@ -133,7 +150,7 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
var html = $("<div>").html(marqueur._popup_header); var html = $("<div>").html(marqueur._popup_header);
var stageliste = $("<ul>"); var stageliste = $("<ul>");
$.each(lieux_map[data.id], function(i, item) { $.each(lieux_map[data.id], function(i, item) {
var stage_el = $("#resultat-stage-"+item); var stage_el = stages_db[item];
var url = stage_el.find('a.stage-sujet').attr('href'); var url = stage_el.find('a.stage-sujet').attr('href');
var sujet = stage_el.find('a.stage-sujet').text(); var sujet = stage_el.find('a.stage-sujet').text();
var auteur = stage_el.find('.auteur').text(); var auteur = stage_el.find('.auteur').text();
@ -146,19 +163,42 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
marqueur.setPopupContent(html[0]); marqueur.setPopupContent(html[0]);
} }
// Affichage de la liste hybride au survol + chargement asynchrone
function showDetailsListeListener (evt) { function showDetailsListeListener (evt) {
showDetailsListe(this._lieu_data); showDetailsListe(this._lieu_data);
} }
function showDetailsListe (data) { function showDetailsListe (data, is_callback) {
main_container.addClass("vue-details"); main_container.addClass("vue-details");
var to_load = [];
var liste_el = $("#resultats-details"); var liste_el = $("#resultats-details");
$.each(liste_el.children(), function(i, item){$(item).remove();}); $.each(liste_el.children(), function(i, item){$(item).remove();});
$.each(lieux_map[data.id], function(i, item) { $.each(lieux_map[data.id], function(i, item) {
var stage_el = $("#resultat-stage-"+item); var stage_el = stages_db[item];
if (stage_el === undefined) {
to_load.push(item);
return;
}
var new_el = $("<li>", {class:"stage"}).html(stage_el.html()); var new_el = $("<li>", {class:"stage"}).html(stage_el.html());
liste_el.append(new_el); liste_el.append(new_el);
}); });
if (to_load.length > 0 && !is_callback) { // On évite la boucle si erreur
loadDetailsListe(to_load, data);
liste_el.append($("<li>", {class:"stage"}).html("Chargement..."));
}
}
function loadDetailsListe (liste, data) {
details_liste_data = data;
$.get(ITEMS_URL, {ids: liste.join(";")},
function (html) {
var temp_el = $("<ul>").html(html);
referenceStageItems(temp_el.children());
if (details_liste_data == data) {
showDetailsListe(data, true);
}
});
} }
function unlockDetailsListe () { function unlockDetailsListe () {
@ -167,6 +207,7 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
} }
function hideDetailsListeListener () { function hideDetailsListeListener () {
details_liste_data = undefined;
if (details_lock === false) if (details_lock === false)
main_container.removeClass("vue-details"); main_container.removeClass("vue-details");
else else
@ -195,6 +236,33 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
$("li.stage.expanded").removeClass("expanded"); $("li.stage.expanded").removeClass("expanded");
} }
//
// Pagination et chargement automatique
//
function initLoadMoreAJAX () {
var btn = $("#next-page-btn");
btn.on("click", loadMoreAJAX);
}
function loadMoreAJAX () {
var btn = this;
var url = btn.href;
if (btn.__is_loading) return false;
btn.innerHTML = "Chargement...";
$.get(url+"&format=raw", {}, function(html) {
$(btn).remove();
var new_els = $("<ul>").html(html).children();
$("#resultats").append(new_els);
referenceStageItems(new_els);
new_els.filter(".stage")
.on("mouseover touchdown", showLieuxFromStage)
.on("mouseout", hideLieuxSurvol);
initLoadMoreAJAX();
});
return false;
}
// __init__ // __init__
initInterface(); initInterface();

View file

@ -18,7 +18,7 @@
{% block extra_head %}{% endblock %} {% block extra_head %}{% endblock %}
</head> </head>
<body> <body class="{% block bodyclass %}{% endblock %}">
<header> <header>
<h1><a href="{% url 'avisstage:index' %}">ExperiENS{# <span class='beta'>beta</span>#}</a></h1> <h1><a href="{% url 'avisstage:index' %}">ExperiENS{# <span class='beta'>beta</span>#}</a></h1>

View file

@ -36,8 +36,8 @@
</div> </div>
</div> </div>
<div class="betacadre"> <div class="footer">
Ce site est en développement actif, et fait l'objet de mises à jours régulières. N'hésitez pas à donner votre avis en utilisant le bouton "feedback". Un projet du <a href="https://www.eleves.ens.fr/home/klub-dev/">Klub Dev ENS</a>
</div> </div>
</article> </article>
{% endblock %} {% endblock %}

View file

@ -3,7 +3,7 @@
{% block title %}Chercher un stage - ExperiENS{% endblock %} {% block title %}Chercher un stage - ExperiENS{% endblock %}
{% block extra_content_class %}recherche{% endblock %} {% block bodyclass %}recherche{% endblock %}
{% block content %} {% block content %}
<h1>Chercher un stage</h1> <h1>Chercher un stage</h1>

View file

@ -6,14 +6,14 @@
{% block extra_head %} {% block extra_head %}
<script type="text/javascript" src="{% static 'js/leaflet.js' %}"></script> <script type="text/javascript" src="{% static 'js/leaflet.js' %}"></script>
<script type="text/javascript" src="{% static 'js/leaflet.markercluster.js' %}"></script> <script type="text/javascript" src="{% static 'js/leaflet.markercluster.js' %}"></script>
<script type="text/javascript" src="{% static 'js/recherche.js' %}"></script> <script type="text/javascript" src="{% static 'js/recherche.js' %}?v2"></script>
<link rel="stylesheet" type="text/css" href="{% static 'css/leaflet.css' %}" /> <link rel="stylesheet" type="text/css" href="{% static 'css/leaflet.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/MarkerCluster.css' %}" /> <link rel="stylesheet" type="text/css" href="{% static 'css/MarkerCluster.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/MarkerCluster.Default.css' %}" /> <link rel="stylesheet" type="text/css" href="{% static 'css/MarkerCluster.Default.css' %}" />
<script type="text/javascript" src="{% static "js/render.js" %}"></script> <script type="text/javascript" src="{% static "js/render.js" %}"></script>
{% endblock %} {% endblock %}
{% block extra_content_class %}recherche {{ vue }}{% endblock %} {% block bodyclass %}recherche {{ vue }}{% endblock %}
{% block content %} {% block content %}
<section class="recherche-liste" id="recherche-liste"> <section class="recherche-liste" id="recherche-liste">
@ -30,42 +30,11 @@
<li><a href="javascript:void(0);" id="voir_carte">Carte</a></li> <li><a href="javascript:void(0);" id="voir_carte">Carte</a></li>
</ul> </ul>
</div> </div>
<p class="numresults">{{ stages|length }} expérience{{ stages|length|pluralize }} trouvée{{ stages|length|pluralize }}</p> <p class="numresults">{{ paginator.paginator.count }} expérience{{ paginator.paginator.count|pluralize }} trouvée{{ paginator.paginator.count|pluralize }}</p>
{% endif %} {% endif %}
<ul class="stage-liste" id="resultats"> <ul class="stage-liste" id="resultats">
{% for stage in stages %} {% include "avisstage/recherche/stage_items.html" %}
{% if tri == '-date_maj' %}
{% ifchanged stage.date_maj.date %}<li class="date-maj">Mis à jour le {{ stage.date_maj.date }}</li>{% endifchanged %}
{% endif %}
<li class="stage" id="resultat-stage-{{ stage.id }}">
<div class="misc-hdr">
<h3><a href="{% url "avisstage:stage" stage.id %}" class="stage-sujet">{{ stage.sujet }}</a><span class="auteur"> par <span class="stage-auteur">{{ stage.auteur.nom }}</span></span></h3>
<p class="dates" c-radius="30"><span class="detail"><span class="debut">{{ stage.date_debut|date:"d/m" }}</span><span class="fin">{{ stage.date_fin|date:"d/m" }}</span></span><span class="year">{{ stage.date_debut|date:"Y" }}</span></p>
</div>
<div>
<ul class="infos">
<li class="type">{{ stage.get_type_stage_display }}</li>
{% if stage.structure %}<li class="structure">{{ stage.structure }}</li>{% endif %}
{% for lieu in stage.lieux.all %}<li class="lieu">{{ lieu.nom }}</li>{% endfor %}
{% for matiere in stage.matieres.all %}
<li class="matiere">{{ matiere.nom }}</li>
{% endfor %}
{% for thematique in stage.thematiques.all %}
<li class="thematique">{{ thematique.name }}</li>
{% endfor %}
<li class="year">{{ stage.date_debut|date:"Y" }}</li>
<li class="avis-len avis-{{ stage.len_avis_stage|avis_len }}">Avis stage {{ stage.len_avis_stage|avis_len }}</li>
<li class="avis-len avis-{{ stage.len_avis_lieux|avis_len }}">Avis lieux {{ stage.len_avis_lieux|avis_len }}</li>
</ul>
</div>
<a href="{% url "avisstage:stage" stage.id %}" class="hoverlink">&nbsp;</a>
</li>
{% empty %}
<li class="stage">Aucun stage ne correspond à votre recherche et vos critères</li>
{% endfor %}
</ul> </ul>
</article> </article>
@ -82,12 +51,16 @@
<div id="carte"></div> <div id="carte"></div>
<div id="vue-options2" class="vue-options"> <div id="vue-options2" class="vue-options">
<ul> <ul>
<li><a href="javascript:void(0);" id="voir_hybride">Afficher la liste</a></li> <li><a href="javascript:void(0);" id="voir_hybride">Afficher la liste et les menus</a></li>
</ul> </ul>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var lieux = [{{ lieux|join:',' }}]; var lieux = [{{ lieux|join:',' }}];
var interfaceRecherche = new InterfaceRecherche("{{ STATIC_URL|escapejs }}", "{% url 'avisstage:api_dispatch_list' resource_name="lieu" api_name="v1" %}", lieux); var interfaceRecherche = new InterfaceRecherche(
"{{ STATIC_URL|escapejs }}",
"{% url 'avisstage:api_dispatch_list' resource_name="lieu" api_name="v1" %}",
"{% url 'avisstage:stage_items' %}",
lieux);
</script> </script>
</section> </section>
{% endif %} {% endif %}

View file

@ -0,0 +1,38 @@
{% load avisstage_tags %}
{% for stage in stages %}
{% if tri == '-date_maj' %}
{% ifchanged stage.date_maj.date %}<li class="date-maj">Mis à jour le {{ stage.date_maj.date }}</li>{% endifchanged %}
{% endif %}
<li class="stage" id="resultat-stage-{{ stage.id }}">
<div class="misc-hdr">
<h3><a href="{% url "avisstage:stage" stage.id %}" class="stage-sujet">{{ stage.sujet }}</a><span class="auteur"> par <span class="stage-auteur">{{ stage.auteur.nom }}</span></span></h3>
<p class="dates" c-radius="30"><span class="detail"><span class="debut">{{ stage.date_debut|date:"d/m" }}</span><span class="fin">{{ stage.date_fin|date:"d/m" }}</span></span><span class="year">{{ stage.date_debut|date:"Y" }}</span></p>
</div>
<div>
<ul class="infos">
<li class="type">{{ stage.get_type_stage_display }}</li>
{% if stage.structure %}<li class="structure">{{ stage.structure }}</li>{% endif %}
{% for lieu in stage.lieux.all %}<li class="lieu">{{ lieu.nom }}</li>{% endfor %}
{% for matiere in stage.matieres.all %}
<li class="matiere">{{ matiere.nom }}</li>
{% endfor %}
{% for thematique in stage.thematiques.all %}
<li class="thematique">{{ thematique.name }}</li>
{% endfor %}
<li class="year">{{ stage.date_debut|date:"Y" }}</li>
<li class="avis-len avis-{{ stage.len_avis_stage|avis_len }}">Avis stage {{ stage.len_avis_stage|avis_len }}</li>
<li class="avis-len avis-{{ stage.len_avis_lieux|avis_len }}">Avis lieux {{ stage.len_avis_lieux|avis_len }}</li>
</ul>
</div>
<a href="{% url "avisstage:stage" stage.id %}" class="hoverlink">&nbsp;</a>
</li>
{% empty %}
<li class="stage">Aucun stage ne correspond à votre recherche et vos critères</li>
{% endfor %}
{% if paginator %}
<li class="pagination">
{% if paginator.has_next %}
<a href="?{% url_replace request 'page' paginator.next_page_number %}" id="next-page-btn" class="btn">Plus de résultats</a>
{% endif %}
</li>
{% endif %}

View file

@ -33,3 +33,9 @@ def avis_len(value):
return "court" return "court"
else: else:
return "long" return "long"
@register.simple_tag
def url_replace(request, field, value):
dict_ = request.GET.copy()
dict_[field] = value
return dict_.urlencode()

View file

@ -23,6 +23,7 @@ urlpatterns = [
url(r'^profil/edit/$', views.ProfilEdit.as_view(), name='profil_edit'), url(r'^profil/edit/$', views.ProfilEdit.as_view(), name='profil_edit'),
url(r'^recherche/$', views.recherche, name='recherche'), url(r'^recherche/$', views.recherche, name='recherche'),
url(r'^recherche/resultats/$', views.recherche_resultats, name='recherche_resultats'), url(r'^recherche/resultats/$', views.recherche_resultats, name='recherche_resultats'),
url(r'^recherche/items/$', views.stage_items, name='stage_items'),
url(r'^feedback/$', views.feedback, name='feedback'), url(r'^feedback/$', views.feedback, name='feedback'),
url(r'^moderation/$', views.statistiques, name='moderation'), url(r'^moderation/$', views.statistiques, name='moderation'),
url(r'^api/', include(v1_api.urls)), url(r'^api/', include(v1_api.urls)),

View file

@ -1,16 +1,24 @@
# coding: utf-8 # coding: utf-8
from django.shortcuts import render, redirect, get_object_or_404 from datetime import date
from django.contrib.auth.decorators import login_required
from django import forms from django import forms
from django.contrib.auth.decorators import login_required
from django.core.cache import cache
from django.core.paginator import Paginator
from django.db.models import Q from django.db.models import Q
from django.http import JsonResponse, HttpResponseBadRequest
from django.shortcuts import render, redirect, get_object_or_404
import json
import logging
from .documents import StageDocument from .documents import StageDocument
from .models import Stage from .models import Stage
from .statics import TYPE_LIEU_OPTIONS, TYPE_STAGE_OPTIONS, NIVEAU_SCOL_OPTIONS from .statics import TYPE_LIEU_OPTIONS, TYPE_STAGE_OPTIONS, NIVEAU_SCOL_OPTIONS
from datetime import date
logger = logging.getLogger("recherche")
# Recherche # Recherche
class SearchForm(forms.Form): class SearchForm(forms.Form):
@ -137,13 +145,70 @@ def recherche_resultats(request):
if request.method == "GET": if request.method == "GET":
form = SearchForm(request.GET) form = SearchForm(request.GET)
if form.is_valid(): if form.is_valid():
stages, tri = cherche(**form.cleaned_data) page = request.GET.get("page", 1)
stages = stages.prefetch_related('lieux', 'auteur', 'matieres', 'thematiques') search_args = form.cleaned_data
lieux = [[stageid, lieuid] for (stageid, lieuid) in stages.values_list('id', 'lieux') if lieuid is not None]
# Gestion du cache
lsearch_args = {key: val for key, val in search_args.items()
if val != "" and val is not None}
cache_key = json.dumps(lsearch_args, sort_keys=True)
cached = cache.get(cache_key)
if cached is None:
# Requête effective
stages, tri = cherche(**search_args)
stageids = stages.values_list('id', flat=True)
lieux = [[stageid, lieuid] for (stageid, lieuid) in stages.values_list('id', 'lieux') if lieuid is not None]
# Sauvegarde dans le cache
to_cache = {"stages": stageids, "lieux": lieux, "tri": tri}
cache.set(cache_key, to_cache, 600)
logger.info(cache_key)
else:
# Lecture du cache
stageids = cached["stages"]
lieux = cached["lieux"]
tri = cached["tri"]
logger.info("recherche en cache")
# Pagination
paginator = Paginator(stageids, 25)
try:
stageids = paginator.page(page)
except InvalidPage:
stageids = []
if cached is None:
stages = stages[stageids.start_index()-1:stageids.end_index()]
else:
stages = Stage.objects.filter(id__in=stageids)
stages = stages.prefetch_related('lieux', 'auteur',
'matieres', 'thematiques')
else: else:
form = SearchForm() form = SearchForm()
if stages: if stages:
vue = 'vue-hybride' vue = 'vue-hybride'
return render(request, 'avisstage/recherche/resultats.html',
{"form": form, "stages":stages, # Version JSON pour recherche dynamique
if request.GET.get("format") == "json":
return JsonResponse({"stages": stages, "page": page,
"num_pages": paginator.num_pages})
template_name = 'avisstage/recherche/resultats.html'
if request.GET.get("format") == "raw":
template_name = 'avisstage/recherche/stage_items.html'
return render(request, template_name,
{"form": form, "stages": stages, "paginator": stageids,
"tri": tri, "vue": vue, "lieux": lieux}) "tri": tri, "vue": vue, "lieux": lieux})
@login_required
def stage_items(request):
try:
stageids = [int(a) for a in request.GET.get("ids", "").split(';')]
except ValueError:
return HttpResponseBadRequest("Paramètre incorrect")
stages = Stage.objects.filter(id__in=stageids)\
.prefetch_related('lieux', 'auteur',
'matieres', 'thematiques')
return render(request, 'avisstage/recherche/stage_items.html',
{"stages": stages})

View file

@ -66,6 +66,7 @@ TEMPLATES = [
'django.template.context_processors.media', 'django.template.context_processors.media',
'django.template.context_processors.static', 'django.template.context_processors.static',
'django.template.context_processors.tz', 'django.template.context_processors.tz',
'django.template.context_processors.request',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
], ],
}, },
@ -114,3 +115,23 @@ CAS_VERSION = 'CAS_2_SAML_1_0'
LOGIN_URL = reverse_lazy('login') LOGIN_URL = reverse_lazy('login')
LOGOUT_URL = reverse_lazy('logout') LOGOUT_URL = reverse_lazy('logout')
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': os.path.join(BASE_DIR, 'recherche.log'),
},
},
'loggers': {
'recherche': {
'handlers': ['file'],
'level': 'INFO',
'propagate': True,
},
},
}