This commit is contained in:
		| @@ -35,7 +35,7 @@ public class IndexController extends CommonController { | ||||
| 	@GetMapping("/") | ||||
| 	public String index(Model model) { | ||||
| 		super.setupSession(model, request); | ||||
| 		model.addAttribute("camps", service.getAllCamps()); | ||||
| 		model.addAttribute("camps", service.getAllCamps(true)); | ||||
| 		return super.isLoggedIn(request) ? dashboard(model) : "/index"; | ||||
| 	} | ||||
|  | ||||
| @@ -45,7 +45,7 @@ public class IndexController extends CommonController { | ||||
| 		model.addAttribute("mybookings", service.getBookingsOf(super.getCurrentUser(request))); | ||||
| 		model.addAttribute("bookingBean", new BookingBean()); | ||||
| 		model.addAttribute("keycloakProfileUrl", keycloak.getUserClientUrl()); | ||||
| 		model.addAttribute("camps", service.getAllCamps()); | ||||
| 		model.addAttribute("camps", service.getAllCamps(true)); | ||||
| 		return "/dashboard"; | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import java.util.List; | ||||
| import java.util.stream.Stream; | ||||
|  | ||||
| import org.jooq.Condition; | ||||
| import org.jooq.impl.DSL; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| @@ -28,8 +29,8 @@ public class IndexService { | ||||
| 	 * | ||||
| 	 * @return the list of found camps | ||||
| 	 */ | ||||
| 	public List<VCampRecord> getAllCamps() { | ||||
| 		Condition condition = V_CAMP.DEPART.greaterOrEqual(LocalDateTime.now()); | ||||
| 	public List<VCampRecord> getAllCamps(Boolean upcomingOnly) { | ||||
| 		Condition condition = upcomingOnly ? V_CAMP.DEPART.greaterOrEqual(LocalDateTime.now()) : DSL.trueCondition(); | ||||
| 		Stream<VCampRecord> stream = gateway.getAllCamps(condition); | ||||
| 		List<VCampRecord> list = new ArrayList<>(); | ||||
| 		stream.forEach(o -> list.add(o)); | ||||
|   | ||||
| @@ -31,13 +31,17 @@ public class RegistrationController extends CommonController { | ||||
| 	@GetMapping("/registration/{fkCamp}") | ||||
| 	public String index(@PathVariable(name = "fkCamp", required = true) Integer fkCamp, Model model) { | ||||
| 		super.setupSession(model, request); | ||||
| 		CampBean campBean = service.getCamp(fkCamp); | ||||
| 		model.addAttribute("camp", campBean); | ||||
| 		RegistrationBean bean = new RegistrationBean(); | ||||
| 		bean.setFkCamp(fkCamp); | ||||
| 		bean.setRegisterInKeycloak(true); // we want people to register generally | ||||
| 		model.addAttribute("bean", bean); | ||||
| 		return "/registration/registration"; | ||||
| 		if (service.campIsNotYetOver(fkCamp)) { | ||||
| 			CampBean campBean = service.getCamp(fkCamp); | ||||
| 			model.addAttribute("camp", campBean); | ||||
| 			RegistrationBean bean = new RegistrationBean(); | ||||
| 			bean.setFkCamp(fkCamp); | ||||
| 			bean.setRegisterInKeycloak(true); // we want people to register generally | ||||
| 			model.addAttribute("bean", bean); | ||||
| 			return "/registration/registration"; | ||||
| 		} else { | ||||
| 			return "/registration/isover"; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	@PostMapping("/registration/register") | ||||
|   | ||||
| @@ -239,4 +239,26 @@ public class RegistrationGateway { | ||||
| 		}); | ||||
| 		return lrw.getCounter(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * returns true if the end date of the camp is not yet over | ||||
| 	 * | ||||
| 	 * @param fkCamp the camp ID | ||||
| 	 * @return true or false | ||||
| 	 */ | ||||
| 	public Boolean campIsNotYetOver(Integer fkCamp) { | ||||
| 		SelectConditionStep<Record1<LocalDateTime>> sql = jooq | ||||
| 		// @formatter:off | ||||
| 			.select(T_CAMP.DEPART) | ||||
| 			.from(T_CAMP) | ||||
| 			.where(T_CAMP.PK.eq(fkCamp)); | ||||
| 		// @formatter:on | ||||
| 		LOGGER.debug(sql.toString()); | ||||
| 		for (Record1<LocalDateTime> r : sql.fetch()) { | ||||
| 			LocalDateTime depart = r.get(T_CAMP.DEPART); | ||||
| 			LocalDateTime now = LocalDateTime.now(); | ||||
| 			return now.isBefore(depart); | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -22,6 +22,16 @@ public class RegistrationService { | ||||
| 	@Autowired | ||||
| 	private KeycloakRepository keycloak; | ||||
|  | ||||
| 	/** | ||||
| 	 * return true if the camp is not yet over | ||||
| 	 * | ||||
| 	 * @param fkCamp the camp ID | ||||
| 	 * @return true or false | ||||
| 	 */ | ||||
| 	public Boolean campIsNotYetOver(Integer fkCamp) { | ||||
| 		return gateway.campIsNotYetOver(fkCamp); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * get the camp | ||||
| 	 * | ||||
|   | ||||
| @@ -9,15 +9,6 @@ | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0"> | ||||
| 			<li class="nav-item"><a th:href="@{${keycloakProfileUrl}}" class="btn btn-secondary btn-icon-silent" target="_blank">Profil</a></li> | ||||
| 		</ul> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0"> | ||||
| 			<li class="nav-item dropdown"> | ||||
| 			  <a class="nav-link dropdown-toggle btn btn-secondary btn-icon-silent" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Buchen</a> | ||||
| 			  <ul class="dropdown-menu"> | ||||
| 					<li th:each="c : ${camps}"><a class="dropdown-item" th:href="@{/registration/{id}(id=${c.pk})}"><span th:text="${c.name}"></span> <span | ||||
| 							th:text="${#numbers.formatInteger(c.year, 0)}" th:if="${c.year}"></span></a></li> | ||||
| 				</ul> | ||||
| 			</li> | ||||
| 		</ul> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0" sec:authorize="hasRole('business')"> | ||||
| 			<li class="nav-item"><a th:href="@{/business}" class="btn btn-secondary btn-icon-silent">Abrechnung</a></li> | ||||
| 		</ul> | ||||
| @@ -30,12 +21,54 @@ | ||||
| 	</th:block> | ||||
| 	<th:block layout:fragment="content"> | ||||
| 		<div class="mainpage"> | ||||
| 		  <!-- list of camps --> | ||||
| 		  <div class="container"> | ||||
| 		  	<div class="row"> | ||||
| 		  		<div class="col"> | ||||
| 		  			<div style="text-align: center" class="menufont">Hier kannst du dich zu den Freizeiten anmelden:</div> | ||||
| 		  		</div> | ||||
| 		  	</div> | ||||
| 		  	<br /> | ||||
| 		  	<div class="row"> | ||||
| 		  		<div class="col-sm-12 col-md-6 col-lg-3" th:each="c : ${camps}"> | ||||
| 						<div class="card" style="background-color: rgba(255, 255, 255, 0.5)"> | ||||
| 							<div class="card-body"> | ||||
| 								<div class="menufont" th:text="${c.locationName}" style="padding: 8px"></div> | ||||
| 								<div> | ||||
| 									<h1 th:text="${c.name}" class="menufont"></h1> | ||||
| 								</div> | ||||
| 								<br /> | ||||
| 								<div> | ||||
| 									<span style="margin: 24px">ICON</span> <span class="menufont" th:text="${c.minAge} + ' - ' + ${c.maxAge} + ' Jahre'"></span> | ||||
| 								</div> | ||||
| 								<br /> | ||||
| 								<div> | ||||
| 									<span style="margin: 24px">ICON</span> <span class="menufont" th:text="${#temporals.format(c.arrive, 'dd.MM.')} + ' - ' + ${#temporals.format(c.depart, 'dd.MM.yyyy')}" | ||||
| 										th:if="${c.arrive != null &&  c.depart != null}"></span> | ||||
| 								</div> | ||||
| 								<br /> | ||||
| 								<div> | ||||
| 									<span style="margin: 24px">ICON</span> <span class="menufont" th:text="${c.price}"></span> | ||||
| 								</div> | ||||
| 								<br /> | ||||
| 								<div> | ||||
| 									<a class="btn btn-outline-primary form-control menufont" th:href="@{/registration/{id}(id=${c.pk})}">Jetzt anmelden</a> | ||||
| 								</div> | ||||
| 							</div> | ||||
| 						</div> | ||||
| 					</div> | ||||
| 		  	</div> | ||||
| 		  </div> | ||||
| 		  <br /> | ||||
|  | ||||
| 		  <!-- registrations --> | ||||
| 			<script type="text/javascript"> | ||||
| 				function mark(e) { | ||||
| 					$(e).css("background", "orange"); | ||||
| 				} | ||||
| 			</script> | ||||
| 			<div class="alert alert-primary" th:if="${mybookings.size() < 1}">Es wurden noch keine Anmeldungen für eine Freizeit hinterlegt.</div> | ||||
| 			<div class="alert alert-primary menufont" th:if="${mybookings.size() < 1}">Es wurden noch keine Anmeldungen für eine Freizeit hinterlegt.</div> | ||||
| 			<div th:if="${mybookings.size() > 0}" class="menufont">Deine bisherigen Anmeldungen:</div> | ||||
| 			<div class="accordion" id="acc" th:if="${mybookings.size() > 0}"> | ||||
| 				<div class="accordion-item" th:each="b : ${mybookings}"> | ||||
| 					<h2 class="accordion-header" th:id="'acc-head-' + ${b.pk}" th:if="${b.pk}"> | ||||
|   | ||||
							
								
								
									
										31
									
								
								src/main/resources/templates/registration/isover.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/main/resources/templates/registration/isover.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| <!DOCTYPE html> | ||||
| <html xmlns:th="http://www.thymeleaf.org" layout:decorate="~{template}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:sec="http://www.thymeleaf.org/extras/spring-security"> | ||||
| <head> | ||||
| <title>Camp Organizer 2</title> | ||||
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||||
| </head> | ||||
| <body> | ||||
| 	<th:block layout:fragment="header"> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0" th:if="${not #strings.isEmpty(currentUser)}"> | ||||
| 			<li class="nav-item"><a th:href="@{${keycloakProfileUrl}}" class="btn btn-secondary btn-icon-silent" target="_blank">Profil</a></li> | ||||
| 		</ul> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0" sec:authorize="hasRole('business')"> | ||||
| 			<li class="nav-item"><a th:href="@{/business}" class="btn btn-secondary btn-icon-silent">Abrechnung</a></li> | ||||
| 		</ul> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0" sec:authorize="hasRole('registrator')"> | ||||
| 			<li class="nav-item"><a th:href="@{/confirmation}" class="btn btn-secondary btn-icon-silent">Bestätigung</a></li> | ||||
| 		</ul> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0" th:if="${not #strings.isEmpty(currentUser)}"> | ||||
| 			<li class="nav-item"><a href="https://www.onkelwernerfreizeiten.de/cloud" class="btn btn-secondary btn-icon-silent" target="_blank">Nextcloud</a></li> | ||||
| 		</ul> | ||||
| 	</th:block> | ||||
| 	<th:block layout:fragment="content"> | ||||
| 		<div class="mainpage"> | ||||
| 			<div class="alert alert-error"> | ||||
| 				Die Freizeit ist bereits vorbei. Du kannst dich nur zu Freizeiten anmelden, die noch nicht beendet worden sind. | ||||
| 			</div> | ||||
| 			<div><a th:href="@{/}" class="btn btn-outline-secondary">zur Hauptseite</a></div> | ||||
| 		</div> | ||||
| 	</th:block> | ||||
| </body> | ||||
| </html> | ||||
| @@ -17,6 +17,7 @@ | ||||
| 			<div class="card centered-card" style="max-width: 48rem"> | ||||
| 				<div class="card-body"> | ||||
| 					<form th:action="@{/registration/register}" th:object="${bean}" method="post"> | ||||
| 						<span class="error"	th:each="error : ${#fields.errors('fkCamp')}">[[${error}]]<br /></span> | ||||
| 						<input type="hidden" th:field="*{fkCamp}" /> | ||||
| 						<div class="container"> | ||||
| 							<div class="row"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user