aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fietsboek/locale/de/LC_MESSAGES/messages.mobin20685 -> 20960 bytes
-rw-r--r--fietsboek/locale/de/LC_MESSAGES/messages.po16
-rw-r--r--fietsboek/locale/en/LC_MESSAGES/messages.mobin19490 -> 19742 bytes
-rw-r--r--fietsboek/locale/en/LC_MESSAGES/messages.po16
-rw-r--r--fietsboek/templates/browse.jinja222
-rw-r--r--fietsboek/views/browse.py36
6 files changed, 89 insertions, 1 deletions
diff --git a/fietsboek/locale/de/LC_MESSAGES/messages.mo b/fietsboek/locale/de/LC_MESSAGES/messages.mo
index 25b4a89..ec717d2 100644
--- a/fietsboek/locale/de/LC_MESSAGES/messages.mo
+++ b/fietsboek/locale/de/LC_MESSAGES/messages.mo
Binary files differ
diff --git a/fietsboek/locale/de/LC_MESSAGES/messages.po b/fietsboek/locale/de/LC_MESSAGES/messages.po
index bdd53a7..3d6c4aa 100644
--- a/fietsboek/locale/de/LC_MESSAGES/messages.po
+++ b/fietsboek/locale/de/LC_MESSAGES/messages.po
@@ -269,6 +269,18 @@ msgstr "Längenbeschränkungen"
msgid "page.browse.filter.length_maximum"
msgstr "Maximale Länge"
+#: fietsboek/templates/browse.jinja2:34
+msgid "page.browse.filter.uphill_minimum"
+msgstr "Minimaler Bergauf"
+
+#: fietsboek/templates/browse.jinja2:40
+msgid "page.browse.filter.uphill_boundaries"
+msgstr "Bergaufbeschränkungen"
+
+#: fietsboek/templates/browse.jinja2:46
+msgid "page.browse.filter.uphill_maximum"
+msgstr "Maximaler Bergauf"
+
#: fietsboek/templates/browse.jinja2:59
msgid "page.browse.filter.date_boundaries"
msgstr "Datumsgrenzen"
@@ -326,6 +338,10 @@ msgid "page.browse.sort.length"
msgstr "Nach Länge sortieren"
#: fietsboek/templates/browse.jinja2:125 fietsboek/templates/browse.jinja2:126
+msgid "page.browse.sort.uphill"
+msgstr "Nach Bergauf sortieren"
+
+#: fietsboek/templates/browse.jinja2:127 fietsboek/templates/browse.jinja2:128
msgid "page.browse.sort.duration"
msgstr "Nach Dauer sortieren"
diff --git a/fietsboek/locale/en/LC_MESSAGES/messages.mo b/fietsboek/locale/en/LC_MESSAGES/messages.mo
index b0c8a9c..95464f3 100644
--- a/fietsboek/locale/en/LC_MESSAGES/messages.mo
+++ b/fietsboek/locale/en/LC_MESSAGES/messages.mo
Binary files differ
diff --git a/fietsboek/locale/en/LC_MESSAGES/messages.po b/fietsboek/locale/en/LC_MESSAGES/messages.po
index e75d0e0..b94eb76 100644
--- a/fietsboek/locale/en/LC_MESSAGES/messages.po
+++ b/fietsboek/locale/en/LC_MESSAGES/messages.po
@@ -269,6 +269,18 @@ msgstr "Length limits"
msgid "page.browse.filter.length_maximum"
msgstr "Maximum length"
+#: fietsboek/templates/browse.jinja2:34
+msgid "page.browse.filter.uphill_minimum"
+msgstr "Minimum uphill"
+
+#: fietsboek/templates/browse.jinja2:40
+msgid "page.browse.filter.uphill_boundaries"
+msgstr "Uphill limits"
+
+#: fietsboek/templates/browse.jinja2:46
+msgid "page.browse.filter.uphill_maximum"
+msgstr "Maximum uphill"
+
#: fietsboek/templates/browse.jinja2:59
msgid "page.browse.filter.date_boundaries"
msgstr "Date limits"
@@ -326,6 +338,10 @@ msgid "page.browse.sort.length"
msgstr "Sort by length"
#: fietsboek/templates/browse.jinja2:125 fietsboek/templates/browse.jinja2:126
+msgid "page.browse.sort.uphill"
+msgstr "Sort by uphill"
+
+#: fietsboek/templates/browse.jinja2:127 fietsboek/templates/browse.jinja2:128
msgid "page.browse.sort.duration"
msgstr "Sort by duration"
diff --git a/fietsboek/templates/browse.jinja2 b/fietsboek/templates/browse.jinja2
index 28693f6..b4a99b2 100644
--- a/fietsboek/templates/browse.jinja2
+++ b/fietsboek/templates/browse.jinja2
@@ -51,6 +51,26 @@
<div class="col-md-4">
<div class="input-group">
<button type="button" class="btn btn-outline-secondary button-clear-input"><i class="bi bi-eraser-fill"></i></button>
+ <input name="min-uphill" type="number" class="form-control ui-element" placeholder="{{ _("page.browse.filter.uphill_minimum") }}" value="{{ request.params.get('min-uphill', '') }}">
+ <span class="input-group-text ui-element">m</span>
+ </div>
+ </div>
+
+ <div class="col-md-4 fs-5 d-flex align-items-center justify-content-center ui-element">
+ {{ _("page.browse.filter.uphill_boundaries") }}
+ </div>
+
+ <div class="col-md-4">
+ <div class="input-group">
+ <button type="button" class="btn btn-outline-secondary button-clear-input"><i class="bi bi-eraser-fill"></i></button>
+ <input name="max-uphill" type="number" class="form-control ui-element" placeholder="{{ _("page.browse.filter.uphill_maximum") }}" value="{{ request.params.get('max-uphill', '') }}">
+ <span class="input-group-text ui-element">m</span>
+ </div>
+ </div>
+
+ <div class="col-md-4">
+ <div class="input-group">
+ <button type="button" class="btn btn-outline-secondary button-clear-input"><i class="bi bi-eraser-fill"></i></button>
<input name="min-date" type="date" class="form-control ui-element" value="{{ request.params.get('min-date', '') }}">
</div>
</div>
@@ -122,6 +142,8 @@
<option value="DATE_ASC" {% if request.params.get("sort") == "DATE_ASC" %}selected{% endif %}>{{ _("page.browse.sort.date") }} &ShortUpArrow;</option>
<option value="LENGTH_DESC" {% if request.params.get("sort") == "LENGTH_DESC" %}selected{% endif %}>{{ _("page.browse.sort.length") }} &ShortDownArrow;</option>
<option value="LENGTH_ASC" {% if request.params.get("sort") == "LENGTH_ASC" %}selected{% endif %}>{{ _("page.browse.sort.length") }} &ShortUpArrow;</option>
+ <option value="UPHILL_DESC" {% if request.params.get("sort") == "UPHILL_DESC" %}selected{% endif %}>{{ _("page.browse.sort.uphill") }} &ShortDownArrow;</option>
+ <option value="UPHILL_ASC" {% if request.params.get("sort") == "UPHILL_ASC" %}selected{% endif %}>{{ _("page.browse.sort.uphill") }} &ShortUpArrow;</option>
<option value="DURATION_DESC" {% if request.params.get("sort") == "DURATION_DESC" %}selected{% endif %}>{{ _("page.browse.sort.duration") }} &ShortDownArrow;</option>
<option value="DURATION_ASC" {% if request.params.get("sort") == "DURATION_ASC" %}selected{% endif %}>{{ _("page.browse.sort.duration") }} &ShortUpArrow;</option>
</select>
diff --git a/fietsboek/views/browse.py b/fietsboek/views/browse.py
index e2742ad..490b9b4 100644
--- a/fietsboek/views/browse.py
+++ b/fietsboek/views/browse.py
@@ -90,6 +90,8 @@ class ResultOrder(Enum):
LENGTH_DESC = "length-desc"
DURATION_ASC = "duration-asc"
DURATION_DESC = "duration-desc"
+ UPHILL_ASC = "uphill-asc"
+ UPHILL_DESC = "uphill-desc"
class Filter:
@@ -295,7 +297,7 @@ class FilterCollection(Filter):
:param request: The request.
:return: The parsed filter.
"""
- # pylint: disable=singleton-comparison
+ # pylint: disable=singleton-comparison,too-many-branches
filters: list[Filter] = []
if request.params.get("search-terms"):
term = request.params.get("search-terms").strip()
@@ -340,6 +342,34 @@ class FilterCollection(Filter):
)
)
+ if request.params.get("min-uphill"):
+ min_uphill = _get_int(request, "min-uphill")
+ filters.append(
+ LambdaFilter(
+ lambda query, track: query.where(
+ or_(
+ models.TrackCache.uphill >= min_uphill,
+ models.TrackCache.uphill == None, # noqa: E711
+ )
+ ),
+ lambda track: track.uphill >= min_uphill,
+ )
+ )
+
+ if request.params.get("max-uphill"):
+ max_uphill = _get_int(request, "max-uphill")
+ filters.append(
+ LambdaFilter(
+ lambda query, track: query.where(
+ or_(
+ models.TrackCache.uphill <= max_uphill,
+ models.TrackCache.uphill == None, # noqa: E711
+ )
+ ),
+ lambda track: track.uphill <= max_uphill,
+ )
+ )
+
if request.params.get("min-date"):
min_date = _get_date(request, "min-date")
min_date = datetime.datetime.combine(min_date, datetime.time.min)
@@ -415,6 +445,10 @@ def apply_order(query: Select, track: AliasedTrack, order: ResultOrder) -> Selec
query = query.order_by(models.TrackCache.length.desc())
elif order == ResultOrder.LENGTH_ASC:
query = query.order_by(models.TrackCache.length.asc())
+ elif order == ResultOrder.UPHILL_DESC:
+ query = query.order_by(models.TrackCache.uphill.desc())
+ elif order == ResultOrder.UPHILL_ASC:
+ query = query.order_by(models.TrackCache.uphill.asc())
elif order == ResultOrder.DURATION_DESC:
query = query.order_by(
(models.TrackCache.moving_time + models.TrackCache.stopped_time).desc()