feat(seeds): shorten the GDPR field to "DSGVO" and seed its join_description
This commit is contained in:
parent
404d524ee1
commit
1f52350562
3 changed files with 66 additions and 16 deletions
|
|
@ -81,9 +81,11 @@ custom_field_configs = [
|
|||
show_in_overview: true
|
||||
},
|
||||
%{
|
||||
name: "Datenschutzerklärung akzeptiert",
|
||||
name: "DSGVO",
|
||||
value_type: :boolean,
|
||||
description: "Angabe, ob Datenschutzerklärung akzeptiert wurde",
|
||||
description: "Angabe, ob die Datenschutzerklärung akzeptiert wurde",
|
||||
join_description:
|
||||
"Ich habe die [Datenschutzerklärung](https://example.org/datenschutz) gelesen und akzeptiere sie.",
|
||||
required: false,
|
||||
show_in_overview: false
|
||||
},
|
||||
|
|
@ -302,11 +304,15 @@ case Membership.get_settings() do
|
|||
ArgumentError -> Map.has_key?(vis, k)
|
||||
end
|
||||
end
|
||||
|
||||
merged =
|
||||
Enum.reduce(default_hidden_in_overview, visibility_config, fn {key, val}, vis ->
|
||||
if has_key.(vis, key), do: vis, else: Map.put(vis, key, val)
|
||||
end)
|
||||
if merged != visibility_config, do: Map.put(acc, :member_field_visibility, merged), else: acc
|
||||
|
||||
if merged != visibility_config,
|
||||
do: Map.put(acc, :member_field_visibility, merged),
|
||||
else: acc
|
||||
end)
|
||||
|
||||
if map_size(updates) > 0 do
|
||||
|
|
@ -332,9 +338,7 @@ IO.puts(
|
|||
" - Fee types: 5 (Standard, Ermäßigt, Unterstützer, Fördermitglied, Probemitgliedschaft)"
|
||||
)
|
||||
|
||||
IO.puts(
|
||||
" - Custom fields: 6 (Geburtsdatum shown in overview; others hidden by default)"
|
||||
)
|
||||
IO.puts(" - Custom fields: 6 (Geburtsdatum shown in overview; others hidden by default)")
|
||||
|
||||
IO.puts(" - Roles: 5 (Mitglied, Vorstand, Kassenwart, Buchhaltung, Admin)")
|
||||
IO.puts(" - Default fee type: Standard (120€ yearly)")
|
||||
|
|
|
|||
|
|
@ -431,15 +431,16 @@ end)
|
|||
all_custom_fields = Ash.read!(Membership.CustomField, actor: admin_user_with_role)
|
||||
find_field = fn name -> Enum.find(all_custom_fields, &(&1.name == name)) end
|
||||
|
||||
# 16 members with 4–6 custom field values each (Geburtsdatum, Datenschutz, SEPA, Rechnungs-E-Mail, IBAN, Stunden)
|
||||
# 16 members with 4–6 custom field values each (Geburtsdatum, DSGVO, SEPA, Rechnungs-E-Mail, IBAN, Stunden)
|
||||
custom_value_assignments =
|
||||
Enum.map(1..16, fn n ->
|
||||
email = "mitglied#{n}@example.de"
|
||||
# Vary birth dates and values per index
|
||||
base_date = Date.add(~D[1970-01-01], 365 * (n + 10) + rem(n * 31, 365))
|
||||
|
||||
values = [
|
||||
{"Geburtsdatum", %{"_union_type" => "date", "_union_value" => base_date}},
|
||||
{"Datenschutzerklärung akzeptiert",
|
||||
{"DSGVO",
|
||||
%{"_union_type" => "boolean", "_union_value" => n in [1, 2, 3, 5, 7, 9, 11, 13, 15]}},
|
||||
{"SEPA-Mandat", %{"_union_type" => "boolean", "_union_value" => rem(n, 3) != 0}},
|
||||
{"Rechnungs-E-Mail",
|
||||
|
|
@ -448,10 +449,12 @@ custom_value_assignments =
|
|||
%{
|
||||
"_union_type" => "string",
|
||||
"_union_value" =>
|
||||
"DE8937040044#{String.pad_leading(to_string(rem(532013000 + n, 1_000_000_000)), 10, "0")}"
|
||||
"DE8937040044#{String.pad_leading(to_string(rem(532_013_000 + n, 1_000_000_000)), 10, "0")}"
|
||||
}},
|
||||
{"Stunden ehrenamtlich", %{"_union_type" => "integer", "_union_value" => 5 + rem(n * 3, 25)}}
|
||||
{"Stunden ehrenamtlich",
|
||||
%{"_union_type" => "integer", "_union_value" => 5 + rem(n * 3, 25)}}
|
||||
]
|
||||
|
||||
# Drop 0–2 fields per member so not all have 6 (still ~80% overall filled)
|
||||
drop_count = rem(n, 3)
|
||||
{email, Enum.take(values, 6 - drop_count)}
|
||||
|
|
@ -502,19 +505,36 @@ case Membership.get_settings() do
|
|||
Membership.update_settings(settings, %{
|
||||
join_form_enabled: true,
|
||||
join_form_field_ids: settings.join_form_field_ids || default_join_form_field_ids,
|
||||
join_form_field_required: settings.join_form_field_required || default_join_form_field_required
|
||||
join_form_field_required:
|
||||
settings.join_form_field_required || default_join_form_field_required
|
||||
})
|
||||
end
|
||||
|
||||
_ ->
|
||||
:ok
|
||||
end
|
||||
|
||||
# Membership applications (join requests) for UI testing: 4 submitted, 1 with extra form_data
|
||||
join_request_configs = [
|
||||
%{email: "antrag1@example.de", first_name: "Sandra", last_name: "Meier", form_data: %{"city" => "Berlin"}},
|
||||
%{
|
||||
email: "antrag1@example.de",
|
||||
first_name: "Sandra",
|
||||
last_name: "Meier",
|
||||
form_data: %{"city" => "Berlin"}
|
||||
},
|
||||
%{email: "antrag2@example.de", first_name: "Thomas", last_name: "Bauer", form_data: %{}},
|
||||
%{email: "antrag3@example.de", first_name: "Julia", last_name: "Krause", form_data: %{"city" => "Hamburg", "notes" => "Interesse an Jugendgruppe"}},
|
||||
%{email: "antrag4@example.de", first_name: "Michael", last_name: "Schmitt", form_data: %{"city" => "München"}}
|
||||
%{
|
||||
email: "antrag3@example.de",
|
||||
first_name: "Julia",
|
||||
last_name: "Krause",
|
||||
form_data: %{"city" => "Hamburg", "notes" => "Interesse an Jugendgruppe"}
|
||||
},
|
||||
%{
|
||||
email: "antrag4@example.de",
|
||||
first_name: "Michael",
|
||||
last_name: "Schmitt",
|
||||
form_data: %{"city" => "München"}
|
||||
}
|
||||
]
|
||||
|
||||
for config <- join_request_configs do
|
||||
|
|
@ -532,8 +552,15 @@ for config <- join_request_configs do
|
|||
end
|
||||
|
||||
IO.puts("✅ Dev seeds completed.")
|
||||
IO.puts(" - Members: 20 with country (mostly Deutschland, 1 Österreich, 1 Schweiz), fee types distributed, 5 with exit date")
|
||||
IO.puts(" - Test users: 4 linked to mitglied1–4 with roles Mitglied, Vorstand, Kassenwart, Buchhaltung")
|
||||
|
||||
IO.puts(
|
||||
" - Members: 20 with country (mostly Deutschland, 1 Österreich, 1 Schweiz), fee types distributed, 5 with exit date"
|
||||
)
|
||||
|
||||
IO.puts(
|
||||
" - Test users: 4 linked to mitglied1–4 with roles Mitglied, Vorstand, Kassenwart, Buchhaltung"
|
||||
)
|
||||
|
||||
IO.puts(" - Groups: Vorstand, Jugend, Newsletter (with assignments)")
|
||||
IO.puts(" - Custom field values: ~80% filled (16 members, 4–6 fields each)")
|
||||
IO.puts(" - Join form enabled; 4 membership applications (join requests) for UI testing")
|
||||
|
|
|
|||
|
|
@ -123,5 +123,24 @@ defmodule Mv.SeedsTest do
|
|||
assert mitglied.permission_set_name == "own_data",
|
||||
"Mitglied role must have own_data permission set"
|
||||
end
|
||||
|
||||
test "bootstrap seeds create the DSGVO custom field and not the old long name", %{
|
||||
actor: actor
|
||||
} do
|
||||
{:ok, custom_fields} = Ash.read(Mv.Membership.CustomField, actor: actor)
|
||||
names = Enum.map(custom_fields, & &1.name)
|
||||
|
||||
assert "DSGVO" in names, "Bootstrap seeds must create a custom field named DSGVO"
|
||||
|
||||
refute "Datenschutzerklärung akzeptiert" in names,
|
||||
"Old long field name must no longer be seeded"
|
||||
|
||||
dsgvo = Enum.find(custom_fields, &(&1.name == "DSGVO"))
|
||||
assert dsgvo.value_type == :boolean
|
||||
|
||||
assert dsgvo.join_description ==
|
||||
"Ich habe die [Datenschutzerklärung](https://example.org/datenschutz) gelesen und akzeptiere sie.",
|
||||
"DSGVO field must be seeded with a default join_description"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue