|
| 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