- tutorial Circuito Ris Italia
- Invia RIS (visibile per tutti)
This commit is contained in:
@@ -80,6 +80,7 @@ let aggregation = [
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.qualifica": 1,
|
"profile.qualifica": 1,
|
||||||
"profile.resid_province": 1,
|
"profile.resid_province": 1,
|
||||||
|
"profile.resid_card": 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
date_report: 1,
|
date_report: 1,
|
||||||
username_who_report: 1,
|
username_who_report: 1,
|
||||||
@@ -141,6 +142,7 @@ let aggregation = [
|
|||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
"profile.qualifica": 1,
|
"profile.qualifica": 1,
|
||||||
"profile.resid_province": 1,
|
"profile.resid_province": 1,
|
||||||
|
"profile.resid_card": 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
date_report: 1,
|
date_report: 1,
|
||||||
username_who_report: 1,
|
username_who_report: 1,
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ const CircuitSchema = new Schema({
|
|||||||
{
|
{
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
card: // Punti cardinali
|
||||||
|
{
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
pub_to_share: {
|
pub_to_share: {
|
||||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||||
},
|
},
|
||||||
@@ -290,6 +294,7 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
|||||||
symbol: 1,
|
symbol: 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
strProv: 1,
|
strProv: 1,
|
||||||
|
card: 1,
|
||||||
link_group: 1,
|
link_group: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
visibility: 1,
|
visibility: 1,
|
||||||
@@ -354,6 +359,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
|||||||
color: 1,
|
color: 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
strProv: 1,
|
strProv: 1,
|
||||||
|
card: 1,
|
||||||
link_group: 1,
|
link_group: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
visibility: 1,
|
visibility: 1,
|
||||||
@@ -495,12 +501,22 @@ CircuitSchema.statics.getCircuitIdByName = async function (idapp, name) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CircuitSchema.statics.getCircuitByProvince = async function (idapp, strProv) {
|
CircuitSchema.statics.getCircuitByProvinceAndCard = async function (idapp, strProv, card) {
|
||||||
|
|
||||||
const myfind = {
|
let myfind = {};
|
||||||
|
|
||||||
|
if (card) {
|
||||||
|
myfind = {
|
||||||
|
idapp,
|
||||||
|
strProv,
|
||||||
|
card
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
myfind = {
|
||||||
idapp,
|
idapp,
|
||||||
strProv,
|
strProv,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await Circuit.findOne(myfind);
|
return await Circuit.findOne(myfind);
|
||||||
@@ -815,7 +831,13 @@ CircuitSchema.statics.updateData = async function (idapp, circuitname) {
|
|||||||
|
|
||||||
const ris = await User.aggregate(aggr1);
|
const ris = await User.aggregate(aggr1);
|
||||||
|
|
||||||
let numMembers = ris ? ris[0].count : 0;
|
let numMembers = 0;
|
||||||
|
try {
|
||||||
|
numMembers = ris && tools.isArray(ris) ? ris[0].count : 0;
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
let paramstoupdate = {
|
let paramstoupdate = {
|
||||||
numMembers: numMembers,
|
numMembers: numMembers,
|
||||||
@@ -948,7 +970,7 @@ CircuitSchema.statics.getCircuitMyProvince = async function (idapp, username) {
|
|||||||
const myuser = await User.getUserByUsername(idapp, username);
|
const myuser = await User.getUserByUsername(idapp, username);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const circuit = await this.getCircuitByProvince(idapp, myuser.profile.resid_province);
|
const circuit = await this.getCircuitByProvinceAndCard(idapp, myuser.profile.resid_province, myuser.profile.resid_card);
|
||||||
|
|
||||||
if (circuit) {
|
if (circuit) {
|
||||||
if (await User.ifAlreadyInCircuit(idapp, username, circuit.name)) {
|
if (await User.ifAlreadyInCircuit(idapp, username, circuit.name)) {
|
||||||
@@ -964,14 +986,14 @@ CircuitSchema.statics.getCircuitMyProvince = async function (idapp, username) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||||
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province) {
|
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province, card) {
|
||||||
const { User } = require('../models/user');
|
const { User } = require('../models/user');
|
||||||
|
|
||||||
const useradmin = tools.USER_ADMIN_CIRCUITS;
|
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.getCircuitByProvinceAndCard(idapp, province, card);
|
||||||
|
|
||||||
const nomeprovincia = await Province.getStrProvinceByProv(province);
|
const nomeprovincia = await Province.getStrProvinceByProv(province);
|
||||||
|
|
||||||
@@ -981,6 +1003,7 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
|||||||
name: 'Circuito RIS ' + nomeprovincia,
|
name: 'Circuito RIS ' + nomeprovincia,
|
||||||
path: 'ris' + tools.convertSpaces_ToUScore(nomeprovincia.toLowerCase()),
|
path: 'ris' + tools.convertSpaces_ToUScore(nomeprovincia.toLowerCase()),
|
||||||
strProv: province,
|
strProv: province,
|
||||||
|
card,
|
||||||
photos: [],
|
photos: [],
|
||||||
color: '#ff5500',
|
color: '#ff5500',
|
||||||
deperimento: false,
|
deperimento: false,
|
||||||
@@ -1155,7 +1178,7 @@ CircuitSchema.statics.setFido = async function (idapp, username, circuitName, gr
|
|||||||
const accountsuser = await Account.getUserAccounts(idapp, username);
|
const accountsuser = await Account.getUserAccounts(idapp, username);
|
||||||
if (accountsuser) {
|
if (accountsuser) {
|
||||||
// Se lo trovo della mia provincia, prendo quello
|
// Se lo trovo della mia provincia, prendo quello
|
||||||
account = accountsuser.find((account) => account.circuit.strProv === myuser.profile.resid_province)
|
account = accountsuser.find((account) => account.circuit.strProv === myuser.profile.resid_province && account.circuit.card === myuser.profile.resid_card)
|
||||||
if (!account && accountsuser.length > 0) {
|
if (!account && accountsuser.length > 0) {
|
||||||
// Se non lo trovo, prendo il primo in cui sono entrato !
|
// Se non lo trovo, prendo il primo in cui sono entrato !
|
||||||
account = accountsuser[0];
|
account = accountsuser[0];
|
||||||
|
|||||||
@@ -981,6 +981,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
|||||||
'profile.notifs': 1,
|
'profile.notifs': 1,
|
||||||
'profile.mycircuits': 1,
|
'profile.mycircuits': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
|
'profile.resid_card': 1,
|
||||||
'profile.notif_idCities': 1,
|
'profile.notif_idCities': 1,
|
||||||
'profile.notif_provinces': 1,
|
'profile.notif_provinces': 1,
|
||||||
'profile.notif_regions': 1,
|
'profile.notif_regions': 1,
|
||||||
|
|||||||
@@ -441,6 +441,10 @@ const UserSchema = new mongoose.Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
trim: true,
|
trim: true,
|
||||||
},
|
},
|
||||||
|
resid_card: {
|
||||||
|
type: String,
|
||||||
|
trim: true,
|
||||||
|
},
|
||||||
stepTutorial: {
|
stepTutorial: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
@@ -1623,6 +1627,7 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
|
'profile.resid_card': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
@@ -1667,6 +1672,7 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
|
'profile.resid_card': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
@@ -1712,6 +1718,7 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
|
'profile.resid_card': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
@@ -3006,6 +3013,7 @@ function getWhatToShow(idapp, username) {
|
|||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
|
'profile.resid_card': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
@@ -3030,6 +3038,7 @@ function getWhatToShow_Unknown(idapp, username) {
|
|||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
|
'profile.resid_card': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
@@ -3056,6 +3065,7 @@ UserSchema.statics.getWhatToShow_IfFriends = async function (idapp, username) {
|
|||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
|
'profile.resid_card': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
date_report: 1,
|
date_report: 1,
|
||||||
|
|||||||
@@ -952,8 +952,9 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
if (mydata.table === 'users') {
|
if (mydata.table === 'users') {
|
||||||
|
|
||||||
if ('profile.resid_province' in fieldsvalue) {
|
if ('profile.resid_province' in fieldsvalue) {
|
||||||
|
const card = fieldsvalue.hasOwnProperty('profile.resid_card') ? fieldsvalue['profile.resid_card'] : '';
|
||||||
// Controlla se esiste il Circuito di questa provincia, se non esiste lo crea!
|
// Controlla se esiste il Circuito di questa provincia, se non esiste lo crea!
|
||||||
await Circuit.createCircuitIfNotExist(req, idapp, fieldsvalue['profile.resid_province']);
|
await Circuit.createCircuitIfNotExist(req, idapp, fieldsvalue['profile.resid_province'], card);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (camporequisiti) {
|
if (camporequisiti) {
|
||||||
|
|||||||
@@ -762,6 +762,7 @@ module.exports = {
|
|||||||
'profile.mycircuits': 1,
|
'profile.mycircuits': 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
|
'profile.resid_card': 1,
|
||||||
'profile.username_telegram': 1,
|
'profile.username_telegram': 1,
|
||||||
'profile.favorite': 1,
|
'profile.favorite': 1,
|
||||||
'profile.bookmark': 1,
|
'profile.bookmark': 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user