Merge branch 'backend' into main

This commit is contained in:
2020-11-14 15:07:52 +01:00
3 changed files with 10 additions and 1 deletions

4
.gitignore vendored
View File

@@ -31,4 +31,6 @@ build/
### VS Code ### ### VS Code ###
.vscode/ .vscode/
*.log
### Logging ###
/logs/

View File

@@ -1,6 +1,7 @@
package com.github.cato447.AbizeitungVotingSystem.controller; package com.github.cato447.AbizeitungVotingSystem.controller;
import com.github.cato447.AbizeitungVotingSystem.entities.Candidate; import com.github.cato447.AbizeitungVotingSystem.entities.Candidate;
import com.github.cato447.AbizeitungVotingSystem.entities.Category;
import com.github.cato447.AbizeitungVotingSystem.entities.Voter; import com.github.cato447.AbizeitungVotingSystem.entities.Voter;
import com.github.cato447.AbizeitungVotingSystem.repositories.CandidateRepository; import com.github.cato447.AbizeitungVotingSystem.repositories.CandidateRepository;
import com.github.cato447.AbizeitungVotingSystem.repositories.CategoryRepository; import com.github.cato447.AbizeitungVotingSystem.repositories.CategoryRepository;
@@ -76,7 +77,9 @@ public class VotingController {
return "errors/alreadyVoted.html"; return "errors/alreadyVoted.html";
} else { } else {
List<Candidate> candidates = candidateRepository.findAll(); List<Candidate> candidates = candidateRepository.findAll();
List<Category> categories = categoryRepository.findAll();
model.addAttribute("candidates", candidates); model.addAttribute("candidates", candidates);
model.addAttribute("categories", categories);
LOGGER.info(name + " is voting now"); LOGGER.info(name + " is voting now");
return "voting.html"; return "voting.html";
} }

View File

@@ -10,6 +10,10 @@
<body> <body>
<h1>Wähle deine Kandidaten:</h1> <h1>Wähle deine Kandidaten:</h1>
<div th:each="category,iter : ${categories}">
<h2 th:text="${category.candidateList[iter.index]}"></h2>
</div>
<div th:each="candidate : ${candidates}" class="candidates"> <div th:each="candidate : ${candidates}" class="candidates">
<h2 th:text="${candidate.category.name}"></h2> <h2 th:text="${candidate.category.name}"></h2>
<ul> <ul>