- Provincia obbligatoria, chiedo conferma se non vuole entrare nel circuito.
This commit is contained in:
@@ -916,6 +916,8 @@ CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, val
|
||||
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province) {
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const useradmin = tools.USER_ADMIN_CIRCUITS;
|
||||
|
||||
let myrec = null;
|
||||
try {
|
||||
const circuit = await this.getCircuitByProvince(idapp, province);
|
||||
@@ -943,6 +945,7 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
||||
totTransato: 0,
|
||||
totCircolante: 0,
|
||||
date_created: new Date(),
|
||||
admins: [{ username: useradmin }],
|
||||
});
|
||||
|
||||
myrec = await circ.save();
|
||||
@@ -950,14 +953,14 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
||||
if (myrec) {
|
||||
|
||||
// nuovo Circuito:
|
||||
await User.setCircuitCmd(idapp, tools.USER_ADMIN_CIRCUITS, myrec.name,
|
||||
shared_consts.CIRCUITCMD.CREATE, true, tools.USER_ADMIN_CIRCUITS, myrec).then((ris) => {
|
||||
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, tools.USER_ADMIN_CIRCUITS, myrec.name,
|
||||
shared_consts.CIRCUITCMD.SET, true, tools.USER_ADMIN_CIRCUITS, myrec).then((ris) => {
|
||||
await User.setCircuitCmd(idapp, useradmin, myrec.name,
|
||||
shared_consts.CIRCUITCMD.SET, true, useradmin, myrec).then((ris) => {
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -444,6 +444,9 @@ const UserSchema = new mongoose.Schema({
|
||||
noNameSurname: {
|
||||
type: Boolean,
|
||||
},
|
||||
noCircuit: {
|
||||
type: Boolean,
|
||||
},
|
||||
noFoto: {
|
||||
type: Boolean,
|
||||
}
|
||||
|
||||
@@ -1241,6 +1241,14 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
await City.remove({});
|
||||
await Province.remove({});
|
||||
|
||||
} else if (mydata.dbop === 'createAllCircuits') {
|
||||
const { Province } = require('../models/province');
|
||||
|
||||
const arrProv = await Province.find({});
|
||||
for (const recprov of arrProv) {
|
||||
await Circuit.createCircuitIfNotExist(req, idapp, recprov.prov);
|
||||
}
|
||||
|
||||
} else if (mydata.dbop === 'ImpostaMinMaxPersonali') {
|
||||
|
||||
await Account.SetMinMaxPersonali(idapp, mydata.valmin, mydata.valmax);
|
||||
@@ -1329,6 +1337,9 @@ async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
|
||||
} else if (mydata.dbop === 'noNameSurname') {
|
||||
await User.findOneAndUpdate({ _id: mydata._id },
|
||||
{ $set: { 'profile.noNameSurname': mydata.value } });
|
||||
} else if (mydata.dbop === 'noCircuit') {
|
||||
await User.findOneAndUpdate({ _id: mydata._id },
|
||||
{ $set: { 'profile.noCircuit': mydata.value } });
|
||||
} else if (mydata.dbop === 'noFoto') {
|
||||
await User.findOneAndUpdate({ _id: mydata._id },
|
||||
{ $set: { 'profile.noFoto': mydata.value } });
|
||||
|
||||
Reference in New Issue
Block a user