Skip to content

Commit

Permalink
Merge pull request #105 from shikshalokam/master
Browse files Browse the repository at this point in the history
Entity type validation removed
  • Loading branch information
aks30 authored Sep 26, 2022
2 parents 2656d54 + 332c1ca commit 700d68b
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions module/project/templates/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module.exports = class ProjectTemplatesHelper {
let categoryIds = [];
let roleIds = [];
let tasksIds = [];
let entityTypes = [];
// <- Entitytype validation removed {release-5.0.0} - entity generalisation
// let entityTypes = [];

csvData.forEach(template=>{

Expand Down Expand Up @@ -69,10 +70,10 @@ module.exports = class ProjectTemplatesHelper {
parsedData.recommendedFor
);
}

if( parsedData.entityType ) {
entityTypes.push(parsedData.entityType);
}
// <- Entitytype validation removed {release-5.0.0} - entity generalisation
// if( parsedData.entityType ) {
// entityTypes.push(parsedData.entityType);
// }

});

Expand Down Expand Up @@ -126,37 +127,38 @@ module.exports = class ProjectTemplatesHelper {
}
}),{});
}
// <- Entitytype validation removed {release-5.0.0} - entity generalisation
// let entityTypesData = {};

let entityTypesData = {};

if( entityTypes.length > 0 ) {
// if( entityTypes.length > 0 ) {

let entityTypesDocument =
await coreService.entityTypesDocuments();

if( !entityTypesDocument.success ) {
throw {
message : CONSTANTS.apiResponses.ENTITY_TYPES_NOT_FOUND,
status : HTTP_STATUS_CODE['bad_request'].status
}
}

entityTypesData = entityTypesDocument.data.reduce((ac,entityType)=> ({
...ac,
[entityType.name] : {
_id : ObjectId(entityType._id),
name : entityType.name
}
}),{});

}
// let entityTypesDocument =
// await coreService.entityTypesDocuments();

// if( !entityTypesDocument.success ) {
// throw {
// message : CONSTANTS.apiResponses.ENTITY_TYPES_NOT_FOUND,
// status : HTTP_STATUS_CODE['bad_request'].status
// }
// }

// entityTypesData = entityTypesDocument.data.reduce((ac,entityType)=> ({
// ...ac,
// [entityType.name] : {
// _id : ObjectId(entityType._id),
// name : entityType.name
// }
// }),{});

// }

return resolve({
success : true,
data : {
categories : categoriesData,
roles : recommendedFor,
entityTypes : entityTypesData
// <- Entitytype validation removed {release-5.0.0} - entity generalisation
// entityTypes : entityTypesData
}
});

Expand Down Expand Up @@ -216,10 +218,10 @@ module.exports = class ProjectTemplatesHelper {
}

parsedData.recommendedFor = recommendedFor;

if( parsedData.entityType && parsedData.entityType !== "" ) {
parsedData.entityType = csvInformation.entityTypes[parsedData.entityType].name;
}
// <- Entitytype validation removed {release-5.0.0} - entity generalisation
// if( parsedData.entityType && parsedData.entityType !== "" ) {
// parsedData.entityType = csvInformation.entityTypes[parsedData.entityType].name;
// }

let learningResources =
await learningResourcesHelper.extractLearningResourcesFromCsv(parsedData);
Expand Down

0 comments on commit 700d68b

Please sign in to comment.