Skip to content

Commit aabb860

Browse files
committed
(chore) Add importing.md, instructions on using the import libraries
1 parent 5205dd8 commit aabb860

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ Rebuilds the test server, runs rubocop checks, runs the test suite and cleans up
4343
## API Endpoints
4444

4545
A [full list of the API endpoints](endpoints.md) is available in a separate document.
46+
47+
## Importing users
48+
49+
See [this guide](importing.md) to see how to import users and suppliers.

importing.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Import Users / Suppliers
2+
3+
Users and suppliers are imported from a CSV which MUST have the following
4+
fields:
5+
6+
- personname (full name of user)
7+
- email
8+
- suppliername
9+
- frameworkreference (the framework's RM number)
10+
11+
Also, the file needs to encoded in UTF-8 or you'll get errors! To convert an
12+
existing file, run the following on the command line:
13+
14+
`iconv -c -f "US-ASCII" -t "UTF-8" input.csv > output.csv`
15+
16+
The following commands can be run from the Rails console, given a `csv`
17+
variable that contains the contents of a CSV as a string.
18+
19+
# Importing suppliers
20+
21+
Running `require 'supplier_import'; SupplierImport.new(csv).run!` will:
22+
23+
- Create any suppliers that don't already exist in the database
24+
- Assign these suppliers to the correct frameworks (NB: these should already
25+
exist)
26+
27+
# Importing users
28+
29+
First, you'll need to obtain the Auth0 client_id, token and domain. Then you'll
30+
need to set the `csv` variable as above.
31+
32+
Once you have these, run the following from the Rails console.
33+
34+
```ruby
35+
client = Auth0Client.new(client_id: client_id, token: token, domain: domain)
36+
UserImport.new(csv, client).run!
37+
```
38+
39+
You'll see an output like this (one for every row in the CSV)
40+
41+
```
42+
auth0:1234566788,email@example.com,password,John Smith
43+
```
44+
45+
**Make a note of this, as it's the only place where you can see the passwords
46+
generated for each user.**
47+
48+

0 commit comments

Comments
 (0)