1.0.48
Aggiornamento APP RISO: ✅ Inviando i RIS, deve comparire prima il Circuito della Provincia, e poi quello Nazionale ✅ Risolto problema per vecchie registrazioni, la provincia compariva "undefined".
This commit is contained in:
10
logtrans.txt
10
logtrans.txt
@@ -196,4 +196,12 @@ Giovannifruttadisicilia: 222.50 RIS]
|
||||
Mar 28/05 ORE 16:51: [<b>Circuito RIS Italia</b>]: Inviate Monete da ElenaEspx a Giovannifruttadisicilia 28 RIS [causale: Acquisto arance 30genn24 RisoBologna 1]
|
||||
Saldi:
|
||||
ElenaEspx: -60.10 RIS]
|
||||
Giovannifruttadisicilia: 250.50 RIS]
|
||||
Giovannifruttadisicilia: 250.50 RIS]
|
||||
Ven 31/05 ORE 11:12: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a dsadas1 1 RIS [causale: aaa]
|
||||
Saldi:
|
||||
paoloar77: -2.00 RIS]
|
||||
dsadas1: 1.00 RIS]
|
||||
Ven 31/05 ORE 11:59: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a dsadas1 2 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -4.00 RIS]
|
||||
dsadas1: 3.00 RIS]
|
||||
380
src/server/models/attivita.js
Executable file
380
src/server/models/attivita.js
Executable file
@@ -0,0 +1,380 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true;
|
||||
});
|
||||
|
||||
const AttivitaSchema = new Schema(
|
||||
{
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
},
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
// userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
idSector: {
|
||||
type: Number,
|
||||
},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
logo:
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
|
||||
tipodiAttivita: {
|
||||
type: Number,
|
||||
},
|
||||
|
||||
nome_attivita: {
|
||||
type: String,
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
coordinate_gps: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
email: {
|
||||
type: String,
|
||||
},
|
||||
telegram_username: {
|
||||
type: String,
|
||||
},
|
||||
cell_phone: {
|
||||
type: String,
|
||||
},
|
||||
whatsapp: {
|
||||
type: String,
|
||||
},
|
||||
createdBy: { // Username del creatore (proponente)
|
||||
type: String,
|
||||
},
|
||||
|
||||
//**ADDFIELD_ATTIVITA
|
||||
},
|
||||
...Reaction.getFieldsForReactions()
|
||||
}, { strict: false });
|
||||
|
||||
AttivitaSchema.index({ 'idapp': 1 });
|
||||
|
||||
|
||||
AttivitaSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
if (!this.date_created)
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
AttivitaSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const Attivita = this;
|
||||
|
||||
const query = [
|
||||
{ $match: { idapp } },
|
||||
{ $sort: { descr: 1 } },
|
||||
];
|
||||
|
||||
return await Attivita.aggregate(query).then((arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
AttivitaSchema.statics.getFieldsForSearch = function () {
|
||||
return [];
|
||||
};
|
||||
|
||||
AttivitaSchema.statics.getFieldsLastForSearch = function () {
|
||||
return [
|
||||
{ field: 'note', type: tools.FieldType.string },
|
||||
{ field: 'descr', type: tools.FieldType.string },
|
||||
{ field: 'recSkill.descr', type: tools.FieldType.string },
|
||||
{ field: 'attivita.descr', type: tools.FieldType.string },
|
||||
];
|
||||
};
|
||||
|
||||
AttivitaSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
params.fieldsearch_last = this.getFieldsLastForSearch();
|
||||
|
||||
const otherparams = {
|
||||
lookup1: {
|
||||
lk_tab: 'users',
|
||||
lk_LF: 'userId',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
lk_proj: this.getProject(),
|
||||
},
|
||||
};
|
||||
|
||||
params = { ...params, ...otherparams };
|
||||
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) {
|
||||
const Attivita = this;
|
||||
|
||||
let query = [
|
||||
{
|
||||
'$match': {
|
||||
'_id': idSkill, idapp
|
||||
},
|
||||
},
|
||||
{
|
||||
'$sort': {
|
||||
'desc': 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
'$addFields': {
|
||||
'myId1': {
|
||||
'$toObjectId': '$userId',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
'from': 'users',
|
||||
'localField': 'myId1',
|
||||
'foreignField': '_id',
|
||||
'as': 'user',
|
||||
},
|
||||
},
|
||||
{
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
'$arrayElemAt': [
|
||||
'$user',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
'from': 'skills',
|
||||
'localField': 'idSkill',
|
||||
'foreignField': '_id',
|
||||
'as': 'recSkill',
|
||||
},
|
||||
},
|
||||
{
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
'$arrayElemAt': [
|
||||
'$recSkill',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
'from': 'sectors',
|
||||
'localField': 'idSector',
|
||||
'foreignField': '_id',
|
||||
'as': 'sector',
|
||||
},
|
||||
},
|
||||
{
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
'$arrayElemAt': [
|
||||
'$sector',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
'$arrayElemAt': [
|
||||
'$attivita',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
'from': 'cities',
|
||||
'localField': 'idCity',
|
||||
'foreignField': '_id',
|
||||
'as': 'mycities',
|
||||
},
|
||||
},
|
||||
{
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
'$arrayElemAt': [
|
||||
'$mycities',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
let numtab = tools.getNumTabByTable(shared_consts.TABLES_ATTIVITAS);
|
||||
|
||||
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
|
||||
query = [...query, ...objadd.query];
|
||||
|
||||
const toadd = {
|
||||
$project: this.getProject(objadd.proj),
|
||||
};
|
||||
|
||||
query = [...query, { ...toadd }];
|
||||
|
||||
return Attivita.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
});
|
||||
};
|
||||
|
||||
AttivitaSchema.statics.getProject = function (proj_add2) {
|
||||
let proj = {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
idCity: 1,
|
||||
logo: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
descr: 1,
|
||||
website: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
tipodiAttivita: 1,
|
||||
nome_attivita: 1,
|
||||
coordinate_gps: 1,
|
||||
email: 1,
|
||||
telegram_username: 1,
|
||||
cell_phone: 1,
|
||||
whatsapp: 1,
|
||||
createdBy: 1,
|
||||
//**ADDFIELD_ATTIVITA
|
||||
};
|
||||
|
||||
const proj_add = shared_consts.getProjectForAll(proj_add2)
|
||||
|
||||
return Object.assign({}, proj, proj_add);
|
||||
|
||||
}
|
||||
|
||||
AttivitaSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
const Attivita = this;
|
||||
|
||||
return Attivita.getMyRecById(idapp, id);
|
||||
|
||||
};
|
||||
|
||||
const Attivita = mongoose.model('Attivita', AttivitaSchema);
|
||||
|
||||
Attivita.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Attivita };
|
||||
@@ -95,7 +95,11 @@ async function completaSettaggioProduct_AndProductInfo(arrcampi_productInfo, arr
|
||||
productInfo.img = 'upload/products/' + product.code + '.jpg';
|
||||
} else {
|
||||
if (rec.hasOwnProperty('img')) {
|
||||
productInfo.img = 'upload/products/' + rec['img'];
|
||||
if (rec['img']) {
|
||||
productInfo.img = 'upload/products/' + rec['img'];
|
||||
} else {
|
||||
productInfo.img = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -674,7 +674,7 @@ function checkBlocked(req, res, next) {
|
||||
|
||||
if (failedLoginAttempts[username] && failedLoginAttempts[username] > now) {
|
||||
text = 'Utente bloccato. Riprova più tardi. (username=' + username + ')';
|
||||
console.log(text);
|
||||
console.log(text);
|
||||
return res.status(403).json({ message: 'Utente bloccato. Riprova più tardi.' });
|
||||
}
|
||||
|
||||
@@ -1623,6 +1623,14 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
await Circuit.createCircuitIfNotExist(req, idapp, recprov.prov);
|
||||
}
|
||||
|
||||
} else if (mydata.dbop === 'correggiCircuitiANull') {
|
||||
|
||||
|
||||
await User.updateMany(
|
||||
{},
|
||||
{ $pull: { "profile.mycircuits": { "circuitname": null } } }
|
||||
);
|
||||
|
||||
} else if (mydata.dbop === 'ImpostaMinMaxPersonali') {
|
||||
|
||||
await Account.SetMinMaxPersonali(idapp, mydata.valmin, mydata.valmax, '');
|
||||
|
||||
@@ -4960,7 +4960,7 @@ module.exports = {
|
||||
const result = [];
|
||||
|
||||
text = text.replace(",", ".");
|
||||
const regex = /^(\d+\.?\d*)\s*(ml|gr|l|kg|uova)\s*$/; // Aggiunto un punto dopo \d+ per accettare anche i numeri con la virgola
|
||||
const regex = /^(\d+\.?\d*)\s*(ml|gr|g|l|kg|uova)\s*$/; // Aggiunto un punto dopo \d+ per accettare anche i numeri con la virgola
|
||||
|
||||
const match = regex.exec(text);
|
||||
if (match) {
|
||||
|
||||
@@ -24,6 +24,7 @@ const { Skill } = require('../models/skill');
|
||||
const { Good } = require('../models/good');
|
||||
const { SubSkill } = require('../models/subskill');
|
||||
const { MySkill } = require('../models/myskill');
|
||||
const { Attivita } = require('../models/attivita');
|
||||
const { MyGood } = require('../models/mygood');
|
||||
const { MyBacheca } = require('../models/mybacheca');
|
||||
const { MyHosp } = require('../models/myhosp');
|
||||
@@ -212,6 +213,8 @@ module.exports = {
|
||||
mytable = SubSkill;
|
||||
else if (tablename === shared_consts.TABLES_MYSKILLS)
|
||||
mytable = MySkill;
|
||||
else if (tablename === shared_consts.TABLES_ATTIVITAS)
|
||||
mytable = Attivita;
|
||||
else if (tablename === shared_consts.TABLES_MYBACHECAS)
|
||||
mytable = MyBacheca;
|
||||
else if (tablename === shared_consts.TABLES_MYHOSPS)
|
||||
|
||||
@@ -149,13 +149,15 @@ module.exports = {
|
||||
TABLES_MYEVENTS: 'myevents',
|
||||
TABLES_CIRCUITS: 'circuits',
|
||||
TABLES_MYGROUPS: 'mygroups',
|
||||
TABLES_ATTIVITAS: 'attivitas',
|
||||
|
||||
MYTABS: [{ id: 0, table: 'none' },
|
||||
{ id: 1, table: 'myskills' },
|
||||
{ id: 2, table: 'mybachecas' },
|
||||
{ id: 3, table: 'myhosps' },
|
||||
{ id: 4, table: 'mygoods' },
|
||||
{ id: 5, table: 'myevents' }],
|
||||
{ id: 5, table: 'myevents' },
|
||||
{ id: 6, table: 'attivitas' }],
|
||||
|
||||
CMD_REACTION: {
|
||||
SET_FAVORITE: 1,
|
||||
@@ -172,17 +174,20 @@ module.exports = {
|
||||
numattend: 1,
|
||||
},
|
||||
|
||||
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps', 'myskills', 'mygoods'],
|
||||
TABLES_REACTIONS: ['mybachecas', 'myhosps', 'myskills', 'mygoods'],
|
||||
// Condivise
|
||||
TABLES_FAVORITE_BOOKMARK: ['myskills', 'mygoods', 'mybachecas', 'myhosps', 'attivitas'],
|
||||
|
||||
// Solo per NODEJS
|
||||
|
||||
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps', 'myskills', 'mygoods', 'attivitas'],
|
||||
TABLES_USER_INCLUDE_MY: ['mygroups', 'circuits'],
|
||||
TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||
TABLES_INSERT_ALMOST_ONE_TO_ENABLE_CIRCUIT: ['myskills', 'myhosps', 'mygoods'],
|
||||
TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'attivitas'],
|
||||
|
||||
//++Todo: per abilitare gli utenti ad inserire un Circuito aggiungere 'circuits' alla lista TABLES_PERM_NEWREC
|
||||
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
|
||||
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
|
||||
TABLES_FAVORITE_BOOKMARK: ['myskills', 'mygoods', 'mybachecas', 'myhosps'],
|
||||
|
||||
|
||||
TABLES_REACTIONS: ['mybachecas', 'myhosps', 'myskills', 'mygoods', 'attivitas'],
|
||||
|
||||
TABLES_VISU_STAT_IN_HOME: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups', 'circuits'],
|
||||
|
||||
TABLES_ADV_NOTIFICATION: ['myskills', 'myhosps', 'mygoods'],
|
||||
@@ -221,8 +226,8 @@ module.exports = {
|
||||
// 'mygroups'
|
||||
],
|
||||
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||
TABLES_CREATEDBY: ['mygroups', 'circuits'],
|
||||
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots', 'mygroups', 'circuits'],
|
||||
TABLES_CREATEDBY: ['mygroups', 'circuits', 'attivitas'],
|
||||
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots', 'mygroups', 'circuits', 'attivitas'],
|
||||
|
||||
TABLES_FIELDS_DESCR_AND_CITY_AND_USER: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||
|
||||
@@ -855,6 +860,31 @@ module.exports = {
|
||||
link_maplocation: 1,
|
||||
}
|
||||
|
||||
} else if (table === this.TABLES_ATTIVITAS) {
|
||||
proj = {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
idCity: 1,
|
||||
logo: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
descr: 1,
|
||||
website: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
tipodiAttivita: 1,
|
||||
name: 1,
|
||||
coordinate_gps: 1,
|
||||
email: 1,
|
||||
telegram_username: 1,
|
||||
cell_phone: 1,
|
||||
whatsapp: 1,
|
||||
createdBy: 1,
|
||||
//**ADDFIELD_ATTIVITA
|
||||
};
|
||||
|
||||
} else if (table === this.TABLES_MYBACHECAS) {
|
||||
proj = {
|
||||
recSkill: 1,
|
||||
|
||||
Reference in New Issue
Block a user