Aggiunto comune, + filtro regione e provincia

aggiunto Visibilità (da fare check)
This commit is contained in:
Paolo Arena
2022-09-18 20:17:24 +02:00
parent 9d072d4d0d
commit bcb276518f
12 changed files with 127 additions and 19 deletions

View File

@@ -53,6 +53,9 @@ const AccountSchema = new Schema({
saldo: {
type: Number,
},
totTransato: {
type: Number,
},
deleted: {
type: Boolean,
default: false,
@@ -116,6 +119,10 @@ AccountSchema.methods.addtoSaldo = async function(amount) {
if (account) {
account.saldo = account.saldo + amount;
if (!account.totTransato) {
account.totTransato = 0;
}
account.totTransato += Math.abs(amount);
account.date_updated = new Date();
return await account.save();
}

View File

@@ -40,6 +40,13 @@ const CircuitSchema = new Schema({
subname: {
type: String,
},
idCity: [
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
},
longdescr: {
type: String,
},
@@ -220,6 +227,8 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
fido_scoperto_default: 1,
qta_max_default: 1,
symbol: 1,
idCity: 1,
pub_to_share: 1,
color: 1,
abbrev: 1,
data_costituz: 1,
@@ -227,6 +236,7 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
admins: 1,
req_users: 1,
refused_users: 1,
'mycities': 1,
};
};
@@ -255,6 +265,8 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
qta_max_default: 1,
symbol: 1,
color: 1,
idCity: 1,
pub_to_share: 1,
abbrev: 1,
data_costituz: 1,
photos: 1,
@@ -264,6 +276,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
date_updated: 1,
req_users: 1,
refused_users: 1,
'mycities': 1,
};
};
@@ -396,7 +409,11 @@ CircuitSchema.statics.getUserCircuits = async function(idapp, username) {
try {
let aggr1 = [
{
$match: {idapp, username},
$match: {idapp, username,
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
},
},
{
$lookup: {
@@ -510,6 +527,9 @@ CircuitSchema.statics.sendCoins = async function(onlycheck, idapp, usernameOrig,
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
extrarec.saldoOrig = accountorigTable.saldo;
extrarec.saldoDest = accountdestTable.saldo;
} else {
console.log('NON Inviate Monete da', usernameOrig, extrarec.dest, myqty, extrarec.causal);
}

View File

@@ -88,6 +88,9 @@ MovementSchema.statics.executeQueryTable = function(idapp, params) {
MovementSchema.statics.addMov = async function(idapp, accountFromIdTable, accountToIdTable, amount, causal) {
try {
// Only positive values
amount = Math.abs(amount);
let mymov = Movement(
{
_id: new ObjectID().toString(),

View File

@@ -171,6 +171,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'mycities': 1,
reported: 1,
},
},

View File

@@ -51,6 +51,10 @@ const sendNotifSchema = new Schema({
datenotif: {
type: Date,
},
date_created: {
type: Date,
default: Date.now,
},
status: {
type: Number,
default: 0,
@@ -144,7 +148,7 @@ sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function(username, la
};
sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
const numchars = 80;
let newdescr = '';
@@ -321,7 +325,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
}
tag = 'removeadmincircuit';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ) {
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', recnotif.paramsObj.username_action, recnotif.paramsObj.extrarec.qty.toString(),
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', tools.getAhref(recnotif.paramsObj.username_action, await tools.getLinkUserTelegram(recnotif.idapp, recnotif.paramsObj.username_action)), recnotif.paramsObj.extrarec.qty.toString(),
recnotif.paramsObj.extrarec.symbol);
tag = 'sendcoin';
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
@@ -332,12 +336,15 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED) {
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
recnotif.paramsObj.username_action);
recnotif.paramsObj.username_action) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest,
recnotif.paramsObj.extrarec.symbol
);
tag = 'sendcoin';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT) {
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_TO_ME', recnotif.paramsObj.extrarec.qty.toString(),
recnotif.paramsObj.extrarec.symbol,
recnotif.paramsObj.extrarec.dest);
recnotif.paramsObj.extrarec.dest) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoOrig,
recnotif.paramsObj.extrarec.symbol);
tag = 'sendcoin';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED) {
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
@@ -346,7 +353,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT) {
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED_TO_ME', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
recnotif.paramsObj.extrarec.dest);
tag = 'sendcoin';
tag = 'sendcoin';ac
}
}
@@ -451,7 +458,7 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
try {
if (!myrecnotif.openUrl) {
// If not exist, then I set openUrl and description
myrecnotif = this.getDescrAndLinkByRecNotif(myrecnotif);
myrecnotif = await this.getDescrAndLinkByRecNotif(myrecnotif);
}
let newstatus = 0;
@@ -523,8 +530,9 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
if (newstatus) {
const fields_to_update = {
status: newstatus,
read: true,
read: false,
descr: myrecnotif.descr,
datenotif: new Date(),
};
let query = {
@@ -753,7 +761,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
myrecnotifpass.myrectableorig = myrectableorig;
}
myrecnotifpass = this.getDescrAndLinkByRecNotif(myrecnotifpass);
myrecnotifpass = await this.getDescrAndLinkByRecNotif(myrecnotifpass);
delete myrecnotifpass._doc['_id'];
for (const user of userlist) {

View File

@@ -2642,6 +2642,16 @@ UserSchema.statics.SetTelegramIdSuccess = async function(idapp, id, teleg_id) {
};
UserSchema.statics.getUsernameTelegram = async function(idapp, username) {
const User = this;
return await User.findOne({idapp, username}, {'profile.username_telegram': 1}).lean().then((ris) => {
if (ris)
return ris.profile.username_telegram
else
return '';
});
};
UserSchema.statics.setUsernameTelegram = async function(
idapp, id, username_telegram, firstname_telegram, lastname_telegram) {
const User = this;