Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit fde4e02

Browse files
#537 - Pass org to associate new users with during bulk upload
1 parent fadbf59 commit fde4e02

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
There are two apps involved - a front end build using create react app and a backend which is a nodejs api
1313

1414
When working locally, you will run the following commands (after setting the necessary environment variables):
15-
15+
1616
- npm install
1717
- cd client && npm install
1818
- cd .. && npm run dev

client/src/components/Upload/index.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Progress from "./Progress";
1010

1111
import config from "../../config";
1212
import api from "../../services/api";
13+
import { getSingleOrg } from "../../services/user-org";
1314

1415
const STATES = {
1516
INITIAL: "INITIAL",
@@ -41,6 +42,7 @@ export default function Upload({ templateId }) {
4142
const data = new FormData();
4243

4344
data.append("upload", file);
45+
data.append("organizationId", getSingleOrg());
4446

4547
setState({
4648
type: STATES.UPLOADING,

docs/swagger.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ paths:
111111
description: "The excel file that needs to be processed"
112112
required: true
113113
type: "file"
114+
- name: "organizationId"
115+
in: "formData"
116+
description: "The organization id to associate any new users with"
117+
required: true
118+
type: "string"
114119
responses:
115120
"200":
116121
description: "Success"
@@ -263,6 +268,9 @@ definitions:
263268
type: "string"
264269
description: "If status is `failed`, then this field will contain information\
265270
\ on why the processing failed"
271+
organizationId:
272+
type: "string"
273+
description: "The organization id to associate new users with"
266274
- $ref: "#/definitions/AuditFields"
267275
Skill:
268276
allOf:

src/controllers/UploadController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const service = require('../services/UploadService')
99
* @param {Object} res the response
1010
*/
1111
async function uploadEntity (req, res) {
12-
const result = await service.create(req.authUser, req.file)
12+
const result = await service.create(req.authUser, req.file, req.body)
1313
res.send(result)
1414
}
1515

src/models/Upload.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const schema = new Schema({
2424
type: String,
2525
required: true
2626
},
27+
organizationId: {
28+
type: String,
29+
required: true
30+
},
2731
created: {
2832
type: String,
2933
required: true

src/services/UploadService.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ getEntity.schema = {
2626

2727
/**
2828
* Create upload.
29-
* @param {Object} data the data to create upload
29+
* @param {Object} upload the file to upload
30+
* @param {String} data the related data of the upload
3031
* @returns {Object} the created upload
3132
*/
32-
async function create (authUser, upload) {
33+
async function create (authUser, upload, data) {
3334
const id = uuid()
3435
// upload file to s3 under uploads folder
3536
const objectKey = await helper.uploadToS3(config.UPLOAD_S3_BUCKET, upload, `uploads/${id}`)
@@ -40,6 +41,7 @@ async function create (authUser, upload) {
4041
objectKey,
4142
status: 'pending',
4243
info: '',
44+
organizationId: data.organizationId,
4345
created: currDate,
4446
updated: currDate,
4547
createdBy: authUser.handle || authUser.sub,
@@ -60,7 +62,10 @@ async function create (authUser, upload) {
6062

6163
create.schema = {
6264
authUser: Joi.object().required(),
63-
upload: Joi.object().required()
65+
upload: Joi.object().required(),
66+
data: Joi.object().keys({
67+
organizationId: Joi.string().required()
68+
})
6469
}
6570

6671
/**

0 commit comments

Comments
 (0)