Errore in visualizzazione degli eventi ! non si vedevano piu!

This commit is contained in:
Paolo Arena
2021-06-24 15:55:38 +02:00
parent 9d5eda50ae
commit 10e9da805e
3 changed files with 88 additions and 59 deletions

View File

@@ -32,6 +32,18 @@ span Abilita le Newsletter? : 
strong #{iscritto.newsletter_on}<br> strong #{iscritto.newsletter_on}<br>
span Metodo di Pagamento :&nbsp; span Metodo di Pagamento :&nbsp;
strong #{metodo_pagamento}<br> strong #{metodo_pagamento}<br>
span Motivazioni sul perchè intendi iscriverti alla CNM:&nbsp;
strong #{iscritto.motivazioni}<br>
span Descrivi le tue competenze e professionalità:&nbsp;
strong #{iscritto.competenze_professionalita}<br>
span Cosa potresti offrire?:&nbsp;
strong #{iscritto.cosa_potrei_offrire}<br>
span Cosa vorresti ricevere? (cosa ti aspetti?):&nbsp;
strong #{iscritto.cosa_vorrei_ricevere}<br>
span Scrivi altre eventuali informazioni o comunicazioni:&nbsp;
strong #{iscritto.altre_comunicazioni}<br>
span Come ci hai conosciuto?:&nbsp;
strong #{iscritto.come_ci_hai_conosciuto}<br>
p <br>Saluti p <br>Saluti
style(type="text/css"). style(type="text/css").

View File

@@ -2,17 +2,17 @@ const mongoose = require('mongoose');
const Schema = mongoose.Schema; const Schema = mongoose.Schema;
mongoose.Promise = global.Promise; mongoose.Promise = global.Promise;
mongoose.level = "F"; mongoose.level = 'F';
const tools = require('../tools/general'); const tools = require('../tools/general');
const { ObjectID } = require('mongodb'); const {ObjectID} = require('mongodb');
const { Settings } = require('./settings'); const {Settings} = require('./settings');
// Resolving error Unknown modifier: $pushAll // Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => { mongoose.plugin(schema => {
schema.options.usePushEach = true schema.options.usePushEach = true;
}); });
const MyEventSchema = new Schema({ const MyEventSchema = new Schema({
@@ -121,9 +121,10 @@ const MyEventSchema = new Schema({
note: { note: {
type: String, type: String,
}, },
pagefooter: [{ pagefooter: [
type: String, {
}], type: String,
}],
deleted: { deleted: {
type: Boolean, type: Boolean,
}, },
@@ -138,115 +139,132 @@ const MyEventSchema = new Schema({
}, },
}); });
MyEventSchema.statics.findAllIdApp = function (socioresidente, idapp) { MyEventSchema.statics.findAllIdApp = function(socioresidente, idapp) {
const Event = this; const Event = this;
let query = [] let query = [];
if (socioresidente) { if (socioresidente) {
query = [ query = [
{ {
$match: { $match: {
idapp, idapp,
} $or: [
} {deleted: {$exists: false}},
] {deleted: {$exists: true, $eq: false}}],
},
},
];
} else { } else {
query = [ query = [
{ {
$match: { $match: {
idapp, idapp,
$or: [ $and: [
{ $or: [{ internal: { $exists: false } }, { internal: { $exists: true, $eq: false } }] }, {
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}},
],
},
{
$or: [
{internal: {$exists: false}},
{internal: {$exists: true, $eq: false}}],
},
], ],
} },
} },
] ];
} }
query.push({ $sort: { dateTimeStart: 1 } }) query.push({$sort: {dateTimeStart: 1}});
return Event return Event.aggregate(query).then((arrrec) => {
.aggregate(query) return arrrec;
.then((arrrec) => { });
return arrrec
})
}; };
MyEventSchema.statics.getLastEvents = async function (idapp) { MyEventSchema.statics.getLastEvents = async function(idapp) {
const Event = this; const Event = this;
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_EV', 1); const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_EV', 1);
const query = [ const query = [
{ $match: { idapp, dateTimeStart: { $gte: tools.IncDateNow(-1000 * 60 * 60 * 24) } } }, {
$match: {
idapp,
dateTimeStart: {$gte: tools.IncDateNow(-1000 * 60 * 60 * 24)},
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
},
},
{ {
$lookup: { $lookup: {
from: 'operators', from: 'operators',
localField: 'teacher', localField: 'teacher',
foreignField: 'username', foreignField: 'username',
as: 'op1' as: 'op1',
} },
}, },
{ {
$lookup: { $lookup: {
from: 'operators', from: 'operators',
localField: 'teacher2', localField: 'teacher2',
foreignField: 'username', foreignField: 'username',
as: 'op2' as: 'op2',
} },
}, },
{ {
$lookup: { $lookup: {
from: 'operators', from: 'operators',
localField: 'teacher3', localField: 'teacher3',
foreignField: 'username', foreignField: 'username',
as: 'op3' as: 'op3',
} },
}, },
{ {
$lookup: { $lookup: {
from: 'operators', from: 'operators',
localField: 'teacher4', localField: 'teacher4',
foreignField: 'username', foreignField: 'username',
as: 'op4' as: 'op4',
} },
}, },
{ "$addFields": { "contribtype": { "$toObjectId": "$contribtype" } } }, {'$addFields': {'contribtype': {'$toObjectId': '$contribtype'}}},
{ {
$lookup: { $lookup: {
from: 'contribtypes', from: 'contribtypes',
localField: 'contribtype', localField: 'contribtype',
foreignField: '_id', foreignField: '_id',
as: 'contrib' as: 'contrib',
} },
}, },
{ $sort: { dateTimeStart: 1 } } {$sort: {dateTimeStart: 1}},
]; ];
return Event return Event.aggregate(query).then((arrrec) => {
.aggregate(query) // console.table(arrrec);
.then((arrrec) => { if (lastn > 0) {
// console.table(arrrec); return arrrec.slice(0, lastn);
if (lastn > 0) { } else {
return arrrec.slice(0, lastn); return arrrec;
} else { }
return arrrec });
}
})
}; };
MyEventSchema.statics.getFieldsForSearch = function() {
MyEventSchema.statics.getFieldsForSearch = function () { return [
return [{ field: 'short_tit', type: tools.FieldType.string }, {field: 'short_tit', type: tools.FieldType.string},
{ field: 'title', type: tools.FieldType.string }, {field: 'title', type: tools.FieldType.string},
{ field: 'teacher', type: tools.FieldType.string }, {field: 'teacher', type: tools.FieldType.string},
{ field: 'details', type: tools.FieldType.string }] {field: 'details', type: tools.FieldType.string}];
}; };
MyEventSchema.statics.executeQueryTable = function (idapp, params) { MyEventSchema.statics.executeQueryTable = function(idapp, params) {
params.fieldsearch = this.getFieldsForSearch(); params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params); return tools.executeQueryTable(this, idapp, params);
}; };
@@ -256,7 +274,6 @@ if (tools.INITDB_FIRSTIME) {
// MyEventSchema.index({ short_tit: 'text', title: 'text', teacher: 'text', details: 'text' }); // MyEventSchema.index({ short_tit: 'text', title: 'text', teacher: 'text', details: 'text' });
} }
const MyEvent = mongoose.model('MyEvent', MyEventSchema); const MyEvent = mongoose.model('MyEvent', MyEventSchema);
module.exports = { MyEvent }; module.exports = {MyEvent};

View File

@@ -203,9 +203,9 @@ module.exports = {
tools.sendNotifToAdmin('Nuova Registrazione Utente: ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')'); tools.sendNotifToAdmin('Nuova Registrazione Utente: ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
if (tools.isManagAndAdminDifferent(idapp)) { // if (tools.isManagAndAdminDifferent(idapp)) {
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, ''); // this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
} // }
}, },
sendEmail_IscrizioneConacreis: async function (lang, emailto, iscritto, idapp) { sendEmail_IscrizioneConacreis: async function (lang, emailto, iscritto, idapp) {