Affichage de la recherche
This commit is contained in:
parent
1eed88736f
commit
a41f597827
3 changed files with 87 additions and 7 deletions
|
@ -335,3 +335,46 @@ ul.bigger li:hover{
|
||||||
padding:5px;
|
padding:5px;
|
||||||
background:#f99;
|
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 %}
|
{% block content %}
|
||||||
<h1>Rechercher des stages</h1>
|
<h1>Rechercher des stages</h1>
|
||||||
<div id="searchbox">
|
<div id="searchbox">
|
||||||
<form action="{% url 'monstage:search' %}" method="get">
|
<form action="{% url 'monstage:search' %}" method="get" class="recherche">
|
||||||
<p>Critères :</p>
|
<p>Critères :</p>
|
||||||
{{ form.as_p }}
|
<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 id="map_searchlieu"></div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$("#id_lieu").geocomplete({
|
$("#id_lieu").attr("placeholder", "(N'importe où)").geocomplete({
|
||||||
map: "#map_searchlieu",
|
map: "#map_searchlieu",
|
||||||
types: ["geocode", "establishment"],
|
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;
|
var predata;
|
||||||
|
@ -54,7 +91,7 @@
|
||||||
{% for stage in resultats %}
|
{% for stage in resultats %}
|
||||||
<div class="stagefound">
|
<div class="stagefound">
|
||||||
<h3><a href="{% url 'monstage:stage' stage.id %}">{{ stage.sujet }}</a></h3>
|
<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>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -312,7 +312,7 @@ def search(request):
|
||||||
if thematiques:
|
if thematiques:
|
||||||
q = Q()
|
q = Q()
|
||||||
for thematique in thematiques:
|
for thematique in thematiques:
|
||||||
q |= Q(thematiques__name__icontains = thematique)
|
q |= Q(thematiques__slug__icontains = thematique)
|
||||||
stages = stages.filter(q).distinct()
|
stages = stages.filter(q).distinct()
|
||||||
stages = stages.all()
|
stages = stages.all()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue