add reset feature for admins/orgs
Build Images and Deploy / Update-PROD-Stack (push) Successful in 28s
Build Images and Deploy / Update-PROD-Stack (push) Successful in 28s
This commit is contained in:
@@ -222,6 +222,16 @@ const Hunts = {
|
|||||||
.run(name, description, expiryDate || null, id);
|
.run(name, description, expiryDate || null, id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
resetScans(id) {
|
||||||
|
const doReset = db.transaction(() => {
|
||||||
|
// Delete all scans for packages in this hunt
|
||||||
|
db.prepare('DELETE FROM scans WHERE package_id IN (SELECT id FROM packages WHERE hunt_id = ?)').run(id);
|
||||||
|
// Reset package scan counters and scanner references
|
||||||
|
db.prepare('UPDATE packages SET scan_count = 0, first_scanned_by = NULL, last_scanned_by = NULL, hint_text = NULL, hint_image = NULL WHERE hunt_id = ?').run(id);
|
||||||
|
});
|
||||||
|
doReset();
|
||||||
|
},
|
||||||
|
|
||||||
delete(id) {
|
delete(id) {
|
||||||
const doDelete = db.transaction(() => {
|
const doDelete = db.transaction(() => {
|
||||||
// Delete scans for all packages in this hunt
|
// Delete scans for all packages in this hunt
|
||||||
|
|||||||
@@ -112,6 +112,15 @@ router.post('/hunts/:id/edit', requireHuntAccess, (req, res) => {
|
|||||||
res.redirect(`/admin/hunts/${hunt.id}`);
|
res.redirect(`/admin/hunts/${hunt.id}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Reset hunt scans
|
||||||
|
router.post('/hunts/:id/reset', requireHuntAccess, (req, res) => {
|
||||||
|
const hunt = req.hunt;
|
||||||
|
|
||||||
|
Hunts.resetScans(hunt.id);
|
||||||
|
req.session.flash = { type: 'success', message: `All scan data for "${hunt.name}" has been reset.` };
|
||||||
|
res.redirect(`/admin/hunts/${hunt.id}/edit`);
|
||||||
|
});
|
||||||
|
|
||||||
// Delete hunt
|
// Delete hunt
|
||||||
router.post('/hunts/:id/delete', requireHuntAccess, (req, res) => {
|
router.post('/hunts/:id/delete', requireHuntAccess, (req, res) => {
|
||||||
const hunt = req.hunt;
|
const hunt = req.hunt;
|
||||||
|
|||||||
@@ -42,6 +42,14 @@
|
|||||||
|
|
||||||
<div class="card" style="border: 2px solid var(--danger); margin-top: 1.5rem;">
|
<div class="card" style="border: 2px solid var(--danger); margin-top: 1.5rem;">
|
||||||
<div class="card-header" style="color: var(--danger);">Danger Zone</div>
|
<div class="card-header" style="color: var(--danger);">Danger Zone</div>
|
||||||
|
|
||||||
|
<p style="color: var(--muted); font-size: 0.9rem; margin-bottom: 0.75rem;">Reset all scan history, points, hints, and images for this hunt. Packages are kept but returned to a fresh state.</p>
|
||||||
|
<form method="POST" action="/admin/hunts/<%= hunt.id %>/reset" onsubmit="return confirm('Are you sure you want to reset all scan data for "<%= hunt.name %>"? All points, hints, and images will be erased. This cannot be undone.')" style="margin-bottom: 1.25rem;">
|
||||||
|
<button type="submit" class="btn btn-danger">Reset All Scans</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<hr style="border: none; border-top: 1px solid var(--border); margin-bottom: 1rem;">
|
||||||
|
|
||||||
<p style="color: var(--muted); font-size: 0.9rem;">Permanently delete this hunt, all its packages, and all scan data. This cannot be undone.</p>
|
<p style="color: var(--muted); font-size: 0.9rem;">Permanently delete this hunt, all its packages, and all scan data. This cannot be undone.</p>
|
||||||
<form method="POST" action="/admin/hunts/<%= hunt.id %>/delete" onsubmit="return confirm('Are you sure you want to permanently delete "<%= hunt.name %>"? This will delete ALL packages and scan data. This cannot be undone.')">
|
<form method="POST" action="/admin/hunts/<%= hunt.id %>/delete" onsubmit="return confirm('Are you sure you want to permanently delete "<%= hunt.name %>"? This will delete ALL packages and scan data. This cannot be undone.')">
|
||||||
<button type="submit" class="btn btn-danger">Delete Hunt</button>
|
<button type="submit" class="btn btn-danger">Delete Hunt</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user