Skip to main content

laterite_admin/import/
mod.rs

1//! Bulk import: a file's rows written through a resource's form, with a report.
2//!
3//! A resource declaring `import: true` gets the pages under its own path: a
4//! file taken in, its columns shown beside the form's fields with a match
5//! proposed for each, a check that writes nothing, then the run and its report
6//! as it fills. Each row is written the way the form's own submit would: the
7//! same rules, field types, listeners, persister and audit entry, one commit a
8//! row. The run is detached from the request that started it and keeps its
9//! counts and notes in a table the report polls, so a long file finishes
10//! whether or not the browser waits, and a refused row is a line in the report,
11//! never a stopped import. From code, [`start`] and [`find`] do the same
12//! without the pages.
13
14pub(crate) mod file;
15pub(crate) mod migrations;
16mod pages;
17pub mod run;
18pub mod schema;
19mod store;
20
21pub use run::{
22    find, start, Duplicates, Match, Note, NoteKind, OnMatch, Run, RunError, RunSpec, Status,
23};
24
25pub(crate) use pages::ImportFeature;
26
27use laterite_core::{MigrationSet, Module, ModuleId};
28
29/// The name of the disk uploaded files are stored on. The application may
30/// register a `laterite_media::DiskReg` under it; without one, the files go to
31/// `private` under the configured storage directory.
32pub const DISK: &str = "private";
33
34/// The `laterite.import` module: the run table. Built in.
35pub struct ImportModule;
36
37impl Module for ImportModule {
38    fn id(&self) -> ModuleId {
39        ModuleId::new(migrations::MODULE_ID)
40    }
41
42    fn migrations(&self) -> MigrationSet {
43        migrations::migrations()
44    }
45}