Mostrare il Bene, Servizio, solo ai Propri Gruppi.

Nella pagina profilo, i "Gruppi" personali non si vedevano !
This commit is contained in:
Paolo Arena
2022-06-16 20:34:42 +02:00
parent d8aa8e546e
commit c3b0a1f417
17 changed files with 170 additions and 52 deletions

View File

@@ -14,7 +14,7 @@ mongoose.plugin(schema => {
});
const CircuitSchema = new Schema({
_id: {
Num: {
type: Number,
unique: true,
},
@@ -116,15 +116,15 @@ CircuitSchema.statics.findAllIdApp = async function(idapp) {
CircuitSchema.pre('save', async function(next) {
if (this.isNew) {
const myrec = await Circuit.findOne().limit(1).sort({_id: -1});
const myrec = await Circuit.findOne().limit(1).sort({Num: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
if (myrec._doc.Num === 0)
this.Num = 1;
else
this._id = myrec._doc._id + 1;
this.Num = myrec._doc.Num + 1;
} else {
this._id = 1;
this.Num = 1;
}
}

View File

@@ -134,7 +134,7 @@ MyBachecaSchema.statics.getFieldsLastForSearch = function() {
};
MyBachecaSchema.statics.executeQueryTable = function(idapp, params) {
MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -154,6 +154,7 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params) {
dateTimeStart: 1,
dateTimeEnd: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
@@ -168,6 +169,7 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params) {
name: 1,
surname: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -175,7 +177,7 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params) {
params = {...params, ...otherparams};
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
@@ -243,6 +245,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -259,6 +262,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -297,6 +301,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -313,6 +318,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -351,6 +357,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -367,6 +374,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -405,6 +413,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -421,6 +430,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -459,6 +469,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -475,6 +486,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},

View File

@@ -264,9 +264,9 @@ MyEventSchema.statics.getFieldsForSearch = function() {
{field: 'details', type: tools.FieldType.string}];
};
MyEventSchema.statics.executeQueryTable = function(idapp, params) {
MyEventSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
if (tools.INITDB_FIRSTIME) {

View File

@@ -42,6 +42,9 @@ const MyGoodSchema = new Schema({
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
},
numLevel: {
type: Number,
default: 0,
@@ -132,7 +135,7 @@ MyGoodSchema.statics.getFieldsLastForSearch = function() {
};
MyGoodSchema.statics.executeQueryTable = function(idapp, params) {
MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -150,6 +153,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params) {
idStatusGood: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
otherfilters: 1,
@@ -165,6 +169,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params) {
name: 1,
surname: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -172,7 +177,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params) {
params = {...params, ...otherparams};
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
@@ -238,6 +243,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -255,6 +261,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -291,6 +298,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -308,6 +316,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -344,6 +353,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -361,6 +371,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -397,6 +408,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -414,6 +426,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -450,6 +463,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -467,6 +481,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},

View File

@@ -106,7 +106,7 @@ MyGroupSchema.statics.getFieldsForSearch = function() {
return [{field: 'descr', type: tools.FieldType.string}];
};
MyGroupSchema.statics.executeQueryTable = function(idapp, params) {
MyGroupSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
const { User } = require('./user');
@@ -119,7 +119,7 @@ MyGroupSchema.statics.executeQueryTable = function(idapp, params) {
}
}
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyGroupSchema.pre('save', async function(next) {
@@ -149,6 +149,18 @@ MyGroupSchema.statics.findAllIdApp = async function(idapp) {
return await MyGroup.find(myfind);
};
MyGroupSchema.statics.findAllGroups = async function(idapp) {
const whatToShow = this.getWhatToShow(idapp, '');
return await MyGroup.find({
idapp,
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
}, whatToShow);
};
// Rimuovo la Richiesta del Gruppo
MyGroupSchema.statics.removeReqGroup = async function(idapp, username, groupnameDest) {

View File

@@ -67,6 +67,9 @@ const MyHospSchema = new Schema({
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
},
descr: {
type: String,
},
@@ -134,7 +137,7 @@ MyHospSchema.statics.getFieldsLastForSearch = function() {
];
};
MyHospSchema.statics.executeQueryTable = function(idapp, params) {
MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -154,6 +157,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -165,6 +169,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params) {
name: 1,
surname: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -172,7 +177,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params) {
params = {...params, ...otherparams};
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyHospSchema.statics.getMyRecById = function(idapp, id) {
@@ -238,6 +243,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -251,6 +257,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -287,6 +294,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -300,6 +308,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -336,6 +345,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -349,6 +359,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -385,6 +396,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -398,6 +410,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -434,6 +447,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -447,6 +461,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},

View File

@@ -125,9 +125,9 @@ MyPageSchema.statics.getFieldsForSearch = function () {
{ field: 'content', type: tools.FieldType.string }]
};
MyPageSchema.statics.executeQueryTable = function (idapp, params) {
MyPageSchema.statics.executeQueryTable = function (idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyPageSchema.statics.findAllIdApp = async function (idapp) {

View File

@@ -48,6 +48,9 @@ const MySkillSchema = new Schema({
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
},
numLevel: {
type: Number,
default: 0,
@@ -134,8 +137,7 @@ MySkillSchema.statics.getFieldsLastForSearch = function() {
];
};
MySkillSchema.statics.executeQueryTable = function(idapp, params) {
MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -153,6 +155,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
idStatusSkill: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
@@ -167,6 +170,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
name: 1,
surname: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -174,7 +178,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
params = {...params, ...otherparams};
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
@@ -240,6 +244,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -256,6 +261,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -292,6 +298,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -308,6 +315,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -344,6 +352,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -360,6 +369,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -398,6 +408,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -414,6 +425,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -450,6 +462,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -466,6 +479,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -483,7 +497,6 @@ MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
};
const MySkill = mongoose.model('MySkill', MySkillSchema);
module.exports = {MySkill};

View File

@@ -1345,6 +1345,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
verified_email: 1,
verified_by_aportador: 1,
'profile.nationality': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
'profile.biografia': 1,
'profile.teleg_id': 1,
@@ -1378,6 +1379,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
verified_by_aportador: 1,
notask_verif: 1,
'profile.nationality': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
'profile.biografia': 1,
'profile.teleg_id': 1,
@@ -1794,6 +1796,7 @@ function getWhatToShow(idapp, username) {
verified_by_aportador: 1,
notask_verif: 1,
'profile.nationality': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
'profile.biografia': 1,
'profile.username_telegram': 1,