-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7e359a
commit 97cdd71
Showing
14 changed files
with
187 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,7 @@ form.search-followed-datasets { | |
.align-right { | ||
text-align: right; | ||
} | ||
|
||
form.full-width { | ||
max-width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
apps/transport/lib/transport_web/views/reuser_space_view.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,29 @@ | ||
defmodule TransportWeb.ReuserSpaceView do | ||
use TransportWeb, :view | ||
import TransportWeb.BreadCrumbs, only: [breadcrumbs: 1] | ||
|
||
@doc """ | ||
Is the following dataset eligible for the data sharing pilot for this contact, member | ||
of various organizations? | ||
""" | ||
@spec data_sharing_pilot?(DB.Dataset.t(), DB.Contact.t()) :: boolean() | ||
def data_sharing_pilot?(%DB.Dataset{} = dataset, %DB.Contact{} = contact) do | ||
eligible_dataset_type = dataset.type == "public-transit" | ||
has_dataset_tag = DB.Dataset.has_custom_tag?(dataset, config_value(:dataset_custom_tag)) | ||
member_eligible_org = data_sharing_eligible_org(contact) |> Enum.count() == 1 | ||
|
||
Enum.all?([eligible_dataset_type, has_dataset_tag, member_eligible_org]) | ||
end | ||
|
||
def data_sharing_eligible_org(%DB.Contact{organizations: organizations}) do | ||
data_sharing_eligible_org(organizations) | ||
end | ||
|
||
def data_sharing_eligible_org(organizations) when is_list(organizations) do | ||
Enum.filter(organizations, &(&1.id in config_value(:eligible_datagouv_organization_ids))) | ||
end | ||
|
||
defp config_value(key) do | ||
Application.fetch_env!(:transport, :"data_sharing_pilot_#{key}") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
apps/transport/test/transport_web/views/reuser_space_view_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
defmodule TransportWeb.ReuserSpaceViewTest do | ||
use ExUnit.Case, async: true | ||
import TransportWeb.ReuserSpaceView | ||
|
||
@google_maps_org_id "63fdfe4f4cd1c437ac478323" | ||
|
||
setup do | ||
Ecto.Adapters.SQL.Sandbox.checkout(DB.Repo) | ||
end | ||
|
||
describe "data_sharing_pilot?" do | ||
test "contact is not a member of an eligible organization" do | ||
dataset = %DB.Dataset{type: "public-transit", custom_tags: ["repartage_donnees"]} | ||
contact = %DB.Contact{organizations: []} | ||
refute data_sharing_pilot?(dataset, contact) | ||
end | ||
|
||
test "dataset does not have the required tag" do | ||
dataset = %DB.Dataset{type: "public-transit", custom_tags: []} | ||
contact = %DB.Contact{organizations: [%DB.Organization{id: @google_maps_org_id}]} | ||
refute data_sharing_pilot?(dataset, contact) | ||
end | ||
|
||
test "dataset is eligible for contact" do | ||
dataset = %DB.Dataset{type: "public-transit", custom_tags: ["repartage_donnees"]} | ||
contact = %DB.Contact{organizations: [%DB.Organization{id: @google_maps_org_id}]} | ||
assert data_sharing_pilot?(dataset, contact) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Config | ||
|
||
config :transport, | ||
data_sharing_pilot_dataset_custom_tag: "repartage_donnees", | ||
data_sharing_pilot_eligible_datagouv_organization_ids: [ | ||
# transport.data.gouv.fr | ||
"5abca8d588ee386ee6ece479", | ||
# Google Maps | ||
"63fdfe4f4cd1c437ac478323", | ||
# Transit | ||
"5c9a6477634f4133c7a5fc01", | ||
# Citymapper / Via | ||
"5f7cade93fb405c7d8f6d554" | ||
] |