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
No related branches found
No related tags found
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"
This commit is part of merge request !34. Comments created here will be created in the context of that merge request.
...@@ -28,6 +28,16 @@ public class PlacesController { ...@@ -28,6 +28,16 @@ public class PlacesController {
@Autowired @Autowired
private TrailsRepository trailsRepo; 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") @GetMapping("/checkpoints")
public ModelAndView getLocationPages(){ 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.junit.jupiter.api.Test;
//import org.mockito.Mock;
//import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest; //import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.jdbc.core.JdbcTemplate; //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 //@SpringBootTest
//class locationRepositoryJDBCTest { //class LocationRepositoryJDBCTest {
// private JdbcTemplate jdbcTemplate;
// private LocationRepositoryJDBC locationRepositoryJDBC;
// //
//private static LocationRepository locationRepo; // private RowMapper<Location> locationMapper;
// //
// //
// @Autowired // @Autowired
// private LocationRepository locationRepo; // public void setlocationMapper(){
// // locationMapper = (rs, i) -> new Location(
// @Mock //
// private JdbcTemplate jdbc; // rs.getString("locationName"),
//@BeforeAll // rs.getString("locationEmail"),
//public static void setup(){ // rs.getString("locationDescription"),
// LocationRepositoryJDBC aa= new LocationRepositoryJDBC(jdbc); // rs.getString("locationPlace"),
//} // rs.getString("locationTrailID"),
// @Test // rs.getBoolean("locationApproved")
// 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));
// } // }
// // @Autowired
// @Test // public void LocationRepositoryJDBC(JdbcTemplate jdbc){
// void addLocation() { // this.jdbcTemplate = jdbc;
// locationRepositoryJDBC = new LocationRepositoryJDBC(jdbc);
// } // }
// //
//
//
//
// @Test // @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.
Please register or to comment