feat: import custom fields via CSV

This commit is contained in:
carla 2026-02-02 11:42:07 +01:00
parent b9dd990f52
commit 3f8797c356
3 changed files with 251 additions and 132 deletions

View file

@ -138,16 +138,24 @@ defmodule MvWeb.GlobalSettingsLive do
<%= if Authorization.can?(@current_user, :create, Mv.Membership.Member) do %>
<.form_section title={gettext("Import Members (CSV)")}>
<div role="note" class="alert alert-info mb-4">
<.icon name="hero-information-circle" class="size-5" aria-hidden="true" />
<div>
<p class="font-semibold">
<p class="font-semibold mb-1">
{gettext("Custom Fields in CSV Import")}
</p>
<p class="text-sm mb-2">
{gettext(
"Custom fields must be created in Mila before importing CSV files with custom field columns"
"Custom fields must be created in Mila before importing. Use the custom field name as the CSV column header. Unknown custom field columns will be ignored with a warning."
)}
</p>
<p class="text-sm mt-2">
{gettext(
"Use the custom field name as the CSV column header (same normalization as member fields applies)"
)}
<p class="text-sm">
<.link
href="#custom_fields"
class="link link-primary"
data-testid="custom-fields-link"
>
{gettext("Manage Custom Fields")}
</.link>
</p>
</div>
</div>
@ -408,8 +416,10 @@ defmodule MvWeb.GlobalSettingsLive do
# Processes CSV upload and starts import
defp process_csv_upload(socket) do
actor = MvWeb.LiveHelpers.current_actor(socket)
with {:ok, content} <- consume_and_read_csv(socket),
{:ok, import_state} <- MemberCSV.prepare(content) do
{:ok, import_state} <- MemberCSV.prepare(content, actor: actor) do
start_import(socket, import_state)
else
{:error, reason} when is_binary(reason) ->