votingPhase can now be toggled from jar
Use -DvotingPhase={boolean} to set value (Defaults to false)
This commit is contained in:
@@ -26,7 +26,8 @@ import java.util.*;
|
||||
@Controller
|
||||
public class VotingController {
|
||||
|
||||
private Boolean candidatesAdded = true;
|
||||
|
||||
private boolean votingPhase = false;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(VotingController.class);
|
||||
private TableAction tableAction = new TableAction();
|
||||
@@ -52,6 +53,17 @@ public class VotingController {
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
try {
|
||||
String mode = System.getProperty("votingPhase");
|
||||
if (mode.equalsIgnoreCase("true")) {
|
||||
votingPhase = true;
|
||||
} else {
|
||||
votingPhase = false;
|
||||
}
|
||||
} catch (Exception e){
|
||||
votingPhase = false;
|
||||
}
|
||||
|
||||
if (voterRepository.findAll().size() == 0) {
|
||||
tableAction.setUpVoters(voterRepository);
|
||||
LOGGER.info("Voters successfully set up");
|
||||
@@ -62,10 +74,11 @@ public class VotingController {
|
||||
LOGGER.info("Categories successfully set up");
|
||||
}
|
||||
|
||||
if (candidateRepository.findAll().size() == 0 && candidatesAdded == true && possibleCandidateRepository.findAll().size()!=0) {
|
||||
if (candidateRepository.findAll().size() == 0 && votingPhase == true && possibleCandidateRepository.findAll().size() != 0) {
|
||||
tableAction.setUpCandidates(possibleCandidateRepository, candidateRepository);
|
||||
LOGGER.info("Candidates successfully set up");
|
||||
}
|
||||
LOGGER.info(votingPhase);
|
||||
}
|
||||
|
||||
@RequestMapping("/")
|
||||
@@ -91,7 +104,7 @@ public class VotingController {
|
||||
if (voter.getVote_status()) {
|
||||
LOGGER.warn(name + " has already voted");
|
||||
return "errors/alreadyVoted.html";
|
||||
} else if (voter.getCandidatesubmit_status() && candidatesAdded == false) {
|
||||
} else if (voter.getCandidatesubmit_status() && votingPhase == false) {
|
||||
LOGGER.warn(name + " has already submitted its candidates");
|
||||
return "errors/alreadysubmittedcandidates.html";
|
||||
} else {
|
||||
@@ -117,7 +130,7 @@ public class VotingController {
|
||||
switch (tableAction.checkToken(name, code, authCodesRepository)) {
|
||||
case "matched":
|
||||
LOGGER.warn("matched");
|
||||
if(candidatesAdded) {
|
||||
if (votingPhase) {
|
||||
List<Category> categories = categoryRepository.findAll();
|
||||
model.addAttribute("categories", categories);
|
||||
model.addAttribute("name", name);
|
||||
|
||||
Reference in New Issue
Block a user