aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fietsboek/templates/edit_form.jinja22
-rw-r--r--fietsboek/transformers/__init__.py23
2 files changed, 21 insertions, 4 deletions
diff --git a/fietsboek/templates/edit_form.jinja2 b/fietsboek/templates/edit_form.jinja2
index 67c01c9..491db98 100644
--- a/fietsboek/templates/edit_form.jinja2
+++ b/fietsboek/templates/edit_form.jinja2
@@ -156,6 +156,8 @@
<div id="transformer-{{ loop.index}}" class="accordion-collapse collapse" aria-labelledby="transformer-heading-{{ loop.index }}">
<div class="accordion-body">
{% set params = track.transformer_params_for(transformer.identifier()) %}
+ <!-- Short transformer description -->
+ <p>{{ _(transformer.description()) }}</p>
<!-- Checkbox to enable the transformer -->
<div class="form-check">
diff --git a/fietsboek/transformers/__init__.py b/fietsboek/transformers/__init__.py
index b4ed532..1a9517e 100644
--- a/fietsboek/transformers/__init__.py
+++ b/fietsboek/transformers/__init__.py
@@ -11,6 +11,7 @@ function to load and apply transformers.
from abc import ABC, abstractmethod
from collections.abc import Mapping
+from typing import TypeVar
from gpxpy.gpx import GPX
from markupsafe import Markup
@@ -19,6 +20,8 @@ from pyramid.i18n import TranslationString
_ = TranslationString
+T = TypeVar("T", bound="Transformer")
+
class Parameters(BaseModel):
"""Parameters for a transformer.
@@ -54,7 +57,7 @@ class Transformer(ABC):
@classmethod
@abstractmethod
- def identifier(cls) -> str:
+ def identifier(cls: type[T]) -> str:
"""Returns a string identifier for this transformer.
This identifier is used when serializing/deserializing the filters.
@@ -64,7 +67,7 @@ class Transformer(ABC):
@classmethod
@abstractmethod
- def name(cls) -> TranslationString:
+ def name(cls: type[T]) -> TranslationString:
"""The human-readable name of this transformer, as a translateable string.
:return: The transformer's name.
@@ -72,7 +75,15 @@ class Transformer(ABC):
@classmethod
@abstractmethod
- def parameter_model(cls) -> type[Parameters]:
+ def description(cls: type[T]) -> TranslationString:
+ """A short description of what this transformer does.
+
+ :return: The transformer's description.
+ """
+
+ @classmethod
+ @abstractmethod
+ def parameter_model(cls: type[T]) -> type[Parameters]:
"""Returns the parameter model that this transformer expects.
:return: The parameter model class.
@@ -114,7 +125,11 @@ class FixNullElevation(Transformer):
@classmethod
def name(cls) -> TranslationString:
- return _("transformers.fix-null-elevation")
+ return _("transformers.fix-null-elevation.title")
+
+ @classmethod
+ def description(cls) -> TranslationString:
+ return _("transformers.fix-null-elevation.description")
@classmethod
def parameter_model(cls) -> type[Parameters]: