changes
This commit is contained in:
@@ -71,6 +71,7 @@ const QRSalt ="!SaltyMagic5392370662";
|
|||||||
// Make sure open camping tickets actually send email
|
// Make sure open camping tickets actually send email
|
||||||
// Don't hardcode MainURL and PORT
|
// Don't hardcode MainURL and PORT
|
||||||
// Limit number of Open Camping tickets
|
// Limit number of Open Camping tickets
|
||||||
|
// + Make sure subsequent FB imports don't add duplicate tickets
|
||||||
// Maybe:
|
// Maybe:
|
||||||
// Deactivate individual magic links (User)
|
// Deactivate individual magic links (User)
|
||||||
// Option to "Email me my QR Code"
|
// Option to "Email me my QR Code"
|
||||||
@@ -183,7 +184,7 @@ app.use((req, res, next) => {
|
|||||||
let users={};
|
let users={};
|
||||||
let tickets={};
|
let tickets={};
|
||||||
let camps={};
|
let camps={};
|
||||||
let settings={ "enable-transfer":true };
|
let settings={ "enable-transfer":true, "open-limit":0 };
|
||||||
|
|
||||||
function InitDatabase() {
|
function InitDatabase() {
|
||||||
for (const key in users ) delete users[key];
|
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) });
|
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) => {
|
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) => {
|
app.post('/importfb',requireSuperUser,upload.single("file"),(req,res) => {
|
||||||
console.log("File name:", req.file.originalname);
|
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();
|
const contents=req.file.buffer.toString();
|
||||||
csvParse.parse(contents, { columns: true, trim: true }, (err, records) => {
|
csvParse.parse(contents, { columns: true, trim: true }, (err, records) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -673,13 +690,14 @@ app.post('/importfb',requireSuperUser,upload.single("file"),(req,res) => {
|
|||||||
return res.redirect("/settings");
|
return res.redirect("/settings");
|
||||||
}
|
}
|
||||||
let count=0;
|
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 };
|
if (!camps[item.camp]) camps[item.camp]={ leader:"", lastid:0 };
|
||||||
camps[item.camp].lastid++;
|
camps[item.camp].lastid++;
|
||||||
const ticket=item.camp+"-"+camps[item.camp].lastid;
|
const ticket=item.camp+"-"+camps[item.camp].lastid;
|
||||||
tickets[ticket]={ owner:"", offered: item.email, paid:0.00, status:"i" };
|
tickets[ticket]={ owner:"", offered: item.email, paid:0.00, status:"i" };
|
||||||
console.log("Offered ",ticket," to ",item.email);
|
console.log("Offered ",ticket," to ",item.email);
|
||||||
count++;
|
count++;
|
||||||
|
emails[item.email]=1;
|
||||||
}
|
}
|
||||||
req.session.message="Imported "+count+" Frostburn-style records.";
|
req.session.message="Imported "+count+" Frostburn-style records.";
|
||||||
return res.redirect("/settings");
|
return res.redirect("/settings");
|
||||||
@@ -698,7 +716,7 @@ app.post('/serialize',requireSuperUser, async (req,res) => {
|
|||||||
|
|
||||||
app.post('/deserialize',requireSuperUser, (req,res) => {
|
app.post('/deserialize',requireSuperUser, (req,res) => {
|
||||||
DeserializeAll();
|
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) => {
|
app.post('/purge',requireSuperUser, (req,res) => {
|
||||||
@@ -753,6 +771,7 @@ function do_payforwhat(payforwhat) {
|
|||||||
camps[payforwhat.camp].lastid++;
|
camps[payforwhat.camp].lastid++;
|
||||||
tickets[payforwhat.camp+"-"+camps[payforwhat.camp].lastid]={ owner:payforwhat.email, offered:"",paid:100.0*payforwhat.amounteach,status:"i" };
|
tickets[payforwhat.camp+"-"+camps[payforwhat.camp].lastid]={ owner:payforwhat.email, offered:"",paid:100.0*payforwhat.amounteach,status:"i" };
|
||||||
}
|
}
|
||||||
|
EmailTickets(payforwhat.email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
views/partials/nav.ejs~
Normal file
12
views/partials/nav.ejs~
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<!-- views/partials/nav.ejs -->
|
||||||
|
<aside>
|
||||||
|
<nav class="nav-links">
|
||||||
|
Falls on Fire
|
||||||
|
<ul>
|
||||||
|
<li><a href="/mytickets">View My Tickets</a></li>
|
||||||
|
<li><a href="/camps">View Camps (Admin)</a></li>
|
||||||
|
<li><a href="/settings">Settings (Admin)</a></li>
|
||||||
|
<li><a href="/logout">Log Out</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</aside>
|
||||||
@@ -28,6 +28,11 @@
|
|||||||
<input type="email" name="email">
|
<input type="email" name="email">
|
||||||
<button type="submit">Deactivate</button>
|
<button type="submit">Deactivate</button>
|
||||||
</form>
|
</form>
|
||||||
|
<form action="/addopen" method="post">
|
||||||
|
Open Camping Tickets: <%=opencount%> / <%=settings['open-limit']%>
|
||||||
|
<input type="number" name="addopen">
|
||||||
|
<button type="submit">Add</button>
|
||||||
|
</form
|
||||||
<form action="/importfb" method="post" enctype="multipart/form-data">
|
<form action="/importfb" method="post" enctype="multipart/form-data">
|
||||||
Import Tickets (Frostburn Format):
|
Import Tickets (Frostburn Format):
|
||||||
<input type="file" name="file">
|
<input type="file" name="file">
|
||||||
|
|||||||
Reference in New Issue
Block a user