- Iscrizione Conacreis
- Ordini - Carrello
This commit is contained in:
@@ -19,8 +19,6 @@ const { ObjectID } = require('mongodb');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
const queryclass = require('../classes/queryclass');
|
||||
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
mongoose.level = "F";
|
||||
@@ -254,21 +252,30 @@ const UserSchema = new mongoose.Schema({
|
||||
sex: {
|
||||
type: Number,
|
||||
},
|
||||
chisei: {
|
||||
motivazioni: {
|
||||
type: String
|
||||
},
|
||||
iltuoimpegno: {
|
||||
competenze_professionalita: {
|
||||
type: String
|
||||
},
|
||||
come_aiutare: {
|
||||
cosa_offrire: {
|
||||
type: String
|
||||
},
|
||||
socio: {
|
||||
cosa_ricevere: {
|
||||
type: String
|
||||
},
|
||||
altre_comunicazioni: {
|
||||
type: Boolean,
|
||||
},
|
||||
come_ci_hai_conosciuto: {
|
||||
type: Boolean,
|
||||
},
|
||||
socioresidente: {
|
||||
type: Boolean,
|
||||
},
|
||||
consiglio: {
|
||||
type: Boolean,
|
||||
},
|
||||
myshares: [{
|
||||
description: { type: String },
|
||||
rating: { type: Number },
|
||||
@@ -373,9 +380,9 @@ UserSchema.statics.isManager = function (perm) {
|
||||
}
|
||||
};
|
||||
|
||||
UserSchema.statics.isTraduttrici = function (perm) {
|
||||
UserSchema.statics.isEditor = function (perm) {
|
||||
try {
|
||||
return ((perm & shared_consts.Permissions.Traduttrici) === shared_consts.Permissions.Traduttrici);
|
||||
return ((perm & shared_consts.Permissions.Editor) === shared_consts.Permissions.Editor);
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
@@ -721,6 +728,27 @@ UserSchema.statics.isUserResidente = async function (idapp, username) {
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.isUserConsiglio = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
const myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
};
|
||||
|
||||
const myrec = await User.findOne(myquery);
|
||||
if (!!myrec) {
|
||||
return myrec.profile.consiglio;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.isUserVisuProjects = async function (idapp, username) {
|
||||
@@ -1209,6 +1237,21 @@ UserSchema.statics.getNameSurnameByUsername = async function (idapp, username) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getNameSurnameById = async function (idapp, userId) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
_id: userId,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
|
||||
}, { name: 1, surname: 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec) ? `${rec.name} ${rec.surname}` : '';
|
||||
}).catch((e) => {
|
||||
console.error('getNameSurnameById', e);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getSmallRecByIndOrder = async function (idapp, ind_order) {
|
||||
|
||||
try {
|
||||
@@ -1943,7 +1986,7 @@ UserSchema.statics.getUsersResidenti = async function (idapp) {
|
||||
'profile.socioresidente': { $exists: true, $eq: true }
|
||||
};
|
||||
|
||||
return await User.find(myfind, {username: 1, name: 1, surname: 1});
|
||||
return await User.find(myfind, { username: 1, name: 1, surname: 1 });
|
||||
};
|
||||
|
||||
UserSchema.statics.getSaw_and_Accepted = async function (idapp) {
|
||||
@@ -2057,7 +2100,10 @@ UserSchema.statics.getUsersRegDaily = function (idapp, nrec) {
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
|
||||
$group: {
|
||||
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } },
|
||||
count: { $sum: 1 }
|
||||
}
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
@@ -2076,7 +2122,10 @@ UserSchema.statics.getUsersRegWeekly = function (idapp, nrec) {
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%U", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
|
||||
$group: {
|
||||
_id: { $dateToString: { format: "%Y-%U", date: "$date_reg", timezone: 'Europe/Rome' } },
|
||||
count: { $sum: 1 }
|
||||
}
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
@@ -2097,7 +2146,10 @@ UserSchema.statics.getnumRegNDays = function (idapp, nrec) {
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
|
||||
$group: {
|
||||
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } },
|
||||
count: { $sum: 1 }
|
||||
}
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
|
||||
Reference in New Issue
Block a user