diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java index 369d649..096ac62 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -25,16 +25,6 @@ import java.util.concurrent.ExecutionException; @Controller public class VotingController { - - @Value("motto") - String motto; - - @Value("adding") - String adding; - - @Value("voting") - String voting; - private boolean votingPhase = false; private boolean mottoPhase = false; private boolean addingPhase = false; @@ -67,8 +57,8 @@ public class VotingController { @PostConstruct public void init() { mottoPhase = false; - votingPhase = false; - addingPhase = true; + votingPhase = true; + addingPhase = false; LOGGER.info("Program started with arguments: votingPhase="+ votingPhase + " mottoPhase=" + mottoPhase + " addingPhase=" + addingPhase); @@ -127,7 +117,6 @@ public class VotingController { return "errors/alreadyVoted.html"; } else { if (authCodesRepository.findByName(name) == null) { - LOGGER.warn("no code"); AuthCode authCode = tableAction.generateToken(name, RandomNumber.getRandomNumberString(), authCodesRepository); sendSimpleMessage(name, "Code zur Authentifizierung", "Dein Code lautet: " + authCode.getCode()); } else if (authCodesRepository.findByName(name) != null && authCodesRepository.findByName(name).isExpired()) { @@ -164,7 +153,6 @@ public class VotingController { @RequestMapping("/vote") public String voting_adding(@RequestParam String code, @RequestParam String name, Model model) { String tokenStatus = tableAction.checkToken(name, code, authCodesRepository); - LOGGER.warn(code); if (tokenStatus.equals("matched")) { LOGGER.warn("matched"); if (mottoPhase) { @@ -244,15 +232,17 @@ public class VotingController { @RequestMapping("/processVote") public String ProcessVote(@RequestParam String name, @RequestParam String voteValues) { - if (voterRepository.findByEmail(name).getCandidatesubmit_status()) { - return "errors/alreadySubmitted.html"; + if (voterRepository.findByEmail(name).getVote_status()) { + return "errors/alreadyVoted.html"; } else { - String[] partVoteValues = voteValues.split(","); - for (String s : partVoteValues) { - tableAction.voteForCandidate(s, candidateRepository); + if(!voteValues.equals("")) { + String[] partVoteValues = voteValues.split(","); + for (String s : partVoteValues) { + tableAction.voteForCandidate(s, candidateRepository); + } + LOGGER.info(name + " has voted!"); } tableAction.updateVotingStatus(name, voterRepository); - LOGGER.info(name + " has voted!"); return "voteSuccessful.html"; } } diff --git a/src/main/resources/templates/errors/alreadyVoted.html b/src/main/resources/templates/errors/alreadyVoted.html index ad4dc2b..2fafb30 100644 --- a/src/main/resources/templates/errors/alreadyVoted.html +++ b/src/main/resources/templates/errors/alreadyVoted.html @@ -10,7 +10,6 @@

Du hast schon abgestimmt!

-

Nächste Abstimmung in:

@@ -18,28 +17,6 @@ document.getElementById("backButton").onclick = function() { location.href = "/"; }; - - const zeroPad = (num, places) => String(num).padStart(places, '0') - - // We can set endTime to whatever we want here (e.g. Midnight today ) - // Use moment().endOf('day') to do this. - var dateFuture = new Date(2020, 11, 28, 0, 0); - - // Show time remaining now. - showTimeRemaining(); - - // Set a timer to update the displayed clock every 1000 milliseconds. - setInterval(showTimeRemaining, 1000); - - function showTimeRemaining() { - var dateNow = Date.now(); - var days = zeroPad(Math.floor((dateFuture - dateNow) / (1000 * 60 * 60 * 24)), 2); - var hours = zeroPad(Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24) / (1000 * 60 * 60)), 2); - var mins = zeroPad(Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60) / (1000 * 60)), 2); - var secs = zeroPad(Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60 - mins * 1000 * 60) / 1000), 2); - document.getElementById("time_remain").innerHTML = "Nächste Abstimmung in: " + days + "D " + hours + ":" + mins + ":" + secs; - console.log("Nächste Abstimmung in: " + days + "D " + hours + ":" + mins + ":" + secs); - } diff --git a/src/main/resources/templates/voteSuccessful.html b/src/main/resources/templates/voteSuccessful.html index 777a7b7..3d74f7d 100644 --- a/src/main/resources/templates/voteSuccessful.html +++ b/src/main/resources/templates/voteSuccessful.html @@ -11,7 +11,6 @@

Deine Auswahl fließt nun in die Wahl ein!

Danke fürs abstimmen!

-

Nächste Abstimmung in:

@@ -20,28 +19,6 @@ document.getElementById("backButton").onclick = function() { location.href = "/"; }; - - const zeroPad = (num, places) => String(num).padStart(places, '0') - - // We can set endTime to whatever we want here (e.g. Midnight today ) - // Use moment().endOf('day') to do this. - var dateFuture = new Date(2020, 11, 28, 0, 0); - - // Show time remaining now. - showTimeRemaining(); - - // Set a timer to update the displayed clock every 1000 milliseconds. - setInterval(showTimeRemaining, 1000); - - function showTimeRemaining() { - var dateNow = Date.now(); - var days = zeroPad(Math.floor((dateFuture - dateNow) / (1000 * 60 * 60 * 24)), 2); - var hours = zeroPad(Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24) / (1000 * 60 * 60)), 2); - var mins = zeroPad(Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60) / (1000 * 60)), 2); - var secs = zeroPad(Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60 - mins * 1000 * 60) / 1000), 2); - document.getElementById("time_remain").innerHTML = "Nächste Abstimmung in: " + days + "D " + hours + ":" + mins + ":" + secs; - console.log("Nächste Abstimmung in: " + days + "D " + hours + ":" + mins + ":" + secs); - } \ No newline at end of file