Export Movements to CSV File
fix Visibility for a Circuit
This commit is contained in:
@@ -45,8 +45,13 @@ const CircuitSchema = new Schema({
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
visibility: [
|
||||
{
|
||||
type: Number,
|
||||
},
|
||||
],
|
||||
longdescr: {
|
||||
type: String,
|
||||
},
|
||||
@@ -202,9 +207,9 @@ CircuitSchema.statics.getFieldsForSearch = function() {
|
||||
{field: 'descr', type: tools.FieldType.string}];
|
||||
};
|
||||
|
||||
CircuitSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
CircuitSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
@@ -229,6 +234,7 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
symbol: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
visibility: 1,
|
||||
color: 1,
|
||||
abbrev: 1,
|
||||
data_costituz: 1,
|
||||
@@ -267,6 +273,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
color: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
visibility: 1,
|
||||
abbrev: 1,
|
||||
data_costituz: 1,
|
||||
photos: 1,
|
||||
|
||||
@@ -43,7 +43,7 @@ const MyGoodSchema = new Schema({
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
|
||||
@@ -68,7 +68,7 @@ const MyHospSchema = new Schema({
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
|
||||
@@ -49,7 +49,7 @@ const MySkillSchema = new Schema({
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
|
||||
@@ -417,7 +417,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||
circuitnameDest = myrec ? myrec.name : '';
|
||||
setnotif = true;
|
||||
setnotif = (myrec.visibility === 0); // Not send a notification to others if the Circuit is HIDDEN or PRIVATE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -731,17 +731,17 @@ module.exports = {
|
||||
// Pass object into sendNotification
|
||||
return webpush.sendNotification(subscription._doc, JSON.stringify(payload),
|
||||
pushOptions).
|
||||
catch(err => {
|
||||
catch((err) => {
|
||||
if (err.statusCode === 410) {
|
||||
// Gone: is not valid anymore (Expired probably!), so I have to delete from my db
|
||||
return Subscription.findOneAndRemove({_id: subscription._id});
|
||||
} else {
|
||||
console.log('Subscription is no longer valid: ', err);
|
||||
}
|
||||
}).then((ris) => {
|
||||
|
||||
}).
|
||||
then(ris => {
|
||||
console.log('sendNotification', ris);
|
||||
}).
|
||||
// console.log('sendNotification', ris);
|
||||
catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
@@ -1157,17 +1157,19 @@ module.exports = {
|
||||
|
||||
let recnotif = null;
|
||||
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||
recnotif = await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT, idapp, extrarec.dest, usernameOrig, username_action, circuitname, circuit.path, null,
|
||||
recnotif = await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT, idapp, extrarec.dest, usernameOrig,
|
||||
username_action, circuitname, circuit.path, null,
|
||||
false, '', extrarec);
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT, idapp, extrarec.dest, usernameOrig, username_action, circuitname, circuit.path, null,
|
||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT, idapp, extrarec.dest, usernameOrig,
|
||||
username_action, circuitname, circuit.path, null,
|
||||
false, '', extrarec);
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT, idapp, extrarec.dest, usernameOrig, username_action, circuitname, circuit.path, null,
|
||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT, idapp, extrarec.dest, usernameOrig,
|
||||
username_action, circuitname, circuit.path, null,
|
||||
false, '', extrarec);
|
||||
}
|
||||
|
||||
|
||||
if (recnotif)
|
||||
extrarec.notifIdToUpdate = recnotif._id;
|
||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, extrarec.dest, username_action, circuitname, circuit.path,
|
||||
@@ -1176,7 +1178,6 @@ module.exports = {
|
||||
|
||||
extrarec.notifIdToUpdate = '';
|
||||
|
||||
|
||||
if (ris)
|
||||
inviato = true;
|
||||
// ++Todo: Inviare anche agli Admin ?!
|
||||
@@ -2018,7 +2019,7 @@ module.exports = {
|
||||
filteradmin = true;
|
||||
}
|
||||
|
||||
if (myfilter['pub_to_share'] === shared_consts.PUBTOSHARE.ONLY_GROUPS_FOLLOW) {
|
||||
if (myfilter['pub_to_share'] === shared_consts.PUBTOSHARE.ONLY_TABLE_FOLLOW && params.table === 'mygroups') {
|
||||
|
||||
let arraygroups = [];
|
||||
|
||||
@@ -2038,6 +2039,27 @@ module.exports = {
|
||||
},
|
||||
};
|
||||
|
||||
query.push({$match: {$and: [condition]}});
|
||||
} else if (myfilter['pub_to_share'] === shared_consts.PUBTOSHARE.ONLY_TABLE_FOLLOW && params.table === 'circuits') {
|
||||
|
||||
let arraycircuits = [];
|
||||
|
||||
if (user && user.profile.mycircuits) {
|
||||
arraycircuits = user.profile.mycircuits.map(rec => rec.circuitname);
|
||||
}
|
||||
// prendere i gruppi dell'utente
|
||||
|
||||
// Cerca tra i gruppi di ogni record, se combaciano almeno 1
|
||||
condition = {
|
||||
'profile.mycircuits':
|
||||
{
|
||||
$elemMatch: {
|
||||
circuitname: {$in: arraycircuits},
|
||||
},
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
query.push({$match: {$and: [condition]}});
|
||||
} else if (shared_consts.TABLES_ENABLE_GETREC_BYID.includes(params.table)) {
|
||||
// Rimuovi dalla query quelli non visibili
|
||||
@@ -2099,16 +2121,25 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
if (params.table === 'mygroups') {
|
||||
if (params.table === 'mygroups' || params.table === 'circuits') {
|
||||
// BINARY CHECK (?): const filter = [{ visibility: { $bitsAnyClear: [1] } }];
|
||||
// if (!User.isAdmin(req.user.perm)) {
|
||||
// not Visibility_Group.HIDDEN
|
||||
if (!filteradmin) {
|
||||
const filter = [
|
||||
{
|
||||
visibility: {
|
||||
$nin: [shared_consts.Visibility_Group.HIDDEN],
|
||||
},
|
||||
$or: [
|
||||
{
|
||||
visibility: {
|
||||
$nin: [shared_consts.Visibility_Group.HIDDEN],
|
||||
},
|
||||
},
|
||||
{
|
||||
createdBy: {
|
||||
$eq: user.username,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
query.push({$match: {$and: filter}});
|
||||
@@ -3331,6 +3362,6 @@ module.exports = {
|
||||
|
||||
getAhref(username, link) {
|
||||
return `<a href='${link}'>${username}</a>`;
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@ module.exports = {
|
||||
|
||||
PUBTOSHARE: {
|
||||
ALL: 0,
|
||||
ONLY_GROUPS_FOLLOW: 1,
|
||||
ONLY_TABLE_FOLLOW: 1,
|
||||
},
|
||||
|
||||
TAB_COUNTRY: 'countries',
|
||||
|
||||
Reference in New Issue
Block a user