Commit e126179f authored by hypsug0's avatar hypsug0
Browse files

fix: fix creator and creator_id filter on place search

parent bb5ef01f
......@@ -531,7 +531,6 @@ const placeSearchBlock = () => {
.bringToFront()
searchMap.fitBounds(locationLayer.getBounds())
searchMap.invalidateSize()
table.rows.add(data.features).draw()
})
.then(
......@@ -586,14 +585,13 @@ const placeSearchBlock = () => {
})
.serialize()
$('#results').text(str)
mutableDataUrl = '/place/api/search?format=json&' + str
mutableDataUrl = `${dataUrl}${str}`
loadDatas()
}
let debounce = null
$('#searchForm').on('click change', 'input, select', function () {
clearTimeout(debounce)
debounce = setTimeout(showValues, 500)
})
......@@ -980,7 +978,7 @@ const sightingSearchBlock = () => {
})
.serialize()
$('#results').text(str)
dataUrlQs = dataUrl + '?' + str
dataUrlQs = `${dataUrl}${str}`
if (circleMarker !== null) {
searchMap.removeLayer(circleMarker)
}
......
......@@ -461,6 +461,7 @@ class PlaceFilteringMixin:
alt_max = self.request.query_params.get("alt_max", None)
gite = self.request.query_params.get("gite", None)
creator = self.request.query_params.get("creator", None)
created_by_id = self.request.query_params.get("created_by_id", None)
metaplace = self.request.query_params.get("metaplace", None)
convention = self.request.query_params.get("convention", None)
managed = self.request.query_params.get("managed", None)
......@@ -487,7 +488,8 @@ class PlaceFilteringMixin:
qs = qs.filter(altitude__gte=alt_min) if alt_min is not None else qs
qs = qs.filter(altitude__lte=alt_max) if alt_max is not None else qs
qs = qs.filter(creator__username__icontains=creator) if creator is not None else qs
qs = qs.filter(created_by__username__icontains=creator) if creator is not None else qs
qs = qs.filter(created_by=created_by_id) if created_by_id is not None else qs
qs = qs.filter(is_gite=True) if gite is not None else qs
qs = (
qs.filter(
......
......@@ -312,7 +312,7 @@ class PlaceList(LoginRequiredMixin, TemplateView):
"js"
] = """
"""
context["dataUrl"] = "/place/api/search?format=json"
context["dataUrl"] = "/place/api/search?format=json&"
return context
......@@ -321,7 +321,6 @@ class PlaceMyList(LoginRequiredMixin, TemplateView):
def get_context_data(self, **kwargs):
logged_user = self.request.user
user = get_user_model().objects.get(id=logged_user.id)
context = super(PlaceMyList, self).get_context_data(**kwargs)
context["icon"] = "fa fa-fw fa-map"
context["title"] = _("Rechercher dans mes localités")
......@@ -329,7 +328,7 @@ class PlaceMyList(LoginRequiredMixin, TemplateView):
"js"
] = """
"""
context["dataUrl"] = "/place/api/search?format=json&creator=" + user.username
context["dataUrl"] = f"/place/api/search?format=json&created_by_id={logged_user.id}&"
return context
......
......@@ -21,7 +21,8 @@
</style>
<script>
const dataUrl = "{% url 'sights:place_search_api' %}";
const dataUrl =
`{% if dataUrl %}{{dataUrl}}{% else %}{% url 'sights:place_search_api' %}{% endif %}`;
$(document).ready(function () {
placeSearchBlock();
});
......@@ -33,7 +34,7 @@
class="fa fa-fw fa-map-marker-alt"></i>
{% trans 'Créer une localité' %}</a><i class="{{ icon | safe }}"></i> {{ title | safe }}
</h1>
{{dataUrl}}
{% comment %}Tableau de recherche avec filtrage {% endcomment %}
<div class="col-sm-12 col-md-6 col-lg-7">
<div class="panel panel-default">
......@@ -156,7 +157,11 @@
{% if filter %}
<link rel="stylesheet" href="{% static 'css/select2-bootstrap.min.css' %}" />
<script type="text/javascript">
{{js | safe}}
{
{
js | safe
}
}
$.fn.select2.defaults.set('theme', 'bootstrap')
</script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment