changes
This commit is contained in:
@@ -71,6 +71,7 @@ const QRSalt ="!SaltyMagic5392370662";
|
||||
// Make sure open camping tickets actually send email
|
||||
// Don't hardcode MainURL and PORT
|
||||
// Limit number of Open Camping tickets
|
||||
// + Make sure subsequent FB imports don't add duplicate tickets
|
||||
// Maybe:
|
||||
// Deactivate individual magic links (User)
|
||||
// Option to "Email me my QR Code"
|
||||
@@ -183,7 +184,7 @@ app.use((req, res, next) => {
|
||||
let users={};
|
||||
let tickets={};
|
||||
let camps={};
|
||||
let settings={ "enable-transfer":true };
|
||||
let settings={ "enable-transfer":true, "open-limit":0 };
|
||||
|
||||
function InitDatabase() {
|
||||
for (const key in users ) delete users[key];
|
||||
@@ -658,13 +659,29 @@ app.post('/qrcodesu',requireSuperUser,async (req,res) => {
|
||||
return res.send({ owner:username, qrcode: URL, magiclink:GetMagicLink(username) });
|
||||
})
|
||||
|
||||
function opencount() {
|
||||
let rval=0;
|
||||
for (t in tickets) if (t.startsWith("open-")) if (tickets[t].status!='r') rval++;
|
||||
return rval;
|
||||
}
|
||||
|
||||
app.get('/settings',requireSuperUser, (req,res) => {
|
||||
res.render('settings',{ username:req.session.username, superuser:req.session.superuser, settings:settings, message: "" })
|
||||
res.render('settings',{ username:req.session.username, superuser:req.session.superuser, settings:settings, opencount:opencount(), message: "" })
|
||||
});
|
||||
|
||||
app.post('/addopen',requireSuperUser,(req,res) => {
|
||||
settings['open-limit']+=Number(req.body.addopen);
|
||||
return res.redirect('/settings');
|
||||
});
|
||||
|
||||
|
||||
app.post('/importfb',requireSuperUser,upload.single("file"),(req,res) => {
|
||||
console.log("File name:", req.file.originalname);
|
||||
let emails={};
|
||||
for (t in tickets) {
|
||||
if (tickets[t].offered) emails[tickets[t].offered]=1;
|
||||
if (tickets[t].owner ) emails[tickets[t].owner ]=1;
|
||||
}
|
||||
const contents=req.file.buffer.toString();
|
||||
csvParse.parse(contents, { columns: true, trim: true }, (err, records) => {
|
||||
if (err) {
|
||||
@@ -673,13 +690,14 @@ app.post('/importfb',requireSuperUser,upload.single("file"),(req,res) => {
|
||||
return res.redirect("/settings");
|
||||
}
|
||||
let count=0;
|
||||
for (const item of records) {
|
||||
for (const item of records) if (item.email in emails) {
|
||||
if (!camps[item.camp]) camps[item.camp]={ leader:"", lastid:0 };
|
||||
camps[item.camp].lastid++;
|
||||
const ticket=item.camp+"-"+camps[item.camp].lastid;
|
||||
tickets[ticket]={ owner:"", offered: item.email, paid:0.00, status:"i" };
|
||||
console.log("Offered ",ticket," to ",item.email);
|
||||
count++;
|
||||
emails[item.email]=1;
|
||||
}
|
||||
req.session.message="Imported "+count+" Frostburn-style records.";
|
||||
return res.redirect("/settings");
|
||||
@@ -698,7 +716,7 @@ app.post('/serialize',requireSuperUser, async (req,res) => {
|
||||
|
||||
app.post('/deserialize',requireSuperUser, (req,res) => {
|
||||
DeserializeAll();
|
||||
return res.redirect("/"); // Since we may be overwriting session
|
||||
return res.redirect("/settings"); // Since we may be overwriting session
|
||||
});
|
||||
|
||||
app.post('/purge',requireSuperUser, (req,res) => {
|
||||
@@ -753,6 +771,7 @@ function do_payforwhat(payforwhat) {
|
||||
camps[payforwhat.camp].lastid++;
|
||||
tickets[payforwhat.camp+"-"+camps[payforwhat.camp].lastid]={ owner:payforwhat.email, offered:"",paid:100.0*payforwhat.amounteach,status:"i" };
|
||||
}
|
||||
EmailTickets(payforwhat.email);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user