Affichage de la recherche
This commit is contained in:
parent
1eed88736f
commit
a41f597827
3 changed files with 87 additions and 7 deletions
|
@ -334,4 +334,47 @@ ul.bigger li:hover{
|
|||
.failure {
|
||||
padding:5px;
|
||||
background:#f99;
|
||||
}
|
||||
|
||||
/* Recherche */
|
||||
form.recherche p {
|
||||
background:none;
|
||||
}
|
||||
form.recherche {
|
||||
background:#ddd;
|
||||
padding:5px;
|
||||
}
|
||||
|
||||
form.recherche .criteria {
|
||||
display:table;
|
||||
width:100%;
|
||||
}
|
||||
form.recherche .criteria p {
|
||||
display:table-cell;
|
||||
}
|
||||
|
||||
form.recherche .lieu {
|
||||
display:table;
|
||||
}
|
||||
|
||||
form.recherche .lieu div {
|
||||
display:table-cell;
|
||||
}
|
||||
|
||||
#map_searchlieu {
|
||||
width:50%;
|
||||
}
|
||||
|
||||
.stagefound {
|
||||
background:#fff;
|
||||
padding:10px;
|
||||
margin:10px 0;
|
||||
}
|
||||
|
||||
.stagefound h3 {
|
||||
margin-top:0;
|
||||
}
|
||||
|
||||
.stagefound p {
|
||||
margin-bottom:0px;
|
||||
}
|
|
@ -10,16 +10,53 @@
|
|||
{% block content %}
|
||||
<h1>Rechercher des stages</h1>
|
||||
<div id="searchbox">
|
||||
<form action="{% url 'monstage:search' %}" method="get">
|
||||
<form action="{% url 'monstage:search' %}" method="get" class="recherche">
|
||||
<p>Critères :</p>
|
||||
{{ form.as_p }}
|
||||
<div id="map_searchlieu"></div>
|
||||
<div class="criteria">
|
||||
<p>
|
||||
{{ form.matiere.errors }}
|
||||
{{ form.matiere.label_tag }}
|
||||
{{ form.matiere }}
|
||||
</p>
|
||||
<p>
|
||||
{{ form.thematiques.errors }}
|
||||
{{ form.thematiques.label_tag }}
|
||||
{{ form.thematiques }}
|
||||
</p>
|
||||
</div>
|
||||
{{ form.latitude }}
|
||||
{{ form.longitude }}
|
||||
<div class="lieu">
|
||||
<div class="champs">
|
||||
<p>
|
||||
{{ form.lieu.errors }}
|
||||
{{ form.lieu.label_tag }}
|
||||
{{ form.lieu }}
|
||||
</p>
|
||||
<p id="search_tolerance" style="display:none">
|
||||
{{ form.tolerance.errors }}
|
||||
{{ form.tolerance.label_tag }}
|
||||
{{ form.tolerance }}
|
||||
</p>
|
||||
</div>
|
||||
<div id="map_searchlieu"></div>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
$("#id_lieu").geocomplete({
|
||||
$("#id_lieu").attr("placeholder", "(N'importe où)").geocomplete({
|
||||
map: "#map_searchlieu",
|
||||
types: ["geocode", "establishment"],
|
||||
}).on("geocode:result", function(event, result){ $("#map_searchlieu").css("display", "block"); digere(result); console.log(result); });
|
||||
}).on("geocode:result", function(event, result){
|
||||
$("#map_searchlieu").css("display", "table-cell");
|
||||
digere(result);
|
||||
console.log(result);
|
||||
if($("#id_latitude").val() != "") {
|
||||
$("#search_tolerance").css("display", "block");
|
||||
}
|
||||
});
|
||||
if($("#id_latitude").val() != "") {
|
||||
$("#search_tolerance").css("display", "block");
|
||||
}
|
||||
});
|
||||
|
||||
var predata;
|
||||
|
@ -54,7 +91,7 @@
|
|||
{% for stage in resultats %}
|
||||
<div class="stagefound">
|
||||
<h3><a href="{% url 'monstage:stage' stage.id %}">{{ stage.sujet }}</a></h3>
|
||||
<p>Par {{ stage.profil_user }} à {% for lieu in stage.lieux.all %}{% if not forloop.first %}{% if forloop.last %} et {% else %}, {% endif %}{% endif %}{{ lieu.name }} ({{ lieu.ville }}){% endfor %}.</p>
|
||||
<p>Par <a href="{% url 'monstage:profil' stage.profil_user.user.username %}">{{ stage.profil_user }}</a> à {% for lieu in stage.lieux.all %}{% if not forloop.first %}{% if forloop.last %} et {% else %}, {% endif %}{% endif %}{{ lieu.name }} ({{ lieu.ville }}){% endfor %}, en {{ stage.end_date|date:'Y' }}.</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
|
|
@ -312,7 +312,7 @@ def search(request):
|
|||
if thematiques:
|
||||
q = Q()
|
||||
for thematique in thematiques:
|
||||
q |= Q(thematiques__name__icontains = thematique)
|
||||
q |= Q(thematiques__slug__icontains = thematique)
|
||||
stages = stages.filter(q).distinct()
|
||||
stages = stages.all()
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue