- 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) {
|
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province) {
|
||||||
const { User } = require('../models/user');
|
const { User } = require('../models/user');
|
||||||
|
|
||||||
|
const useradmin = tools.USER_ADMIN_CIRCUITS;
|
||||||
|
|
||||||
let myrec = null;
|
let myrec = null;
|
||||||
try {
|
try {
|
||||||
const circuit = await this.getCircuitByProvince(idapp, province);
|
const circuit = await this.getCircuitByProvince(idapp, province);
|
||||||
@@ -943,6 +945,7 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
|||||||
totTransato: 0,
|
totTransato: 0,
|
||||||
totCircolante: 0,
|
totCircolante: 0,
|
||||||
date_created: new Date(),
|
date_created: new Date(),
|
||||||
|
admins: [{ username: useradmin }],
|
||||||
});
|
});
|
||||||
|
|
||||||
myrec = await circ.save();
|
myrec = await circ.save();
|
||||||
@@ -950,14 +953,14 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
|||||||
if (myrec) {
|
if (myrec) {
|
||||||
|
|
||||||
// nuovo Circuito:
|
// nuovo Circuito:
|
||||||
await User.setCircuitCmd(idapp, tools.USER_ADMIN_CIRCUITS, myrec.name,
|
await User.setCircuitCmd(idapp, useradmin, myrec.name,
|
||||||
shared_consts.CIRCUITCMD.CREATE, true, tools.USER_ADMIN_CIRCUITS, myrec).then((ris) => {
|
shared_consts.CIRCUITCMD.CREATE, true, useradmin, myrec).then((ris) => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// aggiungi il creatore al Circuito stesso
|
// aggiungi il creatore al Circuito stesso
|
||||||
await User.setCircuitCmd(idapp, tools.USER_ADMIN_CIRCUITS, myrec.name,
|
await User.setCircuitCmd(idapp, useradmin, myrec.name,
|
||||||
shared_consts.CIRCUITCMD.SET, true, tools.USER_ADMIN_CIRCUITS, myrec).then((ris) => {
|
shared_consts.CIRCUITCMD.SET, true, useradmin, myrec).then((ris) => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -444,6 +444,9 @@ const UserSchema = new mongoose.Schema({
|
|||||||
noNameSurname: {
|
noNameSurname: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
|
noCircuit: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
noFoto: {
|
noFoto: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1241,6 +1241,14 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
|||||||
await City.remove({});
|
await City.remove({});
|
||||||
await Province.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') {
|
} else if (mydata.dbop === 'ImpostaMinMaxPersonali') {
|
||||||
|
|
||||||
await Account.SetMinMaxPersonali(idapp, mydata.valmin, mydata.valmax);
|
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') {
|
} else if (mydata.dbop === 'noNameSurname') {
|
||||||
await User.findOneAndUpdate({ _id: mydata._id },
|
await User.findOneAndUpdate({ _id: mydata._id },
|
||||||
{ $set: { 'profile.noNameSurname': mydata.value } });
|
{ $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') {
|
} else if (mydata.dbop === 'noFoto') {
|
||||||
await User.findOneAndUpdate({ _id: mydata._id },
|
await User.findOneAndUpdate({ _id: mydata._id },
|
||||||
{ $set: { 'profile.noFoto': mydata.value } });
|
{ $set: { 'profile.noFoto': mydata.value } });
|
||||||
|
|||||||
Reference in New Issue
Block a user