Skip to content

Commit

Permalink
Datasets: label experimental
Browse files Browse the repository at this point in the history
Fixes #4275.
  • Loading branch information
ptitfred committed Oct 30, 2024
1 parent ba686e6 commit bdd3a1c
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/transport/lib/db/dataset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,14 @@ defmodule DB.Dataset do
def full_logo(%__MODULE__{full_logo: full_logo, custom_full_logo: custom_full_logo}),
do: custom_full_logo || full_logo

@doc """
iex> experimental?(%DB.Dataset{custom_tags: ["experimental", "foo"]})
true
iex> experimental?(%DB.Dataset{custom_tags: ["foo"]})
false
"""
def experimental?(%__MODULE__{} = dataset), do: has_custom_tag?(dataset, @experimental_tag)

def reject_experimental_datasets(queryable) do
queryable
|> where([d], @experimental_tag not in d.tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ defmodule TransportWeb.CustomTagsLive do
%{
name: "authentification_requise",
doc: "Indique sur la page du JDD qu'il est nécessaire de s'authentifier pour accéder aux données."
},
%{
name: "experimental",
doc: "Ajoute sur la page du JDD une bannière indiquant que le jeu est expérimental"
}
]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
"The producer requires authentication to access the data. Consequently, some features on transport.data.gouv.fr, such as data availability, validations, and metadata, are unavailable for this dataset. Please follow the producer's instructions to gain access to the data."
) %>
</p>
<p :if={experimental?(@dataset)} class="notification mt-0">
ℹ️ <%= dgettext(
"page-dataset-details",
"This unofficial dataset is provided experimentally. Do not use it for travel information purpose."
) %>
</p>
1 change: 1 addition & 0 deletions apps/transport/lib/transport_web/views/dataset_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule TransportWeb.DatasetView do
# ~H expects a variable named `assigns`, so wrapping the calls to `~H` inside
# a helper function would be cleaner and more future-proof to avoid conflicts at some point.
import Phoenix.Component, only: [sigil_H: 2, live_render: 3]
import DB.Dataset, only: [experimental?: 1]
import DB.MultiValidation, only: [get_metadata_info: 2, get_metadata_info: 3]
alias Shared.DateTimeDisplay
alias Transport.Validators.GTFSTransport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,3 +717,7 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Data under the responsibility of"
msgstr ""

#, elixir-autogen, elixir-format
msgid "This unofficial dataset is provided experimentally. Do not use it for travel information purpose."
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -717,3 +717,7 @@ msgstr "Le producteur requiert une authentification pour accéder aux données.
#, elixir-autogen, elixir-format
msgid "Data under the responsibility of"
msgstr "Données sous la responsabilité de"

#, elixir-autogen, elixir-format
msgid "This unofficial dataset is provided experimentally. Do not use it for travel information purpose."
msgstr "Ce jeu de données non officiel est publié à titre expérimental. Veuillez à ne pas le réutiliser à des fins d'information voyageur."
4 changes: 4 additions & 0 deletions apps/transport/priv/gettext/page-dataset-details.pot
Original file line number Diff line number Diff line change
Expand Up @@ -717,3 +717,7 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Data under the responsibility of"
msgstr ""

#, elixir-autogen, elixir-format
msgid "This unofficial dataset is provided experimentally. Do not use it for travel information purpose."
msgstr ""

0 comments on commit bdd3a1c

Please sign in to comment.