cambio nome ai circuiti
This commit is contained in:
@@ -918,6 +918,31 @@ CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, val
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||
CircuitSchema.statics.replaceAllCircuits = async function (idapp) {
|
||||
|
||||
const globalTables = require('../tools/globalTables');
|
||||
|
||||
const arrcircuit = await Circuit.find({ idapp }).lean();
|
||||
|
||||
let num = 0;
|
||||
for (const circuit of arrcircuit) {
|
||||
if (circuit.strProv) {
|
||||
let nomeprovincia = await Province.getStrProvinceByProv(circuit.strProv);
|
||||
let newname = 'Circuito RIS ' + nomeprovincia;
|
||||
|
||||
if (newname !== circuit.name) {
|
||||
ris = await globalTables.ReplaceCircuitName(idapp, circuit.name, newname);
|
||||
|
||||
if (ris)
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('*** Replaced Circuits ', num);
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province) {
|
||||
const { User } = require('../models/user');
|
||||
|
||||
@@ -932,7 +957,7 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
||||
if (!circuit && nomeprovincia) {
|
||||
const circ = new Circuit({
|
||||
idapp,
|
||||
name: 'RIS ' + nomeprovincia,
|
||||
name: 'Circuito RIS ' + nomeprovincia,
|
||||
path: 'ris' + tools.convertSpaces_ToUScore(nomeprovincia.toLowerCase()),
|
||||
strProv: province,
|
||||
photos: [],
|
||||
@@ -960,13 +985,13 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
||||
// nuovo Circuito:
|
||||
await User.setCircuitCmd(idapp, useradmin, myrec.name,
|
||||
shared_consts.CIRCUITCMD.CREATE, true, useradmin, myrec).then((ris) => {
|
||||
|
||||
|
||||
});
|
||||
|
||||
// aggiungi il creatore al Circuito stesso
|
||||
await User.setCircuitCmd(idapp, useradmin, myrec.name,
|
||||
shared_consts.CIRCUITCMD.SET, true, useradmin, myrec).then((ris) => {
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user