From 11e29062718cc91999014b628a138e851c11e1d1 Mon Sep 17 00:00:00 2001 From: Simon Bussmann Date: Sun, 27 Dec 2020 23:23:41 +0100 Subject: [PATCH] Added a datelock to end votes automatically --- .../controller/VotingController.java | 13 +++++++++- .../templates/errors/votingClosed.html | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/templates/errors/votingClosed.html 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 096ac62..17b1be8 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -19,6 +19,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.PostConstruct; +import java.time.LocalDate; +import java.time.Month; import java.util.*; import java.util.concurrent.ExecutionException; @@ -85,7 +87,16 @@ public class VotingController { @RequestMapping("/") public String WelcomeSite() { - return "start.html"; + LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,8); + LocalDate now = LocalDate.now(); + + if(now.isAfter(finishDate)){ + LOGGER.warn("passed"); + return "errors/votingClosed.html"; + } else { + LOGGER.warn("in Bounds"); + return "start.html"; + } } public void sendSimpleMessage(String to, String subject, String text) { diff --git a/src/main/resources/templates/errors/votingClosed.html b/src/main/resources/templates/errors/votingClosed.html new file mode 100644 index 0000000..5c5e830 --- /dev/null +++ b/src/main/resources/templates/errors/votingClosed.html @@ -0,0 +1,24 @@ + + + + + + Title + + + + +
+

Das Voting wurde beendet!

+

Informationen zu Votings sind der Adolfinumwebsite zu entnehmen

+ +
+ + + + + \ No newline at end of file