Doppia modalità di Registrazione con lista extra utenti

This commit is contained in:
Paolo Arena
2020-01-13 23:52:51 +01:00
parent 8f784df4fa
commit e23a3a792e
25 changed files with 829 additions and 163 deletions

View File

@@ -41,6 +41,8 @@ module.exports = {
LANGADMIN: 'it',
APORTADOR_NONE: '------',
TYPE_PROJECT: 1,
TYPE_TODO: 2,
@@ -480,7 +482,7 @@ module.exports = {
{
$project: {
count: 1,
rows: { $slice: ['$results', params.startRow, params.endRow] }
rows: { $slice: ['$results', params.startRow, params.endRow - params.startRow] }
}
}
);
@@ -513,6 +515,41 @@ module.exports = {
});
},
async DuplicateAllRecords(mythistable, idapporig, idappdest) {
console.log(mythistable.name);
const numrec = await mythistable.findAllIdApp(idappdest).then((arrrec) => {
if (arrrec && arrrec.length > 1) {
return arrrec.length; // Has Already set
} else {
return 0;
}
});
// Before check if exist more than 1 record in the destination,
// if Yes don't copy
if (numrec <= 0) {
return await mythistable.findAllIdApp(idapporig).then(async (arrrec) => {
let num = 0;
for (let ind = 0; ind < arrrec.length; ind++) {
let newrec = new mythistable(arrrec[ind]._doc);
newrec._id = new ObjectID();
newrec.idapp = idappdest;
await newrec.save((err, rec) => {
if (rec) {
num++;
}
});
}
return num;
});
}
},
isBitActive(bit, whattofind) {
return ((bit & whattofind) === whattofind)
@@ -658,4 +695,38 @@ module.exports = {
}
},
extractNameAndSurnameByComplete(name_complete) {
const suffissoCognome = ['Del', 'La', 'De', 'Lo'];
let campi = name_complete.split(" ");
let namesurname = {
name: '',
surname: '',
};
if (campi.length === 2) {
namesurname.name = campi[0];
namesurname.surname = campi[1];
}else if (campi.length === 3) {
if (suffissoCognome.includes(campi[1])) {
namesurname.name = campi[0];
namesurname.surname = campi[1] + " " + campi[2];
} else {
namesurname.name = campi[0] + " " + campi[1];
namesurname.surname = campi[2];
}
}else if (campi.length === 4) {
namesurname.name = campi[0] + " " + campi[1];
namesurname.surname = campi[2] + " " + campi[3];
}else if (campi.length > 4) {
namesurname.name = campi[0] + " " + campi[1];
namesurname.surname = " " + campi[2];
for (const ind = 3; ind < campi.length; ind++) {
namesurname.surname += " " + campi[ind];
}
}
return namesurname
},
};

View File

@@ -6,6 +6,7 @@ module.exports = Object.freeze({
RIS_CODE_EMAIL_ALREADY_VERIFIED: -5,
RIS_CODE_EMAIL_VERIFIED: 1,
RIS_CODE_USER_EXTRALIST_NOTFOUND: -70,
RIS_CODE_USERNAME_ALREADY_EXIST: -60,
RIS_CODE_EMAIL_ALREADY_EXIST: -50,
RIS_CODE_EMAIL_NOT_SENT: -40,