diff --git a/sw-admin/templates/addpoll.html b/sw-admin/templates/addpoll.html
index e700e41..8855efc 100644
--- a/sw-admin/templates/addpoll.html
+++ b/sw-admin/templates/addpoll.html
@@ -45,7 +45,7 @@
Data zakończenia głosowania:
@@ -139,6 +139,18 @@
Dodawanie nowego głosowania
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
@@ -150,7 +162,10 @@
Dodawanie nowego głosowania
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'),
diff --git a/sw-admin/templates/editpoll.html b/sw-admin/templates/editpoll.html
index c58e61c..07dbd84 100644
--- a/sw-admin/templates/editpoll.html
+++ b/sw-admin/templates/editpoll.html
@@ -55,7 +55,7 @@
{% block header %}Edycja głosowania "{{name}}"{% endblock %}
Głosujacy (adresy email w nowych liniach):
-
+
Data zakończenia głosowania:
@@ -110,6 +110,18 @@
{% 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
@@ -121,7 +133,10 @@ {% 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'),