- Gruppi (3) - lista degli utenti del gruppo
This commit is contained in:
@@ -50,6 +50,7 @@ const {StatusSkill} = require('../models/statusSkill');
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
const {Sector} = require('../models/sector');
|
||||
const {CatGrp} = require('../models/catgrp');
|
||||
const {Level} = require('../models/level');
|
||||
const Pickup = require('../models/pickup');
|
||||
const {Newstosent} = require('../models/newstosent');
|
||||
@@ -315,6 +316,8 @@ function getTableByTableName(tablename) {
|
||||
mytable = Province;
|
||||
else if (tablename === 'sectors')
|
||||
mytable = Sector;
|
||||
else if (tablename === 'catgrps')
|
||||
mytable = CatGrp;
|
||||
else if (tablename === 'levels')
|
||||
mytable = Level;
|
||||
else if (shared_consts.TablePickup.includes(tablename))
|
||||
@@ -351,7 +354,8 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_USER_ID.includes(params.table)) {
|
||||
mydata.userId = req.user._id;
|
||||
if (!mydata.userId)
|
||||
mydata.userId = req.user._id;
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_PERM_NEWREC.includes(params.table)) {
|
||||
@@ -360,20 +364,31 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (params.table === shared_consts.TAB_MYGROUPS) {
|
||||
if (shared_consts.MYGROUPS_KEY_TO_CRYPTED in mydata) {
|
||||
if (mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]) {
|
||||
mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED + shared_consts.SUFFIX_CRYPTED] = tools.cryptdata(mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_USER_INCLUDE_MY.includes(params.table)) {
|
||||
if (!mydata.admins) {
|
||||
mydata.admins = [];
|
||||
} else {
|
||||
const arrnew = [];
|
||||
/*const arrnew = [];
|
||||
for (const username of mydata.admins) {
|
||||
arrnew.push({username});
|
||||
}
|
||||
mydata.admins = arrnew;
|
||||
|
||||
*/
|
||||
}
|
||||
const indfind = mydata.admins.findIndex((rec) => (rec.username === req.user.username));
|
||||
|
||||
if (indfind < 0) {
|
||||
mydata.admins.push({_id: new ObjectID(), username: req.user.username});
|
||||
mydata.admins.push({username: req.user.username});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,7 +649,6 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
fieldsvalue.crypted = true;
|
||||
fieldsvalue.value_str = tools.cryptdata(fieldsvalue.value_str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (mydata.table === shared_consts.TAB_SITES) {
|
||||
@@ -1089,6 +1103,7 @@ function load(req, res, version) {
|
||||
let subSkills = SubSkill.findAllIdApp(idapp);
|
||||
let statusSkills = StatusSkill.findAllIdApp(idapp);
|
||||
let sectors = Sector.findAllIdApp(idapp);
|
||||
let catgrps = CatGrp.findAllIdApp(idapp);
|
||||
let cities = City.findAllIdApp(idapp);
|
||||
let cart = null;
|
||||
let orderscart = null;
|
||||
@@ -1145,7 +1160,9 @@ function load(req, res, version) {
|
||||
sectors,
|
||||
statusSkills,
|
||||
cities,
|
||||
myuserextra]).then((arrdata) => {
|
||||
myuserextra,
|
||||
catgrps,
|
||||
]).then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
let myuser = req.user;
|
||||
if (myuser) {
|
||||
@@ -1216,6 +1233,8 @@ function load(req, res, version) {
|
||||
sectors: arrdata[27],
|
||||
statusSkills: arrdata[28],
|
||||
cities: arrdata[29],
|
||||
// myuser arrdata[30]
|
||||
catgrps: arrdata[31],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1425,11 +1444,14 @@ function uploadFile(req, res, version) {
|
||||
const ris = await resizer(newname, setup_image_compress);
|
||||
|
||||
if (ris) {
|
||||
tools.delete(newname, false, () => {});
|
||||
if (tools.isFileExists(resized_img)) {
|
||||
tools.delete(newname, false, () => {});
|
||||
|
||||
tools.move(resized_img, newname, (err) => {
|
||||
|
||||
});
|
||||
tools.move(resized_img, newname, (err) => {
|
||||
if (err)
|
||||
console.error('err', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('newname', e);
|
||||
|
||||
Reference in New Issue
Block a user