Pagination et mise en cache des résultats

This commit is contained in:
Evarin 2018-12-26 19:06:18 +01:00
parent 4c97c8e420
commit f9f62bd1b6
12 changed files with 569 additions and 413 deletions

View file

@ -94,7 +94,7 @@ def create_user_profile(sender, instance, created, **kwargs):
profil.save()
except ldap.LDAPError:
pass
post_save.connect(create_user_profile, sender=User)
#post_save.connect(create_user_profile, sender=User)
#
# 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 {
form.recherche {
.generale {
display: inline-block;
text-align: right;
position: relative;
left: 50%;
transform: translateX(-50%);
width: 500px;
max-width: 100%;
white-space: nowrap;
body.recherche {
span {
display:flex;
}
input[type="text"] {
max-width: 500px;
padding: 10px;
border: 1px solid $fond;
margin:0 5px;
}
input {
display: inline;
}
}
section.content {
form.recherche {
.generale {
display: inline-block;
text-align: right;
position: relative;
left: 50%;
transform: translateX(-50%);
width: 500px;
max-width: 100%;
white-space: nowrap;
.avancee {
background: #fff;
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%;
span {
display:flex;
}
li {
flex-grow: 1;
width: 22%;
min-width: 150px;
margin: 5px 0;
padding: 0 10px;
input[type="text"] {
max-width: 500px;
padding: 10px;
border: 1px solid $fond;
margin:0 5px;
}
input {
display: inline;
}
}
label {
font-weight: bold;
font-size: 0.9em;
}
.avancee {
background: #fff;
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 {
display: block;
li {
flex-grow: 1;
width: 22%;
min-width: 150px;
display: inline-block;
width: 100%;
font-size: 0.9em;
background-color: #f8f8f8;
margin: 5px 0;
padding: 0 10px;
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 {
position:relative;
}
.recherche-carte, .recherche-liste {
position:relative;
}
.numresults {
font-size: 0.9em;
font-weight: bold;
.numresults {
font-size: 0.9em;
font-weight: bold;
}
}
&.vue-hybride #voir_hybride,
@ -124,14 +127,14 @@ section.content.recherche {
left: 60px;
}
&.vue-hybride, &.vue-carte {
&.vue-hybride section.content,
&.vue-carte section.content {
width: 100%;
min-width: unset;
max-width: unset;
min-height: unset;
max-height: unset;
height: 90vh;
height: calc(100vh - 30px);
height: 100vh;
padding: 0;
margin: 0;
@ -145,7 +148,8 @@ section.content.recherche {
}
&.vue-liste .recherche-carte,
&.vue-carte .recherche-liste {
&.vue-carte .recherche-liste,
&.vue-carte header {
display: none;
}
@ -156,31 +160,41 @@ section.content.recherche {
}
&.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 {
width: 100%;
min-width: 400px;
max-width: 500px;
flex: 1;
.dates {
display:none;
}
ul.infos li {
font-size: 0.8em;
font-weight: normal;
&.year {
display: inline-block;
.recherche-liste {
padding-top: 60px;
width: 500px;
.dates {
display:none;
}
ul.infos li {
font-size: 0.8em;
font-weight: normal;
&.year {
display: inline-block;
}
}
}
}
.recherche-carte {
flex: 1.5;
width: 100%;
.recherche-carte {
flex: 1.5;
width: 100%;
.vue-options {
display:none;
.vue-options {
display:none;
}
}
}
}

View file

@ -18,67 +18,7 @@
}
@media screen and (max-width: 600px) {
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;
}
@import "_miniheader.scss";
#feedback-button {
transform: unset;

View file

@ -1225,8 +1225,8 @@ table.stats td, table.stats th {
text-align: center;
}
/* line 3, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale {
/* line 5, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .generale {
display: inline-block;
text-align: right;
position: relative;
@ -1236,39 +1236,39 @@ section.content.recherche form.recherche .generale {
max-width: 100%;
white-space: nowrap;
}
/* line 13, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale span {
/* line 15, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .generale span {
display: flex;
}
/* line 17, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale input[type="text"] {
/* line 19, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .generale input[type="text"] {
max-width: 500px;
padding: 10px;
border: 1px solid #8fcc33;
margin: 0 5px;
}
/* line 23, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale input {
/* line 25, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .generale input {
display: inline;
}
/* line 28, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee {
/* line 30, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .avancee {
background: #fff;
display: none;
padding: 15px;
margin-bottom: 15px;
}
/* line 34, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee.expanded {
/* line 36, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .avancee.expanded {
display: block;
}
/* line 38, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee .help_text {
/* line 40, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .avancee .help_text {
font-style: italic;
font-size: 0.9em;
}
/* line 43, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul {
/* line 45, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .avancee ul {
margin: 0 -5px;
display: flexbox;
display: flex;
@ -1276,21 +1276,21 @@ section.content.recherche form.recherche .avancee ul {
justify-content: space-between;
width: 100%;
}
/* line 51, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul li {
/* line 53, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .avancee ul li {
flex-grow: 1;
width: 22%;
min-width: 150px;
margin: 5px 0;
padding: 0 10px;
}
/* line 58, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul li label {
/* line 60, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .avancee ul li label {
font-weight: bold;
font-size: 0.9em;
}
/* line 63, ../../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 {
/* line 65, ../../sass/_recherche.scss */
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;
min-width: 150px;
display: inline-block;
@ -1298,152 +1298,222 @@ section.content.recherche form.recherche .avancee ul li input[type="text"], sect
font-size: 0.9em;
background-color: #f8f8f8;
}
/* line 71, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul li.btnsubmit {
/* line 73, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .avancee ul li.btnsubmit {
text-align: right;
}
/* line 74, ../../sass/_recherche.scss */
section.content.recherche form.recherche .avancee ul li.field__sujet, section.content.recherche form.recherche .avancee ul li.field__contexte {
/* line 76, ../../sass/_recherche.scss */
body.recherche section.content form.recherche .avancee ul li.field__sujet, body.recherche section.content form.recherche .avancee ul li.field__contexte {
width: 45%;
min-width: 300px;
}
/* line 84, ../../sass/_recherche.scss */
section.content.recherche .recherche-carte, section.content.recherche .recherche-liste {
/* line 86, ../../sass/_recherche.scss */
body.recherche section.content .recherche-carte, body.recherche section.content .recherche-liste {
position: relative;
}
/* line 88, ../../sass/_recherche.scss */
section.content.recherche .numresults {
/* line 90, ../../sass/_recherche.scss */
body.recherche section.content .numresults {
font-size: 0.9em;
font-weight: bold;
}
/* line 93, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride #voir_hybride, section.content.recherche.vue-carte #voir_carte, section.content.recherche.vue-liste #voir_liste {
/* line 96, ../../sass/_recherche.scss */
body.recherche.vue-hybride #voir_hybride, body.recherche.vue-carte #voir_carte, body.recherche.vue-liste #voir_liste {
background: #d2ebad;
color: #000;
}
/* line 100, ../../sass/_recherche.scss */
section.content.recherche .vue-options {
/* line 103, ../../sass/_recherche.scss */
body.recherche .vue-options {
text-align: center;
}
/* line 102, ../../sass/_recherche.scss */
section.content.recherche .vue-options ul {
/* line 105, ../../sass/_recherche.scss */
body.recherche .vue-options ul {
display: inline-block;
border-radius: 5px;
overflow: hidden;
}
/* line 107, ../../sass/_recherche.scss */
section.content.recherche .vue-options ul li {
/* line 110, ../../sass/_recherche.scss */
body.recherche .vue-options ul li {
display: inline-block;
background: #fff;
padding: 10px;
}
/* line 111, ../../sass/_recherche.scss */
section.content.recherche .vue-options ul li a {
/* line 114, ../../sass/_recherche.scss */
body.recherche .vue-options ul li a {
display: block;
padding: 10px;
margin: -10px;
}
/* line 120, ../../sass/_recherche.scss */
section.content.recherche .recherche-carte .vue-options {
/* line 123, ../../sass/_recherche.scss */
body.recherche .recherche-carte .vue-options {
position: absolute;
z-index: 3;
top: 15px;
left: 60px;
}
/* line 127, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride, section.content.recherche.vue-carte {
/* line 130, ../../sass/_recherche.scss */
body.recherche.vue-hybride section.content, body.recherche.vue-carte section.content {
width: 100%;
min-width: unset;
max-width: unset;
min-height: unset;
max-height: unset;
height: 90vh;
height: calc(100vh - 30px);
height: 100vh;
padding: 0;
margin: 0;
}
/* line 138, ../../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 {
/* line 141, ../../sass/_recherche.scss */
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%;
}
/* line 141, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-liste, section.content.recherche.vue-carte .recherche-liste {
/* line 144, ../../sass/_recherche.scss */
body.recherche.vue-hybride section.content .recherche-liste, body.recherche.vue-carte section.content .recherche-liste {
overflow-y: auto;
padding: 15px;
}
/* line 147, ../../sass/_recherche.scss */
section.content.recherche.vue-liste .recherche-carte, section.content.recherche.vue-carte .recherche-liste {
/* line 150, ../../sass/_recherche.scss */
body.recherche.vue-liste .recherche-carte, body.recherche.vue-carte .recherche-liste, body.recherche.vue-carte header {
display: none;
}
/* line 152, ../../sass/_recherche.scss */
section.content.recherche.vue-carte .recherche-carte, section.content.recherche.vue-liste .recherche-liste {
/* line 156, ../../sass/_recherche.scss */
body.recherche.vue-carte .recherche-carte, body.recherche.vue-liste .recherche-liste {
display: block;
width: 100%;
}
/* line 158, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride {
display: flex;
}
/* line 161, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-liste {
/* line 2, ../../sass/_miniheader.scss */
body.recherche.vue-hybride header {
z-index: 40;
position: fixed;
top: 0px;
left: 0px;
width: 100%;
min-width: 400px;
max-width: 500px;
flex: 1;
display: block;
max-height: 100vh;
overflow-y: auto;
}
/* line 167, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-liste .dates {
/* line 12, ../../sass/_miniheader.scss */
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;
}
/* line 170, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-liste ul.infos li {
/* line 31, ../../sass/_miniheader.scss */
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-weight: normal;
}
/* line 173, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-liste ul.infos li.year {
/* line 186, ../../sass/_recherche.scss */
body.recherche.vue-hybride section.content .recherche-liste ul.infos li.year {
display: inline-block;
}
/* line 178, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-carte {
/* line 191, ../../sass/_recherche.scss */
body.recherche.vue-hybride section.content .recherche-carte {
flex: 1.5;
width: 100%;
}
/* line 182, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride .recherche-carte .vue-options {
/* line 195, ../../sass/_recherche.scss */
body.recherche.vue-hybride section.content .recherche-carte .vue-options {
display: none;
}
/* line 188, ../../sass/_recherche.scss */
section.content.recherche #carte {
/* line 202, ../../sass/_recherche.scss */
body.recherche #carte {
width: 100%;
height: 100%;
}
/* line 193, ../../sass/_recherche.scss */
section.content.recherche .recherche-liste.recherche-details {
/* line 207, ../../sass/_recherche.scss */
body.recherche .recherche-liste.recherche-details {
display: none !important;
}
/* line 196, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride.vue-details .recherche-liste {
/* line 210, ../../sass/_recherche.scss */
body.recherche.vue-hybride.vue-details .recherche-liste {
display: none;
}
/* line 199, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-details {
/* line 213, ../../sass/_recherche.scss */
body.recherche.vue-hybride.vue-details .recherche-liste.recherche-details {
display: block !important;
}
@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 {
height: calc(100vh - 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 {
max-height: 115px;
overflow-y: hidden;
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 {
position: absolute;
content: "⋅⋅⋅";
@ -1456,35 +1526,35 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
text-align: center;
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 {
display: none;
}
/* line 237, ../../sass/_recherche.scss */
/* line 251, ../../sass/_recherche.scss */
section.content.recherche .recherche-liste .dates .detail {
display: none;
}
/* line 243, ../../sass/_recherche.scss */
/* line 257, ../../sass/_recherche.scss */
ul.messages {
display: none;
}
}
@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 {
font-size: 0.9em;
flex: 1;
}
/* line 255, ../../sass/_recherche.scss */
/* line 269, ../../sass/_recherche.scss */
section.content.recherche form.recherche .generale span input[type=submit] {
white-space: normal;
}
/* line 259, ../../sass/_recherche.scss */
/* line 273, ../../sass/_recherche.scss */
section.content.recherche.vue-hybride, section.content.recherche.vue-carte {
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 {
max-width: 100vw;
min-width: unset;
@ -1512,76 +1582,7 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
}
}
@media screen and (max-width: 600px) {
/* line 21, ../../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 */
/* line 23, ../../sass/_responsive.scss */
#feedback-button {
transform: unset;
top: 0px;
@ -1592,79 +1593,79 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
background: rgba(0, 0, 0, 0.5);
}
/* line 92, ../../sass/_responsive.scss */
/* line 32, ../../sass/_responsive.scss */
.content {
margin-top: 70px;
padding: 15px 3vw;
}
/* line 97, ../../sass/_responsive.scss */
/* line 37, ../../sass/_responsive.scss */
article.stage h3 {
margin-top: 10px;
}
/* line 101, ../../sass/_responsive.scss */
/* line 41, ../../sass/_responsive.scss */
article.stage section .avis-texte, article.stage section .chapo {
padding: 3px 10px;
}
/* line 107, ../../sass/_responsive.scss */
/* line 47, ../../sass/_responsive.scss */
article.stage section #stage-map {
height: 200px;
width: 100%;
}
/* line 113, ../../sass/_responsive.scss */
/* line 53, ../../sass/_responsive.scss */
article.stage section.misc .misc-content.withmap {
display: block;
}
/* line 116, ../../sass/_responsive.scss */
/* line 56, ../../sass/_responsive.scss */
article.stage section.misc .misc-content.withmap > div {
display: block;
vertical-align: top;
}
/* line 120, ../../sass/_responsive.scss */
/* line 60, ../../sass/_responsive.scss */
article.stage section.misc .misc-content.withmap .map {
width: 80%;
min-width: 250px;
min-height: 200px;
margin: 0 auto;
}
/* line 126, ../../sass/_responsive.scss */
/* line 66, ../../sass/_responsive.scss */
article.stage section.misc .misc-content.withmap .desc {
padding: 5px;
}
/* line 134, ../../sass/_responsive.scss */
/* line 74, ../../sass/_responsive.scss */
article.stage section .plusmoins > div {
display: block;
}
/* line 137, ../../sass/_responsive.scss */
/* line 77, ../../sass/_responsive.scss */
article.stage section .plusmoins > div > *, article.stage section .plusmoins > div:before {
display: block;
}
/* line 141, ../../sass/_responsive.scss */
/* line 81, ../../sass/_responsive.scss */
article.stage section .plusmoins > div:before {
text-align: left;
width: 100%;
font-size: 1.5em;
}
/* line 146, ../../sass/_responsive.scss */
/* line 86, ../../sass/_responsive.scss */
article.stage section .plusmoins > div.moins:before {
text-align: right;
margin-top: 5px;
}
/* line 155, ../../sass/_responsive.scss */
/* line 95, ../../sass/_responsive.scss */
article.stage .section-wrapper {
display: block;
margin-left: 0;
}
/* line 159, ../../sass/_responsive.scss */
/* line 99, ../../sass/_responsive.scss */
article.stage .section-wrapper .toc-wrapper, article.stage .section-wrapper > section {
display: block;
}
/* line 162, ../../sass/_responsive.scss */
/* line 102, ../../sass/_responsive.scss */
article.stage .section-wrapper .toc-wrapper {
max-width: unset;
width: unset;
}
/* line 166, ../../sass/_responsive.scss */
/* line 106, ../../sass/_responsive.scss */
article.stage .section-wrapper .toc {
display: none;
position: relative;
@ -1673,65 +1674,65 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
padding: 4px;
}
/* line 176, ../../sass/_responsive.scss */
/* line 116, ../../sass/_responsive.scss */
.homeh1 {
display: block;
}
/* line 178, ../../sass/_responsive.scss */
/* line 118, ../../sass/_responsive.scss */
.homeh1 > * {
display: block;
}
/* line 183, ../../sass/_responsive.scss */
/* line 123, ../../sass/_responsive.scss */
article.promo .explications {
display: block;
}
/* line 185, ../../sass/_responsive.scss */
/* line 125, ../../sass/_responsive.scss */
article.promo .explications div {
max-width: 100%;
display: block;
}
/* line 192, ../../sass/_responsive.scss */
/* line 132, ../../sass/_responsive.scss */
.condensed-stages {
display: block;
}
/* line 195, ../../sass/_responsive.scss */
/* line 135, ../../sass/_responsive.scss */
.condensed-stages li:before, .condensed-stages li, .condensed-stages a {
display: block;
width: auto;
max-width: auto;
}
/* line 201, ../../sass/_responsive.scss */
/* line 141, ../../sass/_responsive.scss */
.condensed-stages li:before {
padding: 3px 15px;
}
/* line 205, ../../sass/_responsive.scss */
/* line 145, ../../sass/_responsive.scss */
.condensed-stages li.stage-ajout:before {
display: none;
}
/* line 210, ../../sass/_responsive.scss */
/* line 150, ../../sass/_responsive.scss */
ul.infos {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
/* line 219, ../../sass/_responsive.scss */
/* line 159, ../../sass/_responsive.scss */
.stage-liste li .misc-hdr .dates .detail {
display: inline;
}
/* line 222, ../../sass/_responsive.scss */
/* line 162, ../../sass/_responsive.scss */
.stage-liste li .misc-hdr .dates .year {
padding: 0;
}
/* line 230, ../../sass/_responsive.scss */
/* line 170, ../../sass/_responsive.scss */
form .field {
display: block;
}
/* line 233, ../../sass/_responsive.scss */
/* line 173, ../../sass/_responsive.scss */
form .field label, form .field .label {
display: block;
text-align: left;
@ -1740,18 +1741,18 @@ section.content.recherche.vue-hybride.vue-details .recherche-liste.recherche-det
margin-top: 0;
width: auto;
}
/* line 242, ../../sass/_responsive.scss */
/* line 182, ../../sass/_responsive.scss */
form .field .help_text {
text-align: right;
color: #395214;
}
/* line 247, ../../sass/_responsive.scss */
/* line 187, ../../sass/_responsive.scss */
form .field .input {
padding-left: 20px;
display: block;
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 {
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 lieux_map = {}, lieux_list = [], stages_map = {}, lieux_db = {};
var stages_data = {};
var stages_db = {};
var details_liste_data;
var marqueurs = L.markerClusterGroup();
var marqueurs_db = {};
var changevue;
@ -13,7 +14,7 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
// TODO se souvenir des préférences d'affichage
function initInterface() {
main_container = $(".content.recherche");
main_container = $("body");
if (main_container.hasClass("vue-liste")) {
interface_mode = "liste";
} else if (main_container.hasClass("vue-carte")) {
@ -43,6 +44,17 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
});
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
@ -53,8 +65,8 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
function changeInterface(mode) {
interface_mode = mode;
$(".content.recherche").removeClass("vue-carte vue-hybride vue-liste")
.addClass("vue-"+mode);
main_container.removeClass("vue-carte vue-hybride vue-liste")
.addClass("vue-"+mode);
if (mode=="hybride" || mode=="carte") {
initCarte();
map.invalidateSize();
@ -84,7 +96,7 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
var greenIcon = makeIcon('red');
var blueIcon = makeIcon('blue', 1.2);
// Chargeùent des infos
// Chargement des infos
function onLoadLieux(data){
console.log(data);
var lieux = data.objects;
@ -133,7 +145,7 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
var html = $("<div>").html(marqueur._popup_header);
var stageliste = $("<ul>");
$.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 sujet = stage_el.find('a.stage-sujet').text();
var auteur = stage_el.find('.auteur').text();
@ -146,19 +158,42 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
marqueur.setPopupContent(html[0]);
}
// Affichage de la liste hybride au survol + chargement asynchrone
function showDetailsListeListener (evt) {
showDetailsListe(this._lieu_data);
}
function showDetailsListe (data) {
function showDetailsListe (data, is_callback) {
main_container.addClass("vue-details");
var to_load = [];
var liste_el = $("#resultats-details");
$.each(liste_el.children(), function(i, item){$(item).remove();});
$.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());
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 () {
@ -167,6 +202,7 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
}
function hideDetailsListeListener () {
details_liste_data = undefined;
if (details_lock === false)
main_container.removeClass("vue-details");
else
@ -195,6 +231,33 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, lieux) {
$("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__
initInterface();

View file

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

View file

@ -6,14 +6,14 @@
{% block extra_head %}
<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/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/MarkerCluster.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/MarkerCluster.Default.css' %}" />
<script type="text/javascript" src="{% static "js/render.js" %}"></script>
{% endblock %}
{% block extra_content_class %}recherche {{ vue }}{% endblock %}
{% block bodyclass %}recherche {{ vue }}{% endblock %}
{% block content %}
<section class="recherche-liste" id="recherche-liste">
@ -30,42 +30,11 @@
<li><a href="javascript:void(0);" id="voir_carte">Carte</a></li>
</ul>
</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 %}
<ul class="stage-liste" id="resultats">
{% 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 %}
{% include "avisstage/recherche/stage_items.html" %}
</ul>
</article>
@ -82,12 +51,16 @@
<div id="carte"></div>
<div id="vue-options2" class="vue-options">
<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>
</div>
<script type="text/javascript">
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>
</section>
{% 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"
else:
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'^recherche/$', views.recherche, name='recherche'),
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'^moderation/$', views.statistiques, name='moderation'),
url(r'^api/', include(v1_api.urls)),

View file

@ -1,16 +1,21 @@
# coding: utf-8
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth.decorators import login_required
from datetime import date
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.http import JsonResponse, HttpResponseBadRequest
from django.shortcuts import render, redirect, get_object_or_404
import json
from .documents import StageDocument
from .models import Stage
from .statics import TYPE_LIEU_OPTIONS, TYPE_STAGE_OPTIONS, NIVEAU_SCOL_OPTIONS
from datetime import date
# Recherche
class SearchForm(forms.Form):
@ -137,13 +142,66 @@ def recherche_resultats(request):
if request.method == "GET":
form = SearchForm(request.GET)
if form.is_valid():
stages, tri = cherche(**form.cleaned_data)
stages = stages.prefetch_related('lieux', 'auteur', 'matieres', 'thematiques')
lieux = [[stageid, lieuid] for (stageid, lieuid) in stages.values_list('id', 'lieux') if lieuid is not None]
page = request.GET.get("page", 1)
search_args = form.cleaned_data
# Gestion du cache
cache_key = json.dumps(search_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)
else:
# Lecture du cache
stageids = cached["stages"]
lieux = cached["lieux"]
tri = cached["tri"]
# 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:
form = SearchForm()
if stages:
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})
@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})