Skip to content

Commit 43634c6

Browse files
committed
fix: add warning when assigning points for event organizing not through the events type
1 parent e8a2216 commit 43634c6

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

templates/admin/points/manual/custom.njk

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@
4141
<div class="form-text">Tip: try starting your reason with a verb, e.g. <i>"Helped out at X event"</i>, <i>"Ranked 1st in Y"</i> or <i>"Received community service"</i>.</div>
4242
</div>
4343

44+
<script>
45+
// Watch for the word "event" in the reason field and display a warning if it is found
46+
document.getElementById('reason').addEventListener('input', function() {
47+
const reason = this.value.toLowerCase();
48+
const warning = document.getElementById('reason-warning');
49+
if (reason.includes('event')) {
50+
if (!warning) {
51+
const warningDiv = document.createElement('div');
52+
warningDiv.id = 'reason-warning';
53+
warningDiv.classList.add('form-text', 'text-danger');
54+
warningDiv.innerText = 'It seems you are trying to assign points for an event. Please use the event-specific forms instead (see warning at the top of the page).';
55+
this.parentNode.appendChild(warningDiv);
56+
}
57+
} else {
58+
if (warning) {
59+
warning.remove();
60+
}
61+
}
62+
});
63+
</script>
64+
4465
<button type="submit" class="btn btn-primary">Assign single score</button>
4566
</form>
4667

@@ -75,6 +96,27 @@ login3,-1000,A very solid reason" required></textarea>
7596
});
7697
</script>
7798

99+
<script>
100+
// Watch for the word "event" in the csv field and display a warning if it is found
101+
document.getElementById('csv').addEventListener('input', function() {
102+
const csv = this.value.toLowerCase();
103+
const warning = document.getElementById('reason-warning-csv');
104+
if (csv.includes('event')) {
105+
if (!warning) {
106+
const warningDiv = document.createElement('div');
107+
warningDiv.id = 'reason-warning-csv';
108+
warningDiv.classList.add('form-text', 'text-danger');
109+
warningDiv.innerText = 'It seems you are trying to assign points for an event. Please use the event-specific forms instead (see warning at the top of the page).';
110+
this.parentNode.appendChild(warningDiv);
111+
}
112+
} else {
113+
if (warning) {
114+
warning.remove();
115+
}
116+
}
117+
});
118+
</script>
119+
78120
<button type="submit" class="btn btn-primary">Assign multiple scores</button>
79121
</form>
80122

templates/admin/points/manual/event.njk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666

6767
<hr>
6868

69+
<div class="alert alert-warning">
70+
<p>It is advised to only assign points for events that have already taken place.</p>
71+
</div>
72+
6973
<form action="/admin/points/manual/event/assign" method="post" class="mb-4">
7074
<div class="mb-2">
7175
<label for="event_name" class="form-label">Intra event</label>

0 commit comments

Comments
 (0)