The Schools database is provided to simplify the creation of new School Organisations on the Voluntarily Platform. When a new School Ambassador is invited onto the platform Invite someone to setup a new Organisation They can pick the school from a drop down list. The data for this list is provided by an API call `api/schools`
which in turn is provided by a database collection `schoollookups`
The schema for this collection is
const schoolLookUpSchema = new Schema({ schoolId: { type: Number, required: true }, name: { type: String }, telephone: { type: String }, emailDomain: { type: String, required: true }, contactName: { type: String }, contactEmail: { type: String }, website: String, address: String, schoolType: { type: String, enum: Object.values(SCHOOL_TYPES), required: true }, decile: Number })
Instructions
If the dropdown of schools has no data, or the collection needs to be refreshed with new data then an admin must run a command line script to update the collection from an external NZ schools database API.
For Developers
node --http-parser=legacy x/db/import-schools.js
For Production Cloud Servers
set MONGODB_URI
environment variable to the selected database.
e.g
`MONGODB_URI=mongodb+srv://vly-client:XXXXXXXXXXXXXX@cluster0-kwmsu.mongodb.net/vly2-alpha?retryWrites=true`
and then run
node --http-parser=legacy x/db/import-schools.js
Output is
Inserted 82 schools Inserted 176 schools Inserted 266 schools Inserted 357 schools Inserted 454 schools Inserted 545 schools Inserted 634 schools Inserted 724 schools Inserted 813 schools Inserted 906 schools Inserted 997 schools Inserted 1088 schools Inserted 1183 schools Inserted 1274 schools Inserted 1365 schools Inserted 1453 schools Inserted 1536 schools Inserted 1631 schools Inserted 1724 schools Inserted 1817 schools Inserted 1900 schools Inserted 1983 schools Inserted 2069 schools Inserted 2159 schools Inserted 2250 schools Inserted 2302 schools Done
Testing the school invite process
Import schools, run these commands to get your local docker environment ready:
# Invite school process 1. Import schools, run these commands to get your local docker environment ready: # in your normal terminal from the voluntarily project root x/docker-dev/npm.sh ci x/docker-dev/up.sh x/docker-dev/console.sh # you will be prompted to select a container here, press 1<ENTER> to use the web container # this will open a console inside the web container, run this command now: node --http-parser=legacy x/db/import-schools.js exit # this will close the web container console and take you back to your normal terminal (which you don't need for the rest of these steps) 2. Open browser and go to local Voluntarily app (http://localhost:3122) 3. Login with an admin account 4. Go to http://localhost:3122/admin/invite-school 5. Fill out the invite form 6. Logout of Voluntarily with your admin account 7. Open mailhog (http://localhost:8025) 8. You should see an email with the subject "[DEVELOPMENT] Your school has been invited to Voluntarily" 9. Click the button "Sign up and activate your school" in the email 10. This should take you to the Auth0 login/sign up screen 11. Either login with an existing account or sign up 12. Once logged in, you should be redirected to your Voluntarily dashboard with the school related goal cards displayed. Also, there should have been a new organisation created (based on the school you selected on the invite school form) which your currently logged in account is now an org admin of.
0 Comments