Skip to content
This repository was archived by the owner on Nov 23, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions sw-admin/templates/addpoll.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h3 class="mb-5">Dodawanie nowego głosowania</h3>
<br />

Głosujacy (adresy email w nowych liniach): <br/>
<textarea class="form-control" id="pollRecipients" placeholder="1@student.pwr.edu.pl&#10;2@student.pwr.edu.pl&#10;..." rows=10></textarea>
<textarea class="form-control" id="pollRecipients" placeholder="1@student.pwr.edu.pl&#10;2@student.pwr.edu.pl&#10;...&#10;lub&#10;123456&#10;234567" rows=10></textarea>
<br /> <br />
<div class="d-flex justify-content-left align-items-center">
Data zakończenia głosowania:
Expand Down Expand Up @@ -139,6 +139,18 @@ <h3 class="mb-5">Dodawanie nowego głosowania</h3>
document.body.appendChild(form);
form.submit();
}

Comment thread
StachowiakDawid marked this conversation as resolved.
const createPollRecipient = (recipient) => {
recipient = recipient.trim();
if (recipient.split('@').length === 2) {
if (/^\d+$/.test(recipient.split('@')[0])) {
return recipient;
}
} else if (recipient.split('@').length === 1 && /^\d+$/.test(recipient.split('@')[0])) {
return recipient + '@student.pwr.edu.pl';
}
}

function send() {
let options = Array.from(document.getElementById('pollOptionsTBody').rows)
.filter(row => row.childElementCount != 1) // filter out the last row with the add button
Expand All @@ -150,7 +162,10 @@ <h3 class="mb-5">Dodawanie nowego głosowania</h3>
name: val('pollName'),
options: JSON.stringify(options),
choiceType: 'multiple-choice',
recipients: JSON.stringify(pollRecipients.value.split('\n').filter(email => email.length != 0).map(email => email.trim())),
recipients: JSON.stringify(
pollRecipients.value.split('\n')
.map(email => createPollRecipient(email)).filter(x => x)
),
closesOnDate: val('pollClosesOnDate') + ' ' + val('pollClosesOnTime'),
visibility: 'private',
mailTemplate: val('pollMailTemplate'),
Expand Down
19 changes: 17 additions & 2 deletions sw-admin/templates/editpoll.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
<br /> <br />

Głosujacy (adresy email w nowych liniach): <br/>
<textarea class="form-control" id="pollRecipients" placeholder="1@student.pwr.edu.pl&#10;2@student.pwr.edu.pl&#10;..." rows=10 {{should_disable}}>{{ "\n".join(possible_recipients) }}</textarea>
<textarea class="form-control" id="pollRecipients" placeholder="1@student.pwr.edu.pl&#10;2@student.pwr.edu.pl&#10;...&#10;lub&#10;123456&#10;234567" rows=10 {{should_disable}}>{{ "\n".join(possible_recipients) }}</textarea>
<br /> <br />
<div class="d-flex justify-content-left align-items-center">
Data zakończenia głosowania:
Expand Down Expand Up @@ -110,6 +110,18 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
document.body.appendChild(form);
form.submit();
}

const createPollRecipient = (recipient) => {
recipient = recipient.trim();
if (recipient.split('@').length === 2) {
if (/^\d+$/.test(recipient.split('@')[0])) {
return recipient;
}
} else if (recipient.split('@').length === 1 && /^\d+$/.test(recipient.split('@')[0])) {
return recipient + '@student.pwr.edu.pl';
}
}

function send() {
let options = Array.from(document.getElementById('pollOptionsTBody').rows)
.filter(row => row.childElementCount != 1) // filter out the last row with the add button
Expand All @@ -121,7 +133,10 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
name: val('pollName'),
options: JSON.stringify(options),
choiceType: 'multiple-choice',
recipients: JSON.stringify(pollRecipients.value.split('\n').filter(email => email.length != 0).map(email => email.trim())),
recipients: JSON.stringify(
pollRecipients.value.split('\n')
.map(email => createPollRecipient(email)).filter(x => x)
),
closesOnDate: val('pollClosesOnDate') + ' ' + val('pollClosesOnTime'),
visibility: 'private',
mailTemplate: val('pollMailTemplate'),
Expand Down