From 3be9c3b66554138762b87e5704364620c90bbf08 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 13 Dec 2020 17:09:08 +0100 Subject: [PATCH 01/32] Css changes to start site --- src/main/resources/static/styles/start.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/static/styles/start.css b/src/main/resources/static/styles/start.css index 7831a91..2584a79 100644 --- a/src/main/resources/static/styles/start.css +++ b/src/main/resources/static/styles/start.css @@ -17,10 +17,10 @@ div.userLogin { input.email_input { background-color: transparent; border: transparent; - border-bottom: 2px solid red; + border-bottom: 2px solid greenyellow; color: #FFF; font-size: xx-large; - width: fit-content; + width: 100%; } input.password_input { From 97a13135242f8ae16dd77a1f679e1b0773c3b5c8 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 13 Dec 2020 17:20:42 +0100 Subject: [PATCH 02/32] Fixed email input bug --- src/main/resources/static/styles/start.css | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/resources/static/styles/start.css b/src/main/resources/static/styles/start.css index 2584a79..a550712 100644 --- a/src/main/resources/static/styles/start.css +++ b/src/main/resources/static/styles/start.css @@ -20,7 +20,7 @@ input.email_input { border-bottom: 2px solid greenyellow; color: #FFF; font-size: xx-large; - width: 100%; + width: fit-content; } input.password_input { @@ -50,10 +50,4 @@ label { border-radius: 12px; box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); -} - -@media only screen and (max-device-width: 1024px) { - input.email_input { - font-size: large; - } } \ No newline at end of file From 3e69fcf97fb54e836d58f1d284628f2156ad473a Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 13 Dec 2020 17:25:27 +0100 Subject: [PATCH 03/32] Make input field static --- src/main/resources/static/styles/start.css | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/resources/static/styles/start.css b/src/main/resources/static/styles/start.css index a550712..203e8a7 100644 --- a/src/main/resources/static/styles/start.css +++ b/src/main/resources/static/styles/start.css @@ -14,28 +14,6 @@ div.userLogin { transform: translate(-50%, -50%); } -input.email_input { - background-color: transparent; - border: transparent; - border-bottom: 2px solid greenyellow; - color: #FFF; - font-size: xx-large; - width: fit-content; -} - -input.password_input { - background-color: transparent; - border: transparent; - color: #FFF; - font-size: medium; - width: fit-content; -} - -label { - color: #FFF; - display: block; -} - #signup_button { display: block; margin: auto; @@ -50,4 +28,26 @@ label { border-radius: 12px; box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); +} + +input.email_input { + background-color: transparent; + border: transparent; + border-bottom: 2px solid greenyellow; + color: #FFF; + font-size: xx-large; + width: 500px; +} + +input.password_input { + background-color: transparent; + border: transparent; + color: #FFF; + font-size: medium; + width: fit-content; +} + +label { + color: #FFF; + display: block; } \ No newline at end of file From e863d288ee00b3a98f7de651c1e2e23b6d6e2b3d Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 13 Dec 2020 21:29:33 +0100 Subject: [PATCH 04/32] Changed categories --- .../controller/VotingController.java | 6 +- src/main/resources/Categories.txt | 68 ++++++++++++++++--- 2 files changed, 65 insertions(+), 9 deletions(-) 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 a24e857..7dc6779 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -27,8 +27,10 @@ public class VotingController { @Value("motto") String motto; + @Value("adding") String adding; + @Value("voting") String voting; @@ -64,7 +66,9 @@ public class VotingController { @PostConstruct public void init() { if (motto != null){ - mottoPhase = true; + mottoPhase = false; + addingPhase = true; + votingPhase = false; } else if (adding != null){ addingPhase = true; } else if (voting != null){ diff --git a/src/main/resources/Categories.txt b/src/main/resources/Categories.txt index 143e51d..3bef5c5 100644 --- a/src/main/resources/Categories.txt +++ b/src/main/resources/Categories.txt @@ -16,21 +16,73 @@ Wer saß am längsten im Klassenschrank? (Schüler) Wer hat die gößte Sauklaue? (Leherer) Wer gründet das nächste Google? (Schüler) Wer kommt am schnellsten in den Knast? (Schüler) -Top 3-Pärchen? (Schüler) -Top 3 Lehrergespanne? (Schüler) +Bestes Pärchen? (Schüler) +Bestes Lehrergespann? Wer ist der motiviertester Lehrer? -Wer ist Google auf zwei Beinen(Schüler)? +Wer ist Google auf zwei Beinen? (Schüler) Wer hat den besten Style (Schüler)? Wer hat den besten Style (Lehrer)? Wer währe ein gutes Pärchen (Lehrer)? -Wer trinkt am meisten Kaffe (Schüler)? -Wer trinkt am meisten Kaffe (Lehrer)? -Tischflip? +(delete) Wer trinkt am meisten Kaffe (Schüler)? +(delete) Wer trinkt am meisten Kaffe (Lehrer)? +Tischflip Wer wird Harzer? Wer hat Wiedererkennungswert (Schüler)? Wen erkennt man an der Lache (Schüler)? Wer bringt die dümmsten Witze? (Lehrer) Wer hat den meisten Schwachsinn erzählt? (Lehrer) Welche Lehrer machen nie das, was die Schüler wollten? (Lehrer) -Wer isst immer? (Lehrer) -Wer hat die meisten peinlichen Momente gebracht? \ No newline at end of file +Wer isst immer? (Schüler) +Wer hat die meisten peinlichen Momente gebracht? + +Vorschläge der Stufe: +Toxic +Unvergesslich +Größter Klugscheißer +Braucht eine neue Leber +Future Celebrity +Pornhub als Abendbeschäftigung (Sehr gut :joy:) +Größte/r Schnorrer/in +Hat gefühlt die meisten Fehlstunden +Beste/r Schwiegersohn/-tochter +Fitnesskanone +Größte Diva +Beautyguru +Der Stufenclown +Größter Tollpatsch +Weltherrschaft 2040 +Größte Schlafmütze +Heiratet bald +Größte Labertasche +Sonnenschein +Kleinster Aufwand, größter Erfolg +Stufenmama/-papa +Ehre wem Ehre gebürt - Der/Die Netteste +Ziemlich beste Freunde +Am faulsten +Immer zu spät +Am ehrgeizigsten +Schwärzeste Lunge +Nobelpreisträger +Lehrers Liebling +For Kanzleramt +Wird als erstes Mutter/Vater +Sieht aus wie in der fünften Klasse +Als erstes im Gefängnis +Größte/r Schleimer/in +Hat sich durchgemogelt +Scheitert bei Jauch an der 100€ Frage +Checkt den Witz als letztes +Größter Bonze +Wohnt mit 40 noch bei Mutti +Verdient später am meisten +Lehrerschreck +Größte Veränderung +Augenschmaus (W) +Augenschmaus (M) +Lästermaul +Hat nie Hausaufgaben +Ist wirklich intelligent +Notenwürfler +Macht alles außer Unterricht +Übermotiviert \ No newline at end of file From 7aff0c5b02dce0abe1f2396fe5369f349f2c8bf5 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 16 Dec 2020 20:03:14 +0100 Subject: [PATCH 05/32] Test --- src/main/resources/Categories.txt | 88 +++++-------------- .../styles/alreadysubmittedcandidates.css | 65 ++++++++++++++ src/main/resources/static/styles/start.css | 2 +- .../errors/alreadysubmittedcandidates.html | 10 ++- src/main/resources/templates/test.html | 66 -------------- 5 files changed, 94 insertions(+), 137 deletions(-) create mode 100644 src/main/resources/static/styles/alreadysubmittedcandidates.css delete mode 100644 src/main/resources/templates/test.html diff --git a/src/main/resources/Categories.txt b/src/main/resources/Categories.txt index 3bef5c5..676c71e 100644 --- a/src/main/resources/Categories.txt +++ b/src/main/resources/Categories.txt @@ -1,88 +1,42 @@ -Wer wird nie von zuhause ausziehen? -Wer ist der/die kreativste Zuspätkommer/in? -Mit wem wird man am ehesten in der Zukunft angeben zur Schule gegangen zu sein? -Wer wohnt im Fittnessstudio? (Schüler) -Wer ist der coolste Leherer? -Wer ist die coolste Lehrerin? -Wer macht den besten Matheunterricht? -Welcher Lehrer hat den Beruf verfehlt? -Welcher Lehrer ist nie da? -Wer hat das Internet erfunden? -Wer sponsort Schollin? (Schüler) -Wer ist am engagiertesten? (Schüler) -Wer wird Bundeskanzler? (Schüler) -Wer hat das Kimpeltum gegründet? (Schüler) -Wer saß am längsten im Klassenschrank? (Schüler) -Wer hat die gößte Sauklaue? (Leherer) -Wer gründet das nächste Google? (Schüler) -Wer kommt am schnellsten in den Knast? (Schüler) -Bestes Pärchen? (Schüler) -Bestes Lehrergespann? -Wer ist der motiviertester Lehrer? -Wer ist Google auf zwei Beinen? (Schüler) -Wer hat den besten Style (Schüler)? -Wer hat den besten Style (Lehrer)? -Wer währe ein gutes Pärchen (Lehrer)? -(delete) Wer trinkt am meisten Kaffe (Schüler)? -(delete) Wer trinkt am meisten Kaffe (Lehrer)? -Tischflip -Wer wird Harzer? -Wer hat Wiedererkennungswert (Schüler)? -Wen erkennt man an der Lache (Schüler)? -Wer bringt die dümmsten Witze? (Lehrer) -Wer hat den meisten Schwachsinn erzählt? (Lehrer) -Welche Lehrer machen nie das, was die Schüler wollten? (Lehrer) -Wer isst immer? (Schüler) -Wer hat die meisten peinlichen Momente gebracht? - -Vorschläge der Stufe: -Toxic -Unvergesslich +Nesthocker +Beste Ausreden +Mathegötter (erklärend) +Falscher Beruf +Verfressenste +Ehre wem Ehre gebührt - Die Engagiertesten +Verhandlungskünstler +Stufenclown +Größte Sauklaue (Lehrer) +Knacki +Traumpaar (Schüler) +Lehrerbuddies +Lebt den Beruf +Lexikon (Schüler) +Harzer +Unvergesslich (Schüler) +Unvergesslich (Lehrer) +Schülerschreck Größter Klugscheißer -Braucht eine neue Leber Future Celebrity -Pornhub als Abendbeschäftigung (Sehr gut :joy:) +Pornhub als Abendbeschäftigung Größte/r Schnorrer/in Hat gefühlt die meisten Fehlstunden -Beste/r Schwiegersohn/-tochter -Fitnesskanone Größte Diva -Beautyguru -Der Stufenclown -Größter Tollpatsch -Weltherrschaft 2040 -Größte Schlafmütze -Heiratet bald +Weltherrschaft 2040 (Schüler) Größte Labertasche Sonnenschein Kleinster Aufwand, größter Erfolg -Stufenmama/-papa -Ehre wem Ehre gebürt - Der/Die Netteste Ziemlich beste Freunde Am faulsten Immer zu spät -Am ehrgeizigsten -Schwärzeste Lunge -Nobelpreisträger Lehrers Liebling -For Kanzleramt -Wird als erstes Mutter/Vater -Sieht aus wie in der fünften Klasse -Als erstes im Gefängnis -Größte/r Schleimer/in -Hat sich durchgemogelt -Scheitert bei Jauch an der 100€ Frage -Checkt den Witz als letztes +Gleich geblieben Größter Bonze -Wohnt mit 40 noch bei Mutti Verdient später am meisten Lehrerschreck -Größte Veränderung Augenschmaus (W) Augenschmaus (M) Lästermaul -Hat nie Hausaufgaben -Ist wirklich intelligent Notenwürfler Macht alles außer Unterricht Übermotiviert \ No newline at end of file diff --git a/src/main/resources/static/styles/alreadysubmittedcandidates.css b/src/main/resources/static/styles/alreadysubmittedcandidates.css new file mode 100644 index 0000000..e0ff00c --- /dev/null +++ b/src/main/resources/static/styles/alreadysubmittedcandidates.css @@ -0,0 +1,65 @@ +body { + background-color: rgb(44, 49, 54); + font-family: Arial, Helvetica, sans-serif; +} + +.center-screen { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; +} + +.centered { + background: transparent; + margin: 0 auto; + padding: 20px; + width: 100%; + overflow: auto; +} + +h1 { + color: #FFF; + font-size: 75px; +} + +h2.categoryHeader { + color: #FFF; + font-size: 50px; +} + +button { + background: transparent; + border: none; + color: #FFF; + font-size: 35px; + font-weight: normal; + letter-spacing: .125rem; + text-transform: uppercase; + text-align: center; + transition: opacity .25s .5s; +} + +.submitButton { + margin-top: 5%; + padding: .25em 0; + border: 0; + outline: 0; + background: #bb1515; + color: rgba(255, 255, 255, 0.85); + font-size: 2rem; + width: 500px; + letter-spacing: .0625rem; + border-radius: 12px; + box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); + text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); +} + +html, +body { + width: 100%; + height: 100%; + background-image: linear-gradient(to bottom right, #111E25 0%, #111 100%); + font-family: 'Lato', sans-serif; +} \ No newline at end of file diff --git a/src/main/resources/static/styles/start.css b/src/main/resources/static/styles/start.css index 203e8a7..76a47b8 100644 --- a/src/main/resources/static/styles/start.css +++ b/src/main/resources/static/styles/start.css @@ -33,7 +33,7 @@ div.userLogin { input.email_input { background-color: transparent; border: transparent; - border-bottom: 2px solid greenyellow; + border-bottom: 2px solid #bb1515; color: #FFF; font-size: xx-large; width: 500px; diff --git a/src/main/resources/templates/errors/alreadysubmittedcandidates.html b/src/main/resources/templates/errors/alreadysubmittedcandidates.html index e976e5b..0a30965 100644 --- a/src/main/resources/templates/errors/alreadysubmittedcandidates.html +++ b/src/main/resources/templates/errors/alreadysubmittedcandidates.html @@ -4,11 +4,15 @@ Title + - -

Du hast deine Kandidaten schon vorgeschlagen!

- Return to Login-Site + +
+

Du hast deine Kandidaten schon vorgeschlagen!

+ Return to Login-Site + +
\ No newline at end of file diff --git a/src/main/resources/templates/test.html b/src/main/resources/templates/test.html deleted file mode 100644 index 77b50c0..0000000 --- a/src/main/resources/templates/test.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - Abizeitung 2020/2021 Voting - - - - -

Paragraphes

-

This is a paragraph.

-

This is another paragraph.

- -

Links

- This is a link - -

HTML Images

-

HTML images are defined with the img tag:

- Binary example picture - -

Line breaks

-

This is a
paragraph with a line break.

- -

Styling

-

This is a red paragraph.

- -

Title attribute

-

This is a paragraph.

- -

Quotes in attributes

-

Example 1

-

Example 2

- -

Bigger headings

-

Heading 1

- -

HTML Display

-

- This paragraph contains a lot of lines in the source code, but the browser ignores it. -

-

- This paragraph contains a lot of spaces in the source code, but the browser ignores it. -

- -

Poem Problem

-

- My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me. -

- -
Solution:
-
-            My Bonnie lies over the ocean.
-          
-            My Bonnie lies over the sea.
-          
-            My Bonnie lies over the ocean.
-          
-            Oh, bring back my Bonnie to me.
-    
- - - - - - \ No newline at end of file From b48453c3006494e6610104424e0725912b850c50 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 16 Dec 2020 23:41:53 +0100 Subject: [PATCH 06/32] test --- .../controller/VotingController.java | 18 ++--------- .../entities/AuthCode.java | 2 +- .../styles/alreadysubmittedcandidates.css | 18 ----------- .../errors/alreadysubmittedcandidates.html | 30 +++++++++++++++++-- 4 files changed, 31 insertions(+), 37 deletions(-) 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 7dc6779..dad5b36 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -65,21 +65,9 @@ public class VotingController { @PostConstruct public void init() { - if (motto != null){ - mottoPhase = false; - addingPhase = true; - votingPhase = false; - } else if (adding != null){ - addingPhase = true; - } else if (voting != null){ - votingPhase = true; - } - - -// //TODO: TESTING REMOVE ON SHIPPING -// votingPhase = false; -// mottoPhase = true; -// addingPhase = false; + mottoPhase = false; + votingPhase = false; + addingPhase = true; LOGGER.info("Program started with arguments: votingPhase="+ votingPhase + " mottoPhase=" + mottoPhase + " addingPhase=" + addingPhase); diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java index 84ab6ce..1e1db47 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java @@ -38,7 +38,7 @@ public class AuthCode { } public boolean isExpired(){ - return System.currentTimeMillis() >= (time + 600*1000); + return System.currentTimeMillis() >= (time + 1800*1000); } public void setTime(long time) { diff --git a/src/main/resources/static/styles/alreadysubmittedcandidates.css b/src/main/resources/static/styles/alreadysubmittedcandidates.css index e0ff00c..9e57561 100644 --- a/src/main/resources/static/styles/alreadysubmittedcandidates.css +++ b/src/main/resources/static/styles/alreadysubmittedcandidates.css @@ -24,25 +24,7 @@ h1 { font-size: 75px; } -h2.categoryHeader { - color: #FFF; - font-size: 50px; -} - -button { - background: transparent; - border: none; - color: #FFF; - font-size: 35px; - font-weight: normal; - letter-spacing: .125rem; - text-transform: uppercase; - text-align: center; - transition: opacity .25s .5s; -} - .submitButton { - margin-top: 5%; padding: .25em 0; border: 0; outline: 0; diff --git a/src/main/resources/templates/errors/alreadysubmittedcandidates.html b/src/main/resources/templates/errors/alreadysubmittedcandidates.html index 0a30965..c7749b8 100644 --- a/src/main/resources/templates/errors/alreadysubmittedcandidates.html +++ b/src/main/resources/templates/errors/alreadysubmittedcandidates.html @@ -9,10 +9,34 @@
-

Du hast deine Kandidaten schon vorgeschlagen!

- Return to Login-Site - +

Du hast schon abgestimmt!

+

Nächste Abstimmung in:

+
+ + \ No newline at end of file From 629d4076f8c9c31001951e7ccb59e2c9e4c6b1f4 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 16 Dec 2020 23:49:50 +0100 Subject: [PATCH 07/32] fixed bug --- .../templates/errors/alreadysubmittedcandidates.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/resources/templates/errors/alreadysubmittedcandidates.html b/src/main/resources/templates/errors/alreadysubmittedcandidates.html index c7749b8..99868c8 100644 --- a/src/main/resources/templates/errors/alreadysubmittedcandidates.html +++ b/src/main/resources/templates/errors/alreadysubmittedcandidates.html @@ -31,11 +31,13 @@ function showTimeRemaining() { var dateNow = Date.now(); - var days = Math.floor((dateFuture - dateNow) / (1000 * 60 * 60 * 24)) - var hours = Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24) / (1000 * 60 * 60)) - var mins = Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60) / (1000 * 60)) - var secs = Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60 - mins * 1000 * 60) / 1000) + var days = Math.floor((dateFuture - dateNow) / (1000 * 60 * 60 * 24)); + var hours = Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24) / (1000 * 60 * 60)); + var mins = Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60) / (1000 * 60)); + var secs = Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60 - mins * 1000 * 60) / 1000); 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); + } From cf138cd8cff90b7848da059cdc70892744881987 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 17 Dec 2020 03:11:28 +0100 Subject: [PATCH 08/32] Must function now Email is down --- .../controller/VotingController.java | 41 ++++++++++++---- .../entities/AuthCode.java | 4 ++ .../table/TableAction.java | 5 +- ...mittedcandidates.css => allreadyVoted.css} | 4 ++ .../resources/static/styles/authenticate.css | 22 +++++++-- .../resources/templates/authenticate.html | 47 +++++++++++++++---- src/main/resources/templates/error.html | 24 ++++++++-- .../templates/errors/alreadyVoted.html | 40 ++++++++++++++-- .../errors/alreadyVotedForMotto.html | 14 ------ .../errors/alreadysubmittedcandidates.html | 44 ----------------- .../templates/errors/notRegistered.html | 20 ++++++-- 11 files changed, 172 insertions(+), 93 deletions(-) rename src/main/resources/static/styles/{alreadysubmittedcandidates.css => allreadyVoted.css} (97%) delete mode 100644 src/main/resources/templates/errors/alreadyVotedForMotto.html delete mode 100644 src/main/resources/templates/errors/alreadysubmittedcandidates.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 dad5b36..69f9923 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -20,6 +20,7 @@ import org.apache.logging.log4j.Logger; import javax.annotation.PostConstruct; import java.util.*; +import java.util.concurrent.ExecutionException; @Controller public class VotingController { @@ -110,16 +111,22 @@ public class VotingController { if (name.strip().toLowerCase().matches("[a-z]+\\.[a-z]+@adolfinum+\\.de$")) { try { LOGGER.warn(name); + try { + Voter voter = voterRepository.findByEmail(name.toLowerCase().strip()); + } catch (Exception e){ + LOGGER.error(name + " is not allowed to vote"); + return "errors/notRegistered.html"; + } Voter voter = voterRepository.findByEmail(name.toLowerCase().strip()); if (voter.getVote_status() && votingPhase) { LOGGER.warn(name + " has already voted"); return "errors/alreadyVoted.html"; } else if (voter.getCandidatesubmit_status() && addingPhase) { LOGGER.warn(name + " has already submitted its candidates"); - return "errors/alreadysubmittedcandidates.html"; + return "errors/alreadyVoted.html"; } else if (voter.getMotto_status() && mottoPhase) { LOGGER.warn(name + " has already chose their motto"); - return "errors/alreadyVotedForMotto.html"; + return "errors/alreadyVoted.html"; } else { if (authCodesRepository.findByName(name) == null) { LOGGER.warn("no code"); @@ -130,30 +137,43 @@ public class VotingController { sendSimpleMessage(name, "Code zur Authentifizierung", "Dein Code lautet: " + authCode.getCode()); } model.addAttribute("name", name); + model.addAttribute("codeTime", authCodesRepository.findByName(name).getExpirationTime()); model.addAttribute("codeExpired", false); model.addAttribute("codeFalse", false); return "authenticate.html"; } } catch (Exception e) { e.printStackTrace(); - LOGGER.error(name + " is not allowed to vote"); - return "errors/notRegistered.html"; + tableAction.deleteToken(name, authCodesRepository); + return "error.html"; } } else { return "errors/falseInput.html"; } } + @RequestMapping("/newCode") + public String provideNewCode(@RequestParam String name, Model model){ + AuthCode authCode = tableAction.generateToken(name, RandomNumber.getRandomNumberString(), authCodesRepository); + sendSimpleMessage(name, "Code zur Authentifizierung", "Dein Code lautet: " + authCode.getCode()); + model.addAttribute("name", name); + model.addAttribute("codeTime", authCodesRepository.findByName(name).getExpirationTime()); + model.addAttribute("codeExpired", false); + model.addAttribute("codeFalse", false); + return "authenticate.html"; + } + @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) { List mottos = mottoRepository.findAll(); model.addAttribute("mottos", mottos); model.addAttribute("name", name); + model.addAttribute("code", code); return "mottoVoting.html"; } else if (addingPhase) { PossibleCandidateWrapper possibleCandidates = new PossibleCandidateWrapper(); @@ -164,11 +184,13 @@ public class VotingController { model.addAttribute("categories", categories); model.addAttribute("form", possibleCandidates); model.addAttribute("name", name); + model.addAttribute("code", code); return "addingCandidates.html"; } else if (votingPhase) { List categories = categoryRepository.findAll(); model.addAttribute("categories", categories); model.addAttribute("name", name); + model.addAttribute("code", code); return "voting.html"; } } else if (tokenStatus.equals("expired")) { @@ -188,10 +210,11 @@ public class VotingController { } @RequestMapping("/saveCandidates") - public String candidateSaving(@ModelAttribute PossibleCandidateWrapper possibleCandidates, @RequestParam String name) { + public String candidateSaving(@ModelAttribute PossibleCandidateWrapper possibleCandidates, @RequestParam String name, @RequestParam String code) { if (voterRepository.findByEmail(name).getVote_status()) { return "errors/alreadyVoted.html"; } else { + authCodesRepository.delete(authCodesRepository.findByName(code)); LinkedList posCandidates = possibleCandidates.getPossibleCandidates(); long index = 1; for (PossibleCandidate posCandidate : posCandidates) { @@ -213,11 +236,12 @@ public class VotingController { } @RequestMapping("/saveMotto") - public String mottoSaving(@RequestParam String name, @RequestParam String voteValue) { + public String mottoSaving(@RequestParam String name, @RequestParam String voteValue, @RequestParam String code) { LOGGER.info(name); if (voterRepository.findByEmail(name).getMotto_status()) { return "errors/alreadySubmitted.html"; } else { + authCodesRepository.delete(authCodesRepository.findByName(code)); tableAction.voteForMotto(voteValue, mottoRepository); tableAction.updateMottoStatus(name, voterRepository); LOGGER.info(name + " has choose his motto"); @@ -226,10 +250,11 @@ public class VotingController { } @RequestMapping("/processVote") - public String ProcessVote(@RequestParam String name, @RequestParam String voteValues) { + public String ProcessVote(@RequestParam String name, @RequestParam String voteValues, @RequestParam String code) { if (voterRepository.findByEmail(name).getCandidatesubmit_status()) { return "errors/alreadySubmitted.html"; } else { + authCodesRepository.delete(authCodesRepository.findByName(code)); String[] partVoteValues = voteValues.split(","); for (String s : partVoteValues) { tableAction.voteForCandidate(s, candidateRepository); diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java index 1e1db47..846d666 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java @@ -37,6 +37,10 @@ public class AuthCode { return time; } + public long getExpirationTime(){ + return time + 1800*1000; + } + public boolean isExpired(){ return System.currentTimeMillis() >= (time + 1800*1000); } diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java index c2ce93a..c12a984 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java @@ -55,7 +55,6 @@ public class TableAction { try { AuthCode authCode = authCodesRepository.findByName(name); if (authCode.getCode().equals(code) && !authCode.isExpired()) { - authCodesRepository.delete(authCode); return "matched"; } else if (authCode.isExpired()) { authCodesRepository.delete(authCode); @@ -67,6 +66,10 @@ public class TableAction { return "wrong"; } + public void deleteToken(String name, AuthCodesRepository authCodesRepository){ + authCodesRepository.delete(authCodesRepository.findByName(name)); + } + private boolean fiveMinutesPassed(Long time){ return System.currentTimeMillis() >= (time + 300*1000); } diff --git a/src/main/resources/static/styles/alreadysubmittedcandidates.css b/src/main/resources/static/styles/allreadyVoted.css similarity index 97% rename from src/main/resources/static/styles/alreadysubmittedcandidates.css rename to src/main/resources/static/styles/allreadyVoted.css index 9e57561..4d4f997 100644 --- a/src/main/resources/static/styles/alreadysubmittedcandidates.css +++ b/src/main/resources/static/styles/allreadyVoted.css @@ -24,6 +24,10 @@ h1 { font-size: 75px; } +h2 { + color: #6d6d78; +} + .submitButton { padding: .25em 0; border: 0; diff --git a/src/main/resources/static/styles/authenticate.css b/src/main/resources/static/styles/authenticate.css index d2178b4..16f0640 100644 --- a/src/main/resources/static/styles/authenticate.css +++ b/src/main/resources/static/styles/authenticate.css @@ -21,9 +21,12 @@ body { } h1 { - margin-top: 5%; color: #FFF; - margin-bottom: 5%; +} + +h1.end { + color: #6d6d78; + margin-bottom: 2%; } h2 { @@ -41,7 +44,7 @@ input { .submitButton { margin-top: 5%; - margin-bottom: 5%; + margin-bottom: 1%; border: 0; outline: 0; background: #bb1515; @@ -54,6 +57,19 @@ input { text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); } +.newCode { + border: 0; + outline: 0; + background: #bb1515; + color: rgba(255, 255, 255, 0.85); + font-size: 1rem; + width: 250px; + letter-spacing: .0625rem; + border-radius: 12px; + box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); + text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); +} + .errorCode { margin-top: 10%; color: #bb1515; diff --git a/src/main/resources/templates/authenticate.html b/src/main/resources/templates/authenticate.html index d20b486..f57a703 100644 --- a/src/main/resources/templates/authenticate.html +++ b/src/main/resources/templates/authenticate.html @@ -10,14 +10,9 @@ - -

+

Nicht wundern das kann ein wenig dauern!

+

Bitte gebe den Authentifizierungscode ein

@@ -28,11 +23,18 @@ -
+ + +
+ + +
+ +
-

Der Code ist nicht mehr gültig!
Fordere einen neuen an

+

Der Code ist nicht mehr gültig!

@@ -76,6 +78,33 @@ output.value = code; document.getElementById("passForm").submit(); } + + function updateCounter(time) { + const zeroPad = (num, places) => String(num).padStart(places, '0') + + // Show time remaining now. + showTimeRemaining(); + + var dateFuture = time; + console.log(dateFuture); + + // Set a timer to update the displayed clock every 1000 milliseconds. + var updateTimeLoop = 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 = "Der Code gilt noch für " + mins + ":" + secs; + if (hours + mins + secs == 0) { + document.getElementById("time_remain").innerHTML = "Der Code ist abgelaufen"; + } + } + } + + updateCounter(document.getElementById("time_remain").innerHTML); diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html index 4e05b4b..dcf2207 100644 --- a/src/main/resources/templates/error.html +++ b/src/main/resources/templates/error.html @@ -1,10 +1,24 @@ - + - -

Something went wrong!

-

Our Engineers are on it

- Go Home + + + Title + + + + +
+

Oops irgendwas ist kaputt gegangen

+

Keine Sorge!
Probiers nochmal :D

+ +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/errors/alreadyVoted.html b/src/main/resources/templates/errors/alreadyVoted.html index e6cb039..ad4dc2b 100644 --- a/src/main/resources/templates/errors/alreadyVoted.html +++ b/src/main/resources/templates/errors/alreadyVoted.html @@ -3,12 +3,44 @@ - Abizeitung 2020/2021 Voting + Title + - -

Jeder darf nur einmal abstimmen!

- Return to Login-Site + +
+

Du hast schon abgestimmt!

+

Nächste Abstimmung in:

+ +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/errors/alreadyVotedForMotto.html b/src/main/resources/templates/errors/alreadyVotedForMotto.html deleted file mode 100644 index 572e139..0000000 --- a/src/main/resources/templates/errors/alreadyVotedForMotto.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - Title - - - -

Du hast deine Motto schon gewählt!

- Return to Login-Site - - - \ No newline at end of file diff --git a/src/main/resources/templates/errors/alreadysubmittedcandidates.html b/src/main/resources/templates/errors/alreadysubmittedcandidates.html deleted file mode 100644 index 99868c8..0000000 --- a/src/main/resources/templates/errors/alreadysubmittedcandidates.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - Title - - - - -
-

Du hast schon abgestimmt!

-

Nächste Abstimmung in:

- -
- - - - - \ No newline at end of file diff --git a/src/main/resources/templates/errors/notRegistered.html b/src/main/resources/templates/errors/notRegistered.html index 6ef3123..b8ce0b4 100644 --- a/src/main/resources/templates/errors/notRegistered.html +++ b/src/main/resources/templates/errors/notRegistered.html @@ -1,14 +1,24 @@ - + - Abizeitung 2020/2021 Voting + Title + - -

Überprüfe noch einmal die eingegebene E-Mail Adresse Sollte der Fall eintreten, dass du deine E-Mail Adresse richtig eingegeben hast und du Schüler der Q2 bist, schreibe eine Mail an simon.bussmann@adolfinum.de mit dem Betreff LoginFehler

- Return to Login-Site + +
+

Du bist nicht zur Wahl zugelassen!

+

Falls du abstimmen können solltest
schreibe eine Mail an ***REMOVED***

+ +
+ + \ No newline at end of file From 8f65d9cc267837265d0c654fe51cf9bcddc551ee Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 18 Dec 2020 18:57:29 +0100 Subject: [PATCH 09/32] Finishing touches --- src/main/resources/Categories.txt | 24 +++++++++---------- .../static/styles/addingCandidates.css | 10 ++++---- .../resources/templates/addingCandidates.html | 8 ++++++- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/main/resources/Categories.txt b/src/main/resources/Categories.txt index 676c71e..3974196 100644 --- a/src/main/resources/Categories.txt +++ b/src/main/resources/Categories.txt @@ -1,28 +1,21 @@ Nesthocker Beste Ausreden -Mathegötter (erklärend) -Falscher Beruf Verfressenste Ehre wem Ehre gebührt - Die Engagiertesten Verhandlungskünstler Stufenclown -Größte Sauklaue (Lehrer) Knacki -Traumpaar (Schüler) -Lehrerbuddies -Lebt den Beruf -Lexikon (Schüler) +Traumpaar +Lexikon Harzer -Unvergesslich (Schüler) -Unvergesslich (Lehrer) -Schülerschreck +Unvergesslich Größter Klugscheißer Future Celebrity Pornhub als Abendbeschäftigung Größte/r Schnorrer/in Hat gefühlt die meisten Fehlstunden Größte Diva -Weltherrschaft 2040 (Schüler) +Weltherrschaft 2040 Größte Labertasche Sonnenschein Kleinster Aufwand, größter Erfolg @@ -39,4 +32,11 @@ Augenschmaus (M) Lästermaul Notenwürfler Macht alles außer Unterricht -Übermotiviert \ No newline at end of file +Übermotiviert +Schülerschreck +Mathegötter (der/die beste Mathelehrer/in) +Falscher Beruf +Größte Sauklaue +Lehrerbuddies +Lebt den Beruf +Unvergesslich \ No newline at end of file diff --git a/src/main/resources/static/styles/addingCandidates.css b/src/main/resources/static/styles/addingCandidates.css index 10be17b..9aac8ac 100644 --- a/src/main/resources/static/styles/addingCandidates.css +++ b/src/main/resources/static/styles/addingCandidates.css @@ -20,15 +20,18 @@ body { } h1 { - margin-top: 5%; color: #FFF; - margin-bottom: 5%; } -h2.categoryHeader { +h2 { color: #FFF; } +h2.categoryCategory { + margin-top: 5%; + margin-bottom: 1%; +} + input { background: #bb1515b2; border: none; @@ -41,7 +44,6 @@ input { .submitButton { margin-top: 5%; - margin-bottom: 5%; border: 0; outline: 0; background: #bb1515; diff --git a/src/main/resources/templates/addingCandidates.html b/src/main/resources/templates/addingCandidates.html index 4db657a..aa7f958 100644 --- a/src/main/resources/templates/addingCandidates.html +++ b/src/main/resources/templates/addingCandidates.html @@ -42,8 +42,14 @@
+
+

Lehrer

+
+
+

Schüler

+

- +
From 14ab45227a7c46b004d1fb2018480a57d159518c Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 18 Dec 2020 19:04:12 +0100 Subject: [PATCH 10/32] Removed code pass through --- .../controller/VotingController.java | 12 +++--------- .../AbizeitungVotingSystem/table/TableAction.java | 1 + .../resources/static/styles/addingCandidates.css | 1 + 3 files changed, 5 insertions(+), 9 deletions(-) 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 69f9923..fe0669f 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -173,7 +173,6 @@ public class VotingController { List mottos = mottoRepository.findAll(); model.addAttribute("mottos", mottos); model.addAttribute("name", name); - model.addAttribute("code", code); return "mottoVoting.html"; } else if (addingPhase) { PossibleCandidateWrapper possibleCandidates = new PossibleCandidateWrapper(); @@ -184,13 +183,11 @@ public class VotingController { model.addAttribute("categories", categories); model.addAttribute("form", possibleCandidates); model.addAttribute("name", name); - model.addAttribute("code", code); return "addingCandidates.html"; } else if (votingPhase) { List categories = categoryRepository.findAll(); model.addAttribute("categories", categories); model.addAttribute("name", name); - model.addAttribute("code", code); return "voting.html"; } } else if (tokenStatus.equals("expired")) { @@ -210,11 +207,10 @@ public class VotingController { } @RequestMapping("/saveCandidates") - public String candidateSaving(@ModelAttribute PossibleCandidateWrapper possibleCandidates, @RequestParam String name, @RequestParam String code) { + public String candidateSaving(@ModelAttribute PossibleCandidateWrapper possibleCandidates, @RequestParam String name) { if (voterRepository.findByEmail(name).getVote_status()) { return "errors/alreadyVoted.html"; } else { - authCodesRepository.delete(authCodesRepository.findByName(code)); LinkedList posCandidates = possibleCandidates.getPossibleCandidates(); long index = 1; for (PossibleCandidate posCandidate : posCandidates) { @@ -236,12 +232,11 @@ public class VotingController { } @RequestMapping("/saveMotto") - public String mottoSaving(@RequestParam String name, @RequestParam String voteValue, @RequestParam String code) { + public String mottoSaving(@RequestParam String name, @RequestParam String voteValue) { LOGGER.info(name); if (voterRepository.findByEmail(name).getMotto_status()) { return "errors/alreadySubmitted.html"; } else { - authCodesRepository.delete(authCodesRepository.findByName(code)); tableAction.voteForMotto(voteValue, mottoRepository); tableAction.updateMottoStatus(name, voterRepository); LOGGER.info(name + " has choose his motto"); @@ -250,11 +245,10 @@ public class VotingController { } @RequestMapping("/processVote") - public String ProcessVote(@RequestParam String name, @RequestParam String voteValues, @RequestParam String code) { + public String ProcessVote(@RequestParam String name, @RequestParam String voteValues) { if (voterRepository.findByEmail(name).getCandidatesubmit_status()) { return "errors/alreadySubmitted.html"; } else { - authCodesRepository.delete(authCodesRepository.findByName(code)); String[] partVoteValues = voteValues.split(","); for (String s : partVoteValues) { tableAction.voteForCandidate(s, candidateRepository); diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java index c12a984..c1f07dd 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java @@ -55,6 +55,7 @@ public class TableAction { try { AuthCode authCode = authCodesRepository.findByName(name); if (authCode.getCode().equals(code) && !authCode.isExpired()) { + authCodesRepository.delete(authCode); return "matched"; } else if (authCode.isExpired()) { authCodesRepository.delete(authCode); diff --git a/src/main/resources/static/styles/addingCandidates.css b/src/main/resources/static/styles/addingCandidates.css index 9aac8ac..6d68b66 100644 --- a/src/main/resources/static/styles/addingCandidates.css +++ b/src/main/resources/static/styles/addingCandidates.css @@ -28,6 +28,7 @@ h2 { } h2.categoryCategory { + color: #bb1515; margin-top: 5%; margin-bottom: 1%; } From 506e2285fda69e6e5ad498466149a705703474b1 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 18 Dec 2020 19:25:40 +0100 Subject: [PATCH 11/32] End --- .../controller/VotingController.java | 2 +- .../static/styles/voteSuccessful.css | 54 +++++++++++++++++++ .../resources/templates/voteSuccessful.html | 41 +++++++++++++- 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/static/styles/voteSuccessful.css 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 fe0669f..8e98735 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -227,7 +227,7 @@ public class VotingController { index++; } tableAction.updateCandidatesubmit_status(name, voterRepository); - return "candidateAddingSuccessful.html"; + return "voteSuccessful.html"; } } diff --git a/src/main/resources/static/styles/voteSuccessful.css b/src/main/resources/static/styles/voteSuccessful.css new file mode 100644 index 0000000..faaa063 --- /dev/null +++ b/src/main/resources/static/styles/voteSuccessful.css @@ -0,0 +1,54 @@ +body { + background-color: rgb(44, 49, 54); + font-family: Arial, Helvetica, sans-serif; +} + +.center-screen { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; +} + +.centered { + background: transparent; + margin: 0 auto; + padding: 20px; + width: 100%; + overflow: auto; +} + +h1 { + color: #FFF; +} + +h2 { + color: #FFF; +} + +h2.time_remain { + color: #6d6d78; +} + +.submitButton { + padding: .25em 0; + border: 0; + outline: 0; + background: #bb1515; + color: rgba(255, 255, 255, 0.85); + font-size: 2rem; + width: 500px; + letter-spacing: .0625rem; + border-radius: 12px; + box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); + text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); +} + +html, +body { + width: 100%; + height: 100%; + background-image: linear-gradient(to bottom right, #111E25 0%, #111 100%); + font-family: 'Lato', sans-serif; +} \ No newline at end of file diff --git a/src/main/resources/templates/voteSuccessful.html b/src/main/resources/templates/voteSuccessful.html index 566549b..777a7b7 100644 --- a/src/main/resources/templates/voteSuccessful.html +++ b/src/main/resources/templates/voteSuccessful.html @@ -1,10 +1,47 @@ - + + Title + - + +
+

Deine Auswahl fließt nun in die Wahl ein!

+

Danke fürs abstimmen!

+

Nächste Abstimmung in:

+ +
+ + + \ No newline at end of file From be8d49ff9e5b405652320721bdff179b50998512 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 18 Dec 2020 20:01:54 +0100 Subject: [PATCH 12/32] Final --- src/main/resources/templates/addingCandidates.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/templates/addingCandidates.html b/src/main/resources/templates/addingCandidates.html index aa7f958..7d0c149 100644 --- a/src/main/resources/templates/addingCandidates.html +++ b/src/main/resources/templates/addingCandidates.html @@ -28,7 +28,7 @@ $('#inputForm div.group:nth-child(' + q + ')').hide(); $('#inputForm div.group:nth-child(' + (q + 1) + ')').show(); if (q == (qMax - 1)) { - $('#btnNext').html('Submit Answers'); + $('#btnNext').html('Eingabe bestätigen'); } q++; } else { @@ -52,7 +52,7 @@
- + From d1c8f24d3d859b301740ed24cb36e39355009468 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 18 Dec 2020 20:11:28 +0100 Subject: [PATCH 13/32] Fix error message --- .../AbizeitungVotingSystem/controller/VotingController.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 8e98735..369d649 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -111,13 +111,11 @@ public class VotingController { if (name.strip().toLowerCase().matches("[a-z]+\\.[a-z]+@adolfinum+\\.de$")) { try { LOGGER.warn(name); - try { - Voter voter = voterRepository.findByEmail(name.toLowerCase().strip()); - } catch (Exception e){ + Voter voter = voterRepository.findByEmail(name.toLowerCase().strip()); + if (voter == null){ LOGGER.error(name + " is not allowed to vote"); return "errors/notRegistered.html"; } - Voter voter = voterRepository.findByEmail(name.toLowerCase().strip()); if (voter.getVote_status() && votingPhase) { LOGGER.warn(name + " has already voted"); return "errors/alreadyVoted.html"; From ffea848311bddf5a09c8fcb01c590c7b146296b0 Mon Sep 17 00:00:00 2001 From: Simon Bussmann Date: Sun, 27 Dec 2020 22:37:20 +0100 Subject: [PATCH 14/32] Changed to Voting Mode --- .../controller/VotingController.java | 30 +++++++------------ .../templates/errors/alreadyVoted.html | 23 -------------- .../resources/templates/voteSuccessful.html | 23 -------------- 3 files changed, 10 insertions(+), 66 deletions(-) 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 From 11e29062718cc91999014b628a138e851c11e1d1 Mon Sep 17 00:00:00 2001 From: Simon Bussmann Date: Sun, 27 Dec 2020 23:23:41 +0100 Subject: [PATCH 15/32] 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 From 880dd12a6fb7bcdd8c1d8ee395208d335ffc81da Mon Sep 17 00:00:00 2001 From: Simon Bussmann Date: Sun, 27 Dec 2020 23:33:56 +0100 Subject: [PATCH 16/32] QOL --- src/main/resources/templates/voting.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/templates/voting.html b/src/main/resources/templates/voting.html index 9f90626..ab60204 100644 --- a/src/main/resources/templates/voting.html +++ b/src/main/resources/templates/voting.html @@ -62,7 +62,7 @@ $('#votingButtons div.voteDiv:nth-child(' + q + ')').hide(); $('#votingButtons div.voteDiv:nth-child(' + (q + 1) + ')').show(); if (q == (qMax - 1)) { - $('#btnNext').html('Submit Answers'); + $('#btnNext').html('Auswahl bestätigen'); } q++; } else { @@ -81,7 +81,7 @@ - +
From 0b9d5cc90ca637dce8850105ba66f407a724d3ce Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 29 Dec 2020 19:23:45 +0100 Subject: [PATCH 17/32] Updated Requierments --- src/main/resources/Categories.txt | 6 ++-- src/main/resources/Categories2.txt | 53 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/Categories2.txt diff --git a/src/main/resources/Categories.txt b/src/main/resources/Categories.txt index 3974196..b533b46 100644 --- a/src/main/resources/Categories.txt +++ b/src/main/resources/Categories.txt @@ -5,7 +5,7 @@ Ehre wem Ehre gebührt - Die Engagiertesten Verhandlungskünstler Stufenclown Knacki -Traumpaar +(x)Traumpaar Lexikon Harzer Unvergesslich @@ -26,10 +26,10 @@ Lehrers Liebling Gleich geblieben Größter Bonze Verdient später am meisten -Lehrerschreck +(x)Lehrerschreck Augenschmaus (W) Augenschmaus (M) -Lästermaul +Lästermaul (Gossip Girl) Notenwürfler Macht alles außer Unterricht Übermotiviert diff --git a/src/main/resources/Categories2.txt b/src/main/resources/Categories2.txt new file mode 100644 index 0000000..51986db --- /dev/null +++ b/src/main/resources/Categories2.txt @@ -0,0 +1,53 @@ +Sportler/in des Jahres +Best dressed student +Picasso Jr. +Verpeilt, verpeilter, ... +Große Klappe +Darf auf keiner Party fehlen +Stille Wasser sind tief +Patrick-Fragen-Steller +Ehrgeizig, ehrgeiziger, ... +Miss Make-Up +Meiste Punkte in Flensburg +Im Bundestag +Leber als Bimsstein +Bester Schwiegersohn +Beste Schwiegertochter +Lebt im Fitnessstudio +Koffeinjunkie +Erkennt man am Lachen +Dschungelkönig/in +Bei Geburt getrennte Zwillinge (Aussehen) +Future Rockstar +Schummelt sich durchs Abi +Organisationstalent +Gute Seele +Nobelpreisträger +Nachteule +Präsentationspro +Lehrerassistent für Technik +Meiste Screentime +Interessiert sich wirklich für den Unterricht +Kleiner Exentriker +Herrscht hart, aber gerecht +Niemand traut sich zu schwänzen +Man lernt nicht für die Schule sondern fürs Leben +Konntert am besten +Best dressed teacher +Eigentlich Motivationstrainer +Schlimmstes Tafelbild +Möchtegern Comedian +Führt ein Doppelleben +"Ich beende den Unterricht" +Schülerschwarm (M) +Schülerschwarm (W) +Harte Schale, weicher Kern +Sklaventreiber +Unterrichtet auch, wenn die Schule brennt +Ist immer da +Lebt in der Schule +Musste einen Wald für Arbeitsblätter roden lassen +Top gestylt + + + From 937971da634851080cd6f00fc6d7f003eb13e513 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 Jan 2021 00:28:55 +0100 Subject: [PATCH 18/32] Expanded the number of candidates from 5 to 10-15 --- .../controller/VotingController.java | 1 - .../table/TableAction.java | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) 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 17b1be8..c6b778f 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -22,7 +22,6 @@ import javax.annotation.PostConstruct; import java.time.LocalDate; import java.time.Month; import java.util.*; -import java.util.concurrent.ExecutionException; @Controller public class VotingController { diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java index c1f07dd..25117f8 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java @@ -71,12 +71,8 @@ public class TableAction { authCodesRepository.delete(authCodesRepository.findByName(name)); } - private boolean fiveMinutesPassed(Long time){ - return System.currentTimeMillis() >= (time + 300*1000); - } - private int getLimit(List possibleCandidates){ - return possibleCandidates.size() <= 5 ? possibleCandidates.size() : 5; + return possibleCandidates.size() <= 15 ? possibleCandidates.size() : 15; } public void voteForCandidate(String id, CandidateRepository candidateRepository){ @@ -123,8 +119,17 @@ public class TableAction { Collections.sort(possibleCandidatesPerCategory, Comparator.comparing(PossibleCandidate::getVotes)); Collections.reverse(possibleCandidatesPerCategory); for (int j = 0; j < getLimit(possibleCandidatesPerCategory); j++){ - Candidate candidate = new Candidate(possibleCandidatesPerCategory.get(j).getName(), possibleCandidatesPerCategory.get(j).getCategory()); - candidateRepository.save(candidate); + if (j >= 10 && possibleCandidatesPerCategory.get(j).getVotes() == possibleCandidatesPerCategory.get(j-1).getVotes()){ + Candidate candidate = new Candidate(possibleCandidatesPerCategory.get(j).getName(), possibleCandidatesPerCategory.get(j).getCategory()); + candidateRepository.save(candidate); + } + if (j < 10){ + Candidate candidate = new Candidate(possibleCandidatesPerCategory.get(j).getName(), possibleCandidatesPerCategory.get(j).getCategory()); + candidateRepository.save(candidate); + } + if (j == 14){ + break; + } } i += -1; possibleCandidatesPerCategory.clear(); From 149a0dece33593b034824c10b78e01d06430adf4 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 Jan 2021 02:22:00 +0100 Subject: [PATCH 19/32] Made final changes --- .../controller/VotingController.java | 73 ++++++++----------- .../entities/Motto.java | 58 --------------- .../entities/Voter.java | 8 -- .../repositories/MottoRepository.java | 14 ---- .../table/TableAction.java | 38 +--------- src/main/resources/Categories2.txt | 7 +- .../resources/templates/addingCandidates.html | 4 +- 7 files changed, 35 insertions(+), 167 deletions(-) delete mode 100644 src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Motto.java delete mode 100644 src/main/java/com/github/cato447/AbizeitungVotingSystem/repositories/MottoRepository.java 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 c6b778f..eb13216 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -6,7 +6,6 @@ import com.github.cato447.AbizeitungVotingSystem.helper.RandomNumber; import com.github.cato447.AbizeitungVotingSystem.repositories.*; import com.github.cato447.AbizeitungVotingSystem.table.TableAction; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.stereotype.Controller; @@ -26,9 +25,8 @@ import java.util.*; @Controller public class VotingController { - private boolean votingPhase = false; - private boolean mottoPhase = false; - private boolean addingPhase = false; + private boolean votingPhase; + private boolean addingPhase; private static final Logger LOGGER = LogManager.getLogger(VotingController.class); private TableAction tableAction = new TableAction(); @@ -42,9 +40,6 @@ public class VotingController { @Autowired CategoryRepository categoryRepository; - @Autowired - MottoRepository mottoRepository; - @Autowired PossibleCandidateRepository possibleCandidateRepository; @@ -57,11 +52,10 @@ public class VotingController { @PostConstruct public void init() { - mottoPhase = false; - votingPhase = true; - addingPhase = false; + votingPhase = false; + addingPhase = true; - LOGGER.info("Program started with arguments: votingPhase="+ votingPhase + " mottoPhase=" + mottoPhase + " addingPhase=" + addingPhase); + LOGGER.info("Program started with arguments: votingPhase="+ votingPhase + " addingPhase=" + addingPhase); if (voterRepository.findAll().size() == 0) { tableAction.setUpVoters(voterRepository); @@ -70,14 +64,10 @@ public class VotingController { if (categoryRepository.findAll().size() == 0) { tableAction.setUpCategories(categoryRepository); + possibleCandidateRepository.deleteAll(); LOGGER.info("Categories successfully set up"); } - if (mottoRepository.findAll().size() == 0){ - tableAction.setUpMottos(mottoRepository); - LOGGER.info("Mottos successfully set up"); - } - if (candidateRepository.findAll().size() == 0 && votingPhase == true && possibleCandidateRepository.findAll().size() != 0) { tableAction.setUpCandidates(possibleCandidateRepository, candidateRepository); LOGGER.info("Candidates successfully set up"); @@ -122,9 +112,6 @@ public class VotingController { } else if (voter.getCandidatesubmit_status() && addingPhase) { LOGGER.warn(name + " has already submitted its candidates"); return "errors/alreadyVoted.html"; - } else if (voter.getMotto_status() && mottoPhase) { - LOGGER.warn(name + " has already chose their motto"); - return "errors/alreadyVoted.html"; } else { if (authCodesRepository.findByName(name) == null) { AuthCode authCode = tableAction.generateToken(name, RandomNumber.getRandomNumberString(), authCodesRepository); @@ -165,12 +152,7 @@ public class VotingController { String tokenStatus = tableAction.checkToken(name, code, authCodesRepository); if (tokenStatus.equals("matched")) { LOGGER.warn("matched"); - if (mottoPhase) { - List mottos = mottoRepository.findAll(); - model.addAttribute("mottos", mottos); - model.addAttribute("name", name); - return "mottoVoting.html"; - } else if (addingPhase) { + if (addingPhase) { PossibleCandidateWrapper possibleCandidates = new PossibleCandidateWrapper(); List categories = categoryRepository.findAll(); for (int i = 0; i < categories.size(); i++) { @@ -204,54 +186,59 @@ public class VotingController { @RequestMapping("/saveCandidates") public String candidateSaving(@ModelAttribute PossibleCandidateWrapper possibleCandidates, @RequestParam String name) { - if (voterRepository.findByEmail(name).getVote_status()) { + if (voterRepository.findByEmail(name).getCandidatesubmit_status()) { return "errors/alreadyVoted.html"; } else { LinkedList posCandidates = possibleCandidates.getPossibleCandidates(); + LinkedList voteForPosCandidates = new LinkedList<>(); + LinkedList addToPosCandidates = new LinkedList<>(); long index = 1; for (PossibleCandidate posCandidate : posCandidates) { if (posCandidate.getName() != "") { if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null) { PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()); - p.setVotes(p.getVotes() + 1); - possibleCandidateRepository.save(p); + voteForPosCandidates.add(p); } else { + if(index > 31 && posCandidate.getName().indexOf(" ") != -1){ + posCandidate.setName(posCandidate.getName().split(" ")[1]); + } PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); - possibleCandidateRepository.save(possibleCandidate); + addToPosCandidates.add(possibleCandidate); } } index++; } + for (PossibleCandidate p: voteForPosCandidates) { + p.setVotes(p.getVotes() + 1); + possibleCandidateRepository.save(p); + } + + for (PossibleCandidate p: addToPosCandidates) { + possibleCandidateRepository.save(p); + } + tableAction.updateCandidatesubmit_status(name, voterRepository); return "voteSuccessful.html"; } } - @RequestMapping("/saveMotto") - public String mottoSaving(@RequestParam String name, @RequestParam String voteValue) { - LOGGER.info(name); - if (voterRepository.findByEmail(name).getMotto_status()) { - return "errors/alreadySubmitted.html"; - } else { - tableAction.voteForMotto(voteValue, mottoRepository); - tableAction.updateMottoStatus(name, voterRepository); - LOGGER.info(name + " has choose his motto"); - } - return "voteSuccessful.html"; - } - @RequestMapping("/processVote") public String ProcessVote(@RequestParam String name, @RequestParam String voteValues) { if (voterRepository.findByEmail(name).getVote_status()) { return "errors/alreadyVoted.html"; } else { + LinkedList voteFor = new LinkedList<>(); if(!voteValues.equals("")) { String[] partVoteValues = voteValues.split(","); for (String s : partVoteValues) { - tableAction.voteForCandidate(s, candidateRepository); + voteFor.add(s); } LOGGER.info(name + " has voted!"); } + for (String s: voteFor) { + tableAction.voteForCandidate(s, candidateRepository); + } + tableAction.updateVotingStatus(name, voterRepository); return "voteSuccessful.html"; } diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Motto.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Motto.java deleted file mode 100644 index e3d6334..0000000 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Motto.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.github.cato447.AbizeitungVotingSystem.entities; - -import javax.persistence.*; - -@Entity -@Table(name = "mottos") -public class Motto implements Comparable{ - - public Motto() { - super(); - } - - public Motto(String name) { - super(); - this.name = name; - this.votes = 0; - } - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - private String name; - - private Integer votes; - - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public Integer getVotes() { - return votes; - } - - public void setName(String name) { - this.name = name; - } - - public void setVotes(Integer votes) { - this.votes = votes; - } - - public void voteFor() { - this.votes += 1; - } - - @Override - public int compareTo(Motto m) { - if (getVotes() == null || m.getVotes() == null) { - return 0; - } - return m.getVotes().compareTo(getVotes()); - } -} diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Voter.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Voter.java index 3bbe10a..97a2c51 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Voter.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Voter.java @@ -14,7 +14,6 @@ public class Voter { this.email = email; this.vote_status = false; this.candidatesubmit_status = false; - this.motto_status = false; } @Id @@ -22,7 +21,6 @@ public class Voter { private Long id; private String email; private Boolean vote_status; - private Boolean motto_status; private Boolean candidatesubmit_status; public Long getId() { @@ -41,10 +39,6 @@ public class Voter { return candidatesubmit_status; } - public Boolean getMotto_status() { - return motto_status; - } - public void vote(){ vote_status = true; } @@ -52,6 +46,4 @@ public class Voter { public void submitCandidates() { candidatesubmit_status = true; } - - public void voteMotto() { motto_status = true;} } diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/repositories/MottoRepository.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/repositories/MottoRepository.java deleted file mode 100644 index 0d3ecb0..0000000 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/repositories/MottoRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.github.cato447.AbizeitungVotingSystem.repositories; - -import com.github.cato447.AbizeitungVotingSystem.entities.Motto; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.Optional; - -public interface MottoRepository extends JpaRepository { - - public Motto findByName(String name); - - Optional findById(Long id); - -} diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java index 25117f8..c4bc283 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java @@ -1,16 +1,9 @@ package com.github.cato447.AbizeitungVotingSystem.table; -import com.github.cato447.AbizeitungVotingSystem.controller.VotingController; import com.github.cato447.AbizeitungVotingSystem.entities.*; import com.github.cato447.AbizeitungVotingSystem.repositories.*; -import org.aspectj.weaver.loadtime.definition.LightXMLParser; import java.io.*; -import java.lang.reflect.Array; -import java.net.JarURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.nio.Buffer; import java.util.*; public class TableAction { @@ -31,12 +24,6 @@ public class TableAction { voterRepository.save(voter); } - public void updateMottoStatus(String email, VoterRepository voterRepository){ - Voter voter = voterRepository.findByEmail(email); - voter.voteMotto(); - voterRepository.save(voter); - } - public AuthCode generateToken(String name, String code, AuthCodesRepository authCodesRepository) { AuthCode authCode = new AuthCode(name, code); try{ @@ -82,13 +69,6 @@ public class TableAction { candidateRepository.save(candidate); } - public void voteForMotto(String id, MottoRepository mottoRepository){ - long mottoID = Long.valueOf(id); - Motto motto = mottoRepository.findById(mottoID).get(); - motto.voteFor(); - mottoRepository.save(motto); - } - public void setUpVoters(VoterRepository voterRepository){ try (InputStream inputStream = getClass().getResourceAsStream("/Q2_emails.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { @@ -142,7 +122,7 @@ public class TableAction { } public void setUpCategories(CategoryRepository categoryRepository){ - try (InputStream inputStream = getClass().getResourceAsStream("/Categories.txt"); + try (InputStream inputStream = getClass().getResourceAsStream("/Categories2.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { String line = ""; ArrayList categories = new ArrayList(); @@ -156,20 +136,4 @@ public class TableAction { e.printStackTrace(); } } - - public void setUpMottos(MottoRepository mottoRepository){ - try (InputStream inputStream = getClass().getResourceAsStream("/Mottos.txt"); - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { - String line = ""; - ArrayList mottos = new ArrayList<>(); - while ((line = reader.readLine())!= null){ - String name = line; - Motto motto = new Motto(name); - mottos.add(motto); - } - mottoRepository.saveAll(mottos); - } catch (IOException e) { - e.printStackTrace(); - } - } } diff --git a/src/main/resources/Categories2.txt b/src/main/resources/Categories2.txt index 51986db..204a4a2 100644 --- a/src/main/resources/Categories2.txt +++ b/src/main/resources/Categories2.txt @@ -10,7 +10,7 @@ Ehrgeizig, ehrgeiziger, ... Miss Make-Up Meiste Punkte in Flensburg Im Bundestag -Leber als Bimsstein +Bimsstein als Leber Bester Schwiegersohn Beste Schwiegertochter Lebt im Fitnessstudio @@ -47,7 +47,4 @@ Unterrichtet auch, wenn die Schule brennt Ist immer da Lebt in der Schule Musste einen Wald für Arbeitsblätter roden lassen -Top gestylt - - - +Top gestylt \ No newline at end of file diff --git a/src/main/resources/templates/addingCandidates.html b/src/main/resources/templates/addingCandidates.html index 7d0c149..908566b 100644 --- a/src/main/resources/templates/addingCandidates.html +++ b/src/main/resources/templates/addingCandidates.html @@ -42,10 +42,10 @@
-
+

Lehrer

-
+

Schüler

From 7ee603d5df7b2002dbe46e9ec1a39310c813454e Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 02:35:55 +0100 Subject: [PATCH 20/32] Added second voting --- .../controller/VotingController.java | 2 +- .../templates/errors/alreadyVoted.html | 33 ++++++++++++++++--- .../templates/errors/votingClosed.html | 4 +-- 3 files changed, 31 insertions(+), 8 deletions(-) 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 eb13216..9f1b561 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -76,7 +76,7 @@ public class VotingController { @RequestMapping("/") public String WelcomeSite() { - LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,8); + LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,17); LocalDate now = LocalDate.now(); if(now.isAfter(finishDate)){ diff --git a/src/main/resources/templates/errors/alreadyVoted.html b/src/main/resources/templates/errors/alreadyVoted.html index 2fafb30..cea84dc 100644 --- a/src/main/resources/templates/errors/alreadyVoted.html +++ b/src/main/resources/templates/errors/alreadyVoted.html @@ -8,15 +8,38 @@ -
-

Du hast schon abgestimmt!

- -
+
+

Du hast schon abgestimmt!

+

Nächste Abstimmung in:

+ +
- diff --git a/src/main/resources/templates/errors/votingClosed.html b/src/main/resources/templates/errors/votingClosed.html index 5c5e830..f04a09e 100644 --- a/src/main/resources/templates/errors/votingClosed.html +++ b/src/main/resources/templates/errors/votingClosed.html @@ -9,8 +9,8 @@
-

Das Voting wurde beendet!

-

Informationen zu Votings sind der Adolfinumwebsite zu entnehmen

+

Du scheinst zu spät zu sein!

+

Momentan findet kein Voting statt

From 8da69f0170aacd66c11b05fd0acf190eef1c490e Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 18:32:31 +0100 Subject: [PATCH 21/32] Fixed out of bounds exception --- .../AbizeitungVotingSystem/controller/VotingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9f1b561..ddf32af 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -200,7 +200,7 @@ public class VotingController { voteForPosCandidates.add(p); } else { if(index > 31 && posCandidate.getName().indexOf(" ") != -1){ - posCandidate.setName(posCandidate.getName().split(" ")[1]); + posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1]); } PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); addToPosCandidates.add(possibleCandidate); From 865c3e778fba0e9b9d02b68a325f84c1ea993294 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 20:23:16 +0100 Subject: [PATCH 22/32] BUGFIX --- .../controller/VotingController.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) 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 ddf32af..6fe81fc 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -190,32 +190,23 @@ public class VotingController { return "errors/alreadyVoted.html"; } else { LinkedList posCandidates = possibleCandidates.getPossibleCandidates(); - LinkedList voteForPosCandidates = new LinkedList<>(); - LinkedList addToPosCandidates = new LinkedList<>(); long index = 1; for (PossibleCandidate posCandidate : posCandidates) { if (posCandidate.getName() != "") { if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null) { PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()); - voteForPosCandidates.add(p); + p.setVotes(p.getVotes() + 1); + possibleCandidateRepository.save(p); } else { - if(index > 31 && posCandidate.getName().indexOf(" ") != -1){ - posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1]); + if (index > 31 && posCandidate.getName().indexOf(" ") != -1) { + posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length - 1]); } PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); - addToPosCandidates.add(possibleCandidate); + possibleCandidateRepository.save(possibleCandidate); } } index++; } - for (PossibleCandidate p: voteForPosCandidates) { - p.setVotes(p.getVotes() + 1); - possibleCandidateRepository.save(p); - } - - for (PossibleCandidate p: addToPosCandidates) { - possibleCandidateRepository.save(p); - } tableAction.updateCandidatesubmit_status(name, voterRepository); return "voteSuccessful.html"; From 6ed12992c91b798cf294d9265d3ea9f3d5e4bb18 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 20:34:55 +0100 Subject: [PATCH 23/32] temp --- .../AbizeitungVotingSystem/controller/VotingController.java | 2 +- src/main/resources/templates/errors/votingClosed.html | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) 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 6fe81fc..33cd7f5 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -76,7 +76,7 @@ public class VotingController { @RequestMapping("/") public String WelcomeSite() { - LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,17); + LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,8); LocalDate now = LocalDate.now(); if(now.isAfter(finishDate)){ diff --git a/src/main/resources/templates/errors/votingClosed.html b/src/main/resources/templates/errors/votingClosed.html index f04a09e..a54361f 100644 --- a/src/main/resources/templates/errors/votingClosed.html +++ b/src/main/resources/templates/errors/votingClosed.html @@ -9,8 +9,7 @@
-

Du scheinst zu spät zu sein!

-

Momentan findet kein Voting statt

+

Es finden momentan Wartungen statt

From 0036b197218a1e357dab1b20c525a21224ca621d Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 21:09:46 +0100 Subject: [PATCH 24/32] reverse block --- .../AbizeitungVotingSystem/controller/VotingController.java | 2 +- src/main/resources/templates/errors/votingClosed.html | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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 33cd7f5..6fe81fc 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -76,7 +76,7 @@ public class VotingController { @RequestMapping("/") public String WelcomeSite() { - LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,8); + LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,17); LocalDate now = LocalDate.now(); if(now.isAfter(finishDate)){ diff --git a/src/main/resources/templates/errors/votingClosed.html b/src/main/resources/templates/errors/votingClosed.html index a54361f..b41d13c 100644 --- a/src/main/resources/templates/errors/votingClosed.html +++ b/src/main/resources/templates/errors/votingClosed.html @@ -9,7 +9,8 @@
-

Es finden momentan Wartungen statt

+

Du bist leider zu spät

+

Momentan ist hier auf der Seite nichts los

From 91874abe4efe222d715d3a851c49bb11b97c23bb Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 21:26:13 +0100 Subject: [PATCH 25/32] Added exeptions --- .../controller/VotingController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 6fe81fc..d4389ff 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -199,7 +199,14 @@ public class VotingController { possibleCandidateRepository.save(p); } else { if (index > 31 && posCandidate.getName().indexOf(" ") != -1) { - posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length - 1]); + if (posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "Neumann" || + posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "neumann" || + posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "Mecklenburg" || + posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "mecklenburg" ){ + posCandidate.setName(posCandidate.getName()); + } else { + posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length - 1]); + } } PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); possibleCandidateRepository.save(possibleCandidate); From 63aa7950862ca24f9e978cb41a34aaa291c2ed7b Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 21:56:17 +0100 Subject: [PATCH 26/32] Final release --- .../controller/VotingController.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) 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 d4389ff..1abcf02 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -193,23 +193,28 @@ public class VotingController { long index = 1; for (PossibleCandidate posCandidate : posCandidates) { if (posCandidate.getName() != "") { - if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null) { + if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null || + possibleCandidateRepository.findByNameAndCategory(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1], categoryRepository.findById(index).get()) != null) { PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()); p.setVotes(p.getVotes() + 1); possibleCandidateRepository.save(p); } else { if (index > 31 && posCandidate.getName().indexOf(" ") != -1) { - if (posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "Neumann" || - posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "neumann" || - posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "Mecklenburg" || - posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "mecklenburg" ){ - posCandidate.setName(posCandidate.getName()); + if (posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("Neumann") || + posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("neumann") || + posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("Mecklenburg") || + posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("mecklenburg")){ + PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); + possibleCandidateRepository.save(possibleCandidate); } else { posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length - 1]); + PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); + possibleCandidateRepository.save(possibleCandidate); } + } else { + PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); + possibleCandidateRepository.save(possibleCandidate); } - PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); - possibleCandidateRepository.save(possibleCandidate); } } index++; From fe5a91455cc4eeda66965b71b7caf13076834597 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 22:07:45 +0100 Subject: [PATCH 27/32] asdf --- .../controller/VotingController.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 1abcf02..120d2ea 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -193,8 +193,11 @@ public class VotingController { long index = 1; for (PossibleCandidate posCandidate : posCandidates) { if (posCandidate.getName() != "") { - if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null || - possibleCandidateRepository.findByNameAndCategory(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1], categoryRepository.findById(index).get()) != null) { + if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null ||) { + PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()); + p.setVotes(p.getVotes() + 1); + possibleCandidateRepository.save(p); + } else if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1], categoryRepository.findById(index).get()) != null){ PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()); p.setVotes(p.getVotes() + 1); possibleCandidateRepository.save(p); From 57589e402cf3e446a2d41324e162ab44f641114e Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 22:08:55 +0100 Subject: [PATCH 28/32] asdf2 --- .../AbizeitungVotingSystem/controller/VotingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 120d2ea..9cdb424 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -198,7 +198,7 @@ public class VotingController { p.setVotes(p.getVotes() + 1); possibleCandidateRepository.save(p); } else if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1], categoryRepository.findById(index).get()) != null){ - PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()); + PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1], categoryRepository.findById(index).get()); p.setVotes(p.getVotes() + 1); possibleCandidateRepository.save(p); } else { From bbc83031b2ed9785f10ae53773b4e135c8c6badc Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Jan 2021 22:09:48 +0100 Subject: [PATCH 29/32] asdf3 --- .../AbizeitungVotingSystem/controller/VotingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9cdb424..d301d80 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -193,7 +193,7 @@ public class VotingController { long index = 1; for (PossibleCandidate posCandidate : posCandidates) { if (posCandidate.getName() != "") { - if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null ||) { + if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null) { PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()); p.setVotes(p.getVotes() + 1); possibleCandidateRepository.save(p); From def3ed6309f9289df174b45824ed402921b019dd Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 17 Jan 2021 15:54:32 +0100 Subject: [PATCH 30/32] Prepared everything for the votings --- .../controller/VotingController.java | 4 +-- .../table/TableAction.java | 2 +- src/main/resources/static/styles/voting.css | 20 ++++++++++- .../templates/errors/alreadyVoted.html | 33 +++---------------- 4 files changed, 27 insertions(+), 32 deletions(-) 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 d301d80..2d95482 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -52,8 +52,8 @@ public class VotingController { @PostConstruct public void init() { - votingPhase = false; - addingPhase = true; + votingPhase = true; + addingPhase = false; LOGGER.info("Program started with arguments: votingPhase="+ votingPhase + " addingPhase=" + addingPhase); diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java index c4bc283..b50e0f7 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java @@ -99,7 +99,7 @@ public class TableAction { Collections.sort(possibleCandidatesPerCategory, Comparator.comparing(PossibleCandidate::getVotes)); Collections.reverse(possibleCandidatesPerCategory); for (int j = 0; j < getLimit(possibleCandidatesPerCategory); j++){ - if (j >= 10 && possibleCandidatesPerCategory.get(j).getVotes() == possibleCandidatesPerCategory.get(j-1).getVotes()){ + if (j >= 10 && possibleCandidatesPerCategory.get(j).getVotes() == possibleCandidatesPerCategory.get(9).getVotes()){ Candidate candidate = new Candidate(possibleCandidatesPerCategory.get(j).getName(), possibleCandidatesPerCategory.get(j).getCategory()); candidateRepository.save(candidate); } diff --git a/src/main/resources/static/styles/voting.css b/src/main/resources/static/styles/voting.css index e0ff00c..5c99db7 100644 --- a/src/main/resources/static/styles/voting.css +++ b/src/main/resources/static/styles/voting.css @@ -42,7 +42,8 @@ button { } .submitButton { - margin-top: 5%; + margin-top: 2%; + margin-bottom: 5%; padding: .25em 0; border: 0; outline: 0; @@ -56,6 +57,23 @@ button { text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); } +@media only screen and (max-device-width: 480px) { + .submitButton { + margin-top: 2%; + padding: .25em 0; + border: 0; + outline: 0; + background: rgb(6, 216, 136); + color: rgba(255, 255, 255, 0.85); + font-size: 2rem; + width: 500px; + letter-spacing: .0625rem; + border-radius: 12px; + box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); + text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); + } +} + html, body { width: 100%; diff --git a/src/main/resources/templates/errors/alreadyVoted.html b/src/main/resources/templates/errors/alreadyVoted.html index cea84dc..2fafb30 100644 --- a/src/main/resources/templates/errors/alreadyVoted.html +++ b/src/main/resources/templates/errors/alreadyVoted.html @@ -8,38 +8,15 @@ -
-

Du hast schon abgestimmt!

-

Nächste Abstimmung in:

- -
+
+

Du hast schon abgestimmt!

+ +
- From 6cae7d78aea571da4630d69057e82de7c046297e Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 17 Jan 2021 16:19:26 +0100 Subject: [PATCH 31/32] Updated Datelock --- .../AbizeitungVotingSystem/controller/VotingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2d95482..98f55b0 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -76,7 +76,7 @@ public class VotingController { @RequestMapping("/") public String WelcomeSite() { - LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,17); + LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,24); LocalDate now = LocalDate.now(); if(now.isAfter(finishDate)){ From f5e714883d7cf03f5ffeafb0710dfe3291d3eb0f Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 27 Jan 2021 18:26:35 +0100 Subject: [PATCH 32/32] Cleaning up for publication --- .gitignore | 3 ++ .../table/TableAction.java | 4 +- src/main/resources/Categories.txt | 42 ---------------- src/main/resources/Categories2.txt | 50 ------------------- src/main/resources/Mottos.txt | 11 ---- src/main/resources/application.properties | 14 +++--- 6 files changed, 12 insertions(+), 112 deletions(-) delete mode 100644 src/main/resources/Categories2.txt delete mode 100644 src/main/resources/Mottos.txt diff --git a/.gitignore b/.gitignore index 27eb534..c249fa8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/**/target/ !**/src/test/**/target/ +Databases/ +logs/ +Results/ ### STS ### .apt_generated diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java index c4bc283..7685bc5 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java @@ -70,7 +70,7 @@ public class TableAction { } public void setUpVoters(VoterRepository voterRepository){ - try (InputStream inputStream = getClass().getResourceAsStream("/Q2_emails.txt"); + try (InputStream inputStream = getClass().getResourceAsStream("/Email_Whitelist.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { String line = ""; ArrayList voters = new ArrayList(); @@ -122,7 +122,7 @@ public class TableAction { } public void setUpCategories(CategoryRepository categoryRepository){ - try (InputStream inputStream = getClass().getResourceAsStream("/Categories2.txt"); + try (InputStream inputStream = getClass().getResourceAsStream("/Categories.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { String line = ""; ArrayList categories = new ArrayList(); diff --git a/src/main/resources/Categories.txt b/src/main/resources/Categories.txt index b533b46..e69de29 100644 --- a/src/main/resources/Categories.txt +++ b/src/main/resources/Categories.txt @@ -1,42 +0,0 @@ -Nesthocker -Beste Ausreden -Verfressenste -Ehre wem Ehre gebührt - Die Engagiertesten -Verhandlungskünstler -Stufenclown -Knacki -(x)Traumpaar -Lexikon -Harzer -Unvergesslich -Größter Klugscheißer -Future Celebrity -Pornhub als Abendbeschäftigung -Größte/r Schnorrer/in -Hat gefühlt die meisten Fehlstunden -Größte Diva -Weltherrschaft 2040 -Größte Labertasche -Sonnenschein -Kleinster Aufwand, größter Erfolg -Ziemlich beste Freunde -Am faulsten -Immer zu spät -Lehrers Liebling -Gleich geblieben -Größter Bonze -Verdient später am meisten -(x)Lehrerschreck -Augenschmaus (W) -Augenschmaus (M) -Lästermaul (Gossip Girl) -Notenwürfler -Macht alles außer Unterricht -Übermotiviert -Schülerschreck -Mathegötter (der/die beste Mathelehrer/in) -Falscher Beruf -Größte Sauklaue -Lehrerbuddies -Lebt den Beruf -Unvergesslich \ No newline at end of file diff --git a/src/main/resources/Categories2.txt b/src/main/resources/Categories2.txt deleted file mode 100644 index 204a4a2..0000000 --- a/src/main/resources/Categories2.txt +++ /dev/null @@ -1,50 +0,0 @@ -Sportler/in des Jahres -Best dressed student -Picasso Jr. -Verpeilt, verpeilter, ... -Große Klappe -Darf auf keiner Party fehlen -Stille Wasser sind tief -Patrick-Fragen-Steller -Ehrgeizig, ehrgeiziger, ... -Miss Make-Up -Meiste Punkte in Flensburg -Im Bundestag -Bimsstein als Leber -Bester Schwiegersohn -Beste Schwiegertochter -Lebt im Fitnessstudio -Koffeinjunkie -Erkennt man am Lachen -Dschungelkönig/in -Bei Geburt getrennte Zwillinge (Aussehen) -Future Rockstar -Schummelt sich durchs Abi -Organisationstalent -Gute Seele -Nobelpreisträger -Nachteule -Präsentationspro -Lehrerassistent für Technik -Meiste Screentime -Interessiert sich wirklich für den Unterricht -Kleiner Exentriker -Herrscht hart, aber gerecht -Niemand traut sich zu schwänzen -Man lernt nicht für die Schule sondern fürs Leben -Konntert am besten -Best dressed teacher -Eigentlich Motivationstrainer -Schlimmstes Tafelbild -Möchtegern Comedian -Führt ein Doppelleben -"Ich beende den Unterricht" -Schülerschwarm (M) -Schülerschwarm (W) -Harte Schale, weicher Kern -Sklaventreiber -Unterrichtet auch, wenn die Schule brennt -Ist immer da -Lebt in der Schule -Musste einen Wald für Arbeitsblätter roden lassen -Top gestylt \ No newline at end of file diff --git a/src/main/resources/Mottos.txt b/src/main/resources/Mottos.txt deleted file mode 100644 index 645759b..0000000 --- a/src/main/resources/Mottos.txt +++ /dev/null @@ -1,11 +0,0 @@ -CannABIs - wir haben es durchgezogen! -ABI 2,010 ‰ - Meist dichter als Denker -KABItän Blaubär - Immer blau und trotzdem schlau -HABI Potter - Wir verlassen die Kammer des Schreckens -A BItch - Für einen Punkt tue ich alles! -ABIthur - Wenn das Elite von die Gymnahsium gehen tut -LABIrinth - Planlos zum Ziel -ABIcrombie & Fitch - Models gehen, Elche bleiben (Abercrombie & Fitch) -SemipermeABIlität - Nur die Besten kommen durch -KohlrABI - Wir machen uns vom Acker -ABIgasmus - Aber das war nur das Vorspiel \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 58e3e6a..987925f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ -spring.datasource.url=jdbc:mysql://localhost/VotingSystem -spring.datasource.username=***REMOVED*** -spring.datasource.password=***REMOVED*** +spring.datasource.url=jdbc:mysql://hostadress/database +spring.datasource.username=mysql_username +spring.datasource.password=mysql_password spring.jpa.hibernate.ddl-auto=update @@ -8,11 +8,11 @@ spring.jpa.hibernate.ddl-auto=update server.port = 8000 ######Email Properties ###### -spring.mail.host=smtp.gmail.com -spring.mail.port=587 +spring.mail.host= +spring.mail.port= spring.mail.properties.mail.smtp.starttls.enable=true -spring.mail.username=***REMOVED*** -spring.mail.password=***REMOVED*** +spring.mail.username= +spring.mail.password= spring.mail.properties.mail.smtp.starttls.required=true spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.connectiontimeout=5000