Skip to content
Snippets Groups Projects
Commit 520fd39c authored by Rhys Evans's avatar Rhys Evans
Browse files

started work on dynamic towns page

parent d376e697
1 merge request!34Resolve "As a user, I would like a town specific page which shows all trails for that town so that I can easily see my progress"
......@@ -28,6 +28,16 @@ public class PlacesController {
@Autowired
private TrailsRepository trailsRepo;
@GetMapping("/towns")
public ModelAndView getTownPages(){
ModelAndView modelAndView = new ModelAndView("towns/townsPageList.html");
List<TownWithTrails> townsList = placeRepo.getAllTownCoords();
List<Trail> trailslocations = trailsRepo.getAllTrails();
modelAndView.addObject("trails", trailslocations);
modelAndView.addObject("towns", townsList);
return modelAndView;
}
@GetMapping("/checkpoints")
public ModelAndView getLocationPages(){
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>towns</title>
</head>
<body>
<main>
<div th:each="town:${towns}">
<H1 th:text="${town.getTownName()}"></H1>
<li>
<!-- <ul th:if="*{town.getTownName()=='Caerphilly'}"></ul>-->
</li>
</div>
</main>
</body>
</html>
\ No newline at end of file
//package Team5.SmartTowns.Data;
//package Team5.SmartTowns.data;
//
//import org.junit.jupiter.api.BeforeAll;
//import org.junit.jupiter.api.Test;
//import org.mockito.Mock;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.jdbc.core.RowMapper;
//
//import java.util.List;
//
//import static org.junit.jupiter.api.Assertions.*;
//// create lists of sql data todo
//@SpringBootTest
//class locationRepositoryJDBCTest {
//class LocationRepositoryJDBCTest {
// private JdbcTemplate jdbcTemplate;
// private LocationRepositoryJDBC locationRepositoryJDBC;
//
//private static LocationRepository locationRepo;
// private RowMapper<Location> locationMapper;
//
//
// @Autowired
// private LocationRepository locationRepo;
//
// @Mock
// private JdbcTemplate jdbc;
//@BeforeAll
//public static void setup(){
// LocationRepositoryJDBC aa= new LocationRepositoryJDBC(jdbc);
//}
// @Test
// void getAllLocation() {
// List<Location> locations= locationRepo.getAllLocation();
// int preAdd = locations.size();
// Location loc = new Location("House","House@Bricks","Description Here","Caerphilly",103);
// locationRepo.addLocation(loc);
// int postAdd = locationRepo.getAllLocation().size();
// assertEquals(1,(postAdd-preAdd));
// public void setlocationMapper(){
// locationMapper = (rs, i) -> new Location(
//
// rs.getString("locationName"),
// rs.getString("locationEmail"),
// rs.getString("locationDescription"),
// rs.getString("locationPlace"),
// rs.getString("locationTrailID"),
// rs.getBoolean("locationApproved")
// );
// }
//
// @Test
// void addLocation() {
// @Autowired
// public void LocationRepositoryJDBC(JdbcTemplate jdbc){
// this.jdbcTemplate = jdbc;
// locationRepositoryJDBC = new LocationRepositoryJDBC(jdbc);
// }
//
//
//
//
// @Test
// void setJdbc() {
// public void test(){
//
// }
//
//
//}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment