Fix bug quand un événement n'a pas de localisation précise
This commit is contained in:
parent
b90736000f
commit
7b38fef6fc
@ -1071,7 +1071,9 @@ class Event(models.Model):
|
|||||||
.order_by("-score")[:10]
|
.order_by("-score")[:10]
|
||||||
)
|
)
|
||||||
|
|
||||||
return qs.only("title", "start_day", "start_time", "exact_location", "location")
|
return qs.only(
|
||||||
|
"title", "start_day", "start_time", "exact_location", "location", "tags"
|
||||||
|
)
|
||||||
|
|
||||||
def proposed_events(self):
|
def proposed_events(self):
|
||||||
threshold_distance = 30000
|
threshold_distance = 30000
|
||||||
@ -1106,15 +1108,22 @@ class Event(models.Model):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
qs = qs.annotate(overlap_tags_count=Value(1))
|
qs = qs.annotate(overlap_tags_count=Value(1))
|
||||||
qs = (
|
|
||||||
qs.filter(overlap_tags_count__gte=min_tags)
|
if self.exact_location:
|
||||||
.annotate(
|
qs = (
|
||||||
distance=Distance(
|
qs.filter(overlap_tags_count__gte=min_tags)
|
||||||
F("exact_location__location"), self.exact_location.location
|
.annotate(
|
||||||
|
distance=Distance(
|
||||||
|
F("exact_location__location"), self.exact_location.location
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
.filter(distance__lte=threshold_distance)
|
||||||
)
|
)
|
||||||
.filter(distance__lte=threshold_distance)
|
else:
|
||||||
.annotate(
|
qs = qs.annotate(distance=Value(1))
|
||||||
|
|
||||||
|
qs = (
|
||||||
|
qs.annotate(
|
||||||
nbday_distance=Func(
|
nbday_distance=Func(
|
||||||
(ExtractDay(F("start_day") - self.start_day)), function="ABS"
|
(ExtractDay(F("start_day") - self.start_day)), function="ABS"
|
||||||
)
|
)
|
||||||
@ -1136,7 +1145,7 @@ class Event(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._proposed_events = qs.only(
|
self._proposed_events = qs.only(
|
||||||
"title", "start_day", "start_time", "exact_location", "location"
|
"title", "start_day", "start_time", "exact_location", "location", "tags"
|
||||||
)
|
)
|
||||||
self._proposed_events = sorted(
|
self._proposed_events = sorted(
|
||||||
self._proposed_events,
|
self._proposed_events,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user