@@ -55,7 +55,7 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
5555 < br /> < br />
5656
5757 Głosujacy (adresy email w nowych liniach): < br />
58- < textarea class ="form-control " id ="pollRecipients " placeholder ="1@student.pwr.edu.pl 2@student.pwr.edu.pl ... " rows =10 {{should_disable}} > {{ "\n".join(possible_recipients) }}</ textarea >
58+ < textarea class ="form-control " id ="pollRecipients " placeholder ="1@student.pwr.edu.pl 2@student.pwr.edu.pl 123456 ... " rows =10 {{should_disable}} > {{ "\n".join(possible_recipients) }}</ textarea >
5959 < br /> < br />
6060 < div class ="d-flex justify-content-left align-items-center ">
6161 Data zakończenia głosowania:
@@ -81,12 +81,12 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
8181
8282 < script >
8383 function deleteRow ( el ) {
84- var row = el . parentNode . parentNode ;
84+ const row = el . parentNode . parentNode ;
8585 document . getElementById ( 'pollOptionsTBody' ) . removeChild ( row ) ;
8686 }
8787 function addRow ( el ) {
88- var row = el . parentNode . parentNode ;
89- var tr = document . createElement ( 'tr' ) ;
88+ const row = el . parentNode . parentNode ;
89+ const tr = document . createElement ( 'tr' ) ;
9090 tr . innerHTML = '<td><input class="form-control" type="text" placeholder="Jan Kowalski"></td>' ;
9191 tr . innerHTML += '<td><input class="form-control" type="text" placeholder="Wydział Architektury"></td>' ;
9292 tr . innerHTML += '<td><button class="btn btn-danger" onclick="deleteRow(this)"><i class="fas fa-trash-alt"></i></button></td>' ;
@@ -96,7 +96,7 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
9696 return document . getElementById ( elName ) . value ;
9797 }
9898 function sendForm ( data ) {
99- let form = document . createElement ( 'form' ) ;
99+ const form = document . createElement ( 'form' ) ;
100100 form . method = "POST" ;
101101 form . action = "{% block formactionpath %}?id={{poll_id}}{% endblock %}" ;
102102 form . style . display = 'none' ;
@@ -111,17 +111,24 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
111111 form . submit ( ) ;
112112 }
113113 function send ( ) {
114- let options = Array . from ( document . getElementById ( 'pollOptionsTBody' ) . rows )
114+ const options = Array . from ( document . getElementById ( 'pollOptionsTBody' ) . rows )
115115 . filter ( row => row . childElementCount != 1 ) // filter out the last row with the add button
116116 . map ( row => ( {
117117 name : row . children [ 0 ] . getElementsByTagName ( 'input' ) [ 0 ] . value ,
118118 description : row . children [ 1 ] . getElementsByTagName ( 'input' ) [ 0 ] . value ,
119119 } ) ) ;
120- let data = {
120+ const createPollRecipient = ( recipient ) => {
121+ recipient = recipient . trim ( ) ;
122+ if ( recipient . split ( '@' ) . length === 1 && / ^ \d + $ / . test ( recipient . split ( '@' ) [ 0 ] ) ) {
123+ return recipient . concat ( '@student.pwr.edu.pl' ) ;
124+ }
125+ return recipient ;
126+ }
127+ const data = {
121128 name : val ( 'pollName' ) ,
122129 options : JSON . stringify ( options ) ,
123130 choiceType : 'multiple-choice' ,
124- recipients : JSON . stringify ( pollRecipients . value . split ( '\n' ) . filter ( email => email . length != 0 ) . map ( email => email . trim ( ) ) ) ,
131+ recipients : JSON . stringify ( pollRecipients . value . split ( '\n' ) . filter ( email => email . length != 0 ) . map ( recipient => createPollRecipient ( recipient ) ) ) ,
125132 closesOnDate : val ( 'pollClosesOnDate' ) + ' ' + val ( 'pollClosesOnTime' ) ,
126133 visibility : 'private' ,
127134 mailTemplate : val ( 'pollMailTemplate' ) ,
0 commit comments