aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fietsboek/models/user.py10
-rw-r--r--fietsboek/templates/details.jinja24
-rw-r--r--fietsboek/templates/edit.jinja22
-rw-r--r--fietsboek/templates/edit_form.jinja29
-rw-r--r--fietsboek/templates/finish_upload.jinja22
5 files changed, 23 insertions, 4 deletions
diff --git a/fietsboek/models/user.py b/fietsboek/models/user.py
index a972f8e..d4b5491 100644
--- a/fietsboek/models/user.py
+++ b/fietsboek/models/user.py
@@ -3,6 +3,7 @@ import datetime
import enum
import uuid
import secrets
+from functools import reduce
from sqlalchemy import (
Column,
@@ -303,6 +304,15 @@ class User(Base):
stmt = friends_assoc.insert().values(user_1_id=self.id, user_2_id=friend.id)
object_session(self).execute(stmt)
+ def autocomplete_tags(self):
+ """Returns all tags the user has ever used, suitable for autocompletion
+ lists.
+
+ :return: All tags of the user.
+ :rtype: ~collections.abc.Iterator[str]
+ """
+ return reduce(lambda acc, track: acc | track.text_tags(), self.tracks, set())
+
Index('idx_users_email', User.email, unique=True)
diff --git a/fietsboek/templates/details.jinja2 b/fietsboek/templates/details.jinja2
index 4d67f07..2ff492c 100644
--- a/fietsboek/templates/details.jinja2
+++ b/fietsboek/templates/details.jinja2
@@ -56,7 +56,7 @@
{% endif %}
- {% if is_organic %}
+ {% if show_organic %}
<ul>
<li>{{ track.owner.name }}</li>
{% for user in track.tagged_people %}
@@ -65,9 +65,11 @@
</ul>
{% endif %}
+ {% if track.tags %}
<p>
{{ _("page.details.tags") }}: {% for tag in track.tags %}<span class="badge rounded-pill bg-info text-dark">{{ tag.tag }}</span> {% endfor %}
</p>
+ {% endif %}
{% if 'secret' in request.GET %}
{% set gpx_url = request.route_path('gpx', track_id=track.id, _query=[('secret', request.GET['secret'])]) %}
diff --git a/fietsboek/templates/edit.jinja2 b/fietsboek/templates/edit.jinja2
index 91c44e3..a9a4221 100644
--- a/fietsboek/templates/edit.jinja2
+++ b/fietsboek/templates/edit.jinja2
@@ -1,6 +1,6 @@
{% extends "layout.jinja2" %}
-{% import "edit_form.jinja2" as edit_form %}
+{% import "edit_form.jinja2" as edit_form with context %}
{% import "util.jinja2" as util with context %}
{% block content %}
diff --git a/fietsboek/templates/edit_form.jinja2 b/fietsboek/templates/edit_form.jinja2
index 34c34c3..f7dd007 100644
--- a/fietsboek/templates/edit_form.jinja2
+++ b/fietsboek/templates/edit_form.jinja2
@@ -37,7 +37,14 @@
</div>
<div class="row">
<div class="col-lg-3">
- <input type="text" id="new-tag" class="form-control">
+ <input type="text" id="new-tag" class="form-control" list="user-tags">
+ <datalist id="user-tags">
+ {% if request.identity %}
+ {% for tag in request.identity.autocomplete_tags() | sort %}
+ <option value="{{ tag }}">
+ {% endfor %}
+ {% endif %}
+ </datalist>
</div>
<div class="col-lg-3">
<button type="button" class="btn btn-primary" id="add-tag-btn">{{ _("page.track.form.add_tag") }}</buttton>
diff --git a/fietsboek/templates/finish_upload.jinja2 b/fietsboek/templates/finish_upload.jinja2
index 0d32392..9ee4576 100644
--- a/fietsboek/templates/finish_upload.jinja2
+++ b/fietsboek/templates/finish_upload.jinja2
@@ -1,6 +1,6 @@
{% extends "layout.jinja2" %}
-{% import "edit_form.jinja2" as edit_form %}
+{% import "edit_form.jinja2" as edit_form with context %}
{% import "util.jinja2" as util with context %}
{% block content %}