- Gruppi si chiamano ora "Organizzazioni".

- Categorie dei Gruppi aggiornate.
- Email ora compare sul profilo se non hai telegram e anche sugli annunci.
This commit is contained in:
Surya Paolo
2025-01-28 23:32:32 +01:00
parent b56e25d1fa
commit 341b4b8ec7
11 changed files with 195 additions and 114 deletions

View File

@@ -2,79 +2,105 @@ module.exports = {
list: [
{
_id: 1,
descr: 'Abitare',
},
{
_id: 2,
descr: 'Arte',
descr: 'Ospitalità ed accoglienza',
color: '#00BCD4',
icon: 'fa fa-bed'
},
{
_id: 3,
descr: 'Alimentazione',
descr: 'Prodotti Alimentari',
color: '#4CAF50',
icon: 'fa fa-apple-alt'
},
{
_id: 4,
descr: 'Artigianato',
descr: 'Prodotti Artigianali e Artistici',
color: '#9C27B0',
icon: 'fa fa-paint-brush'
},
{
_id: 5,
descr: 'Assistenza Legale',
},
{
_id: 6,
descr: 'Benessere',
},
{
_id: 7,
descr: 'Gruppi Locali',
descr: 'Servizi di Assistenza e Integrazione',
color: '#2196F3',
icon: 'fa fa-hands-helping'
},
{
_id: 8,
descr: 'Istruzione',
},
{
_id: 2,
descr: 'Arte',
},
{
_id: 9,
descr: 'Mobilità',
},
{
_id: 10,
descr: 'Sport',
},
{
_id: 11,
descr: 'Servizi',
descr: 'Servizi Formativi ed Educativi',
color: '#FFC107',
icon: 'fa fa-book'
},
{
_id: 12,
descr: 'Tecnologia',
},
{
_id: 13,
descr: 'Turismo',
color: '#607D8B',
icon: 'fa fa-laptop'
},
{
_id: 14,
descr: 'Ecovillaggi / Comunità',
},
{
_id: 15,
descr: 'Feste',
},
{
_id: 16,
descr: 'Altro',
},
{
_id: 17,
descr: 'AutoProduzione',
descr: 'Comunità ed Ecovillaggi',
color: '#8BC34A',
icon: 'fa fa-users'
},
{
_id: 18,
descr: 'Salute',
descr: 'Salute e Benessere',
color: '#E91E63',
icon: 'fa fa-heart'
},
{
_id: 20,
descr: 'Progetti Umanitari (Volontari)',
color: '#F44336',
icon: 'fa fa-hands'
},
{
_id: 31,
descr: 'Servizi per l\'Agricoltura, orto',
color: '#009688',
icon: 'fa fa-leaf'
},
{
_id: 32,
descr: 'Servizi di Distribuzione e Logistica',
color: '#3F51B5',
icon: 'fa fa-truck'
},
{
_id: 33,
descr: 'Servizi di Consulenza',
color: '#CDDC39',
icon: 'fa fa-briefcase'
},
{
_id: 34,
descr: 'Attività Ricreative e di Intrattenim.',
color: '#FF5722',
icon: 'fa fa-music'
},
{
_id: 36,
descr: 'Manutenzione e riparazioni',
color: '#673AB7',
icon: 'fa fa-wrench'
},
{
_id: 37,
descr: 'Cura della persona',
color: '#FFEB3B',
icon: 'fa fa-user'
},
{
_id: 40,
descr: 'Energia',
color: '#03A9F4',
icon: 'fa fa-bolt'
},
{
_id: 41,
descr: 'Servizi e prodotti per la casa',
color: '#FF9800',
icon: 'fa fa-home'
},
],
};
};

View File

@@ -17,11 +17,11 @@ module.exports = {
const mydbfile = require(pathfile);
if (mydbfile && mydbfile.list) {
return table.insertMany(mydbfile.list, {ordered: false}).
then((ris) => {
console.log('Populate table ', tablename);
return !!ris;
});
return table.insertMany(mydbfile.list, { ordered: false }).
then((ris) => {
console.log('Populate table ', tablename);
return !!ris;
});
}
}
} catch (e) {
@@ -31,52 +31,62 @@ module.exports = {
},
async insertIntoDb_NoDuplicate(attiva, tablename, table, field) {
let numrec = 0;
let numupdated = 0;
try {
if (!attiva && await table.countDocuments({}) > 0)
return;
if (!attiva && await table.countDocuments({}) > 0) return;
const pathfile = Path.join(__dirname, tablename + '.js');
if (tools.isFileExists(pathfile)) {
const mydbfile = require(pathfile);
if (mydbfile && mydbfile.list) {
for (const rec of mydbfile.list) {
let obj = {};
obj[field] = rec[field];
let query = {};
query[field] = rec[field];
var mynewrec = new table(rec);
if (rec.hasOwnProperty('idapp')) {
obj.idapop = rec['idapp'];
if (rec.hasOwnProperty('_id')) {
query._id = rec._id;
}
const exist = await table.find(obj);
if (exist.length <= 0) {
try {
const ris = await mynewrec.save();
if (ris) {
if (rec.hasOwnProperty('idapp')) {
query.idapp = rec.idapp;
}
try {
const existingDoc = await table.findOne(query);
if (!existingDoc) {
const { value: existingDoc, upserted } = await table.findOneAndUpdate(
query,
{ $set: rec },
{ upsert: true, new: true }
);
if (upserted) {
// Il documento non esisteva, è stato creato
console.log('Inserted document with _id:', existingDoc._id);
numrec++;
}
} catch (e) {
console.log('error ', e);
}
} else {
// Il documento esiste, lo aggiorniamo
await table.updateOne({ _id: existingDoc._id }, { $set: rec });
numupdated++;
}
} catch (e) {
console.log('Error processing record:', e);
}
}
if (numrec > 0)
console.log('*** Insert', numrec, 'record on ' + tablename);
if (numrec > 0 || numupdated > 0) {
console.log(`*** Inserted ${numrec} and updated ${numupdated} records in ${tablename}`);
}
}
}
} catch (e) {
console.log('error insertIntoDb', e);
console.log('Error in insertIntoDb_NoDuplicate:', e);
}
},
async rewriteTable(table) {
@@ -85,15 +95,15 @@ module.exports = {
let field = '';
try {
const {City} = require('../models/city');
const {Province} = require('../models/province');
const {Sector} = require('../models/sector');
const {SectorGood} = require('../models/sectorgood');
const {Skill} = require('../models/skill');
const {Good} = require('../models/good');
const { City } = require('../models/city');
const { Province } = require('../models/province');
const { Sector } = require('../models/sector');
const { SectorGood } = require('../models/sectorgood');
const { Skill } = require('../models/skill');
const { Good } = require('../models/good');
// const {SubSkill} = require('../models/subskill');
const {Contribtype} = require('../models/contribtype');
const {Level} = require('../models/level');
const { Contribtype } = require('../models/contribtype');
const { Level } = require('../models/level');
if (table === 'cities') {
mytab = City;
@@ -127,11 +137,11 @@ module.exports = {
if (mytab) {
await mytab.collection.drop();
// mongoose.connection.db.dropCollection(table, function(err) {
console.log('Delete ', table);
// await mytab.remove({});
console.log('Delete ', table);
// await mytab.remove({});
this.insertIntoDb_NoDuplicate(false, table, mytab, field);
// });
this.insertIntoDb_NoDuplicate(false, table, mytab, field);
// });
}
return true;
} catch (e) {

View File

@@ -19,7 +19,8 @@ module.exports = {
{_id: 17, descr: 'Attrezzature', icon: 'fas fa-tools', color: 'blue-7'},
{_id: 18, descr: 'Animali', icon: 'fas fa-paw', color: 'green-7'},
{_id: 19, descr: 'Arte / Decorazioni', icon: 'fas fa-palette', color: 'purple-7'},
{_id: 20, descr: 'Agricoltura', icon: 'fa-seedling', color: 'green-7'},
{_id: 20, descr: 'Agricoltura', icon: 'fas fa-seedling', color: 'green-7'},
{_id: 21, descr: 'Elettrodomestici', icon: 'fas fa-blender', color: 'green-7'},
],
};