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

Finished layout, verification and added a review button to the Trails homepage

parent 496275ef
No related branches found
No related tags found
1 merge request!42Resolve "As a site administrator I want to be able to review submitted trail checkpoints by business owners, so that they might be added to the existing trails
Showing
with 136 additions and 19 deletions
......@@ -80,10 +80,14 @@ public class LandmarksController {
int locationID = locationRepository.nametoLocationID(location.getLocationName());
// converts valid response using Location constructor into a submittable format to the sql table
LocationsCoordinates ALocCoord = new LocationsCoordinates(locationID, locCoord.getLocationCoordsLat(), locCoord.getLocationCoordsLong());
boolean checkIfCoorsWithinBoundaries = placesCoordinatesRepo.checkIfCoordsAreWithinTownBoundary(ALocCoord);
if (checkIfCoorsWithinBoundaries==false){ // if coords outside associated town, form is returned to original state
return new ModelAndView("redirect:/checkpointApproval");
}
placesCoordinatesRepo.addLocationCoord(ALocCoord); // adds valid landmark to locations table
locationRepository.updateApprovalStatus(locationID); // updates approval status accordingly
System.out.println(placesCoordinatesRepo.getAllLocationCoords());
ModelAndView modelAndView = new ModelAndView("redirect:/home"); //todo redirect to trails?
ModelAndView modelAndView = new ModelAndView("redirect:/home"); //redirects back top form in case admin wants to input second location
return modelAndView;
// }
......
......@@ -23,11 +23,11 @@ public class LocationsCoordinates {
/// separate class to location to cover all locations within trails that have been approved and have long/lat coords attached for mapping.
private int locationID;
// @NotEmpty(message = "You must enter a Latitude.")
@Min(value=0,message = "You must enter a Latitude.")
// @Min(value=0,message = "You must enter a Latitude.")
private Double locationCoordsLat;
// @NotEmpty(message = "You must type in a Longitude.")
@Min(value=0,message = "You must type in a Longitude.")
// @Min(value=0,message = "You must type in a Longitude.")
private Double locationCoordsLong;
private JdbcTemplate jdbc;
......
......@@ -15,6 +15,8 @@ public interface PlacesCoordinatesRepository {
int getLocationTableIDValue(List<Location> locations, String locationName);
Boolean checkIfCoordsAreWithinTownBoundary(LocationsCoordinates loc);
// List<Location> getFullApprovedLocations(JdbcTemplate aJdbc);
......
package Team5.SmartTowns.placeswithcoordinates;
import Team5.SmartTowns.data.Location;
import Team5.SmartTowns.data.LocationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
......@@ -133,6 +135,33 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
}
@Autowired
LocationRepository local;
@Override
public Boolean checkIfCoordsAreWithinTownBoundary(LocationsCoordinates loc){
int locationID=loc.getLocationID();
String locationTown= jdbc.queryForObject("SELECT locationPlace FROM locations WHERE locationID=?", String.class, locationID);
List<TownWithTrails> allTowns = getAllTownCoords();
for (int i=0;i<allTowns.size();i++){
if (Objects.equals(allTowns.get(i).getTownName(), locationTown)){
double inpLat=(loc.getLocationCoordsLat());
double inpLong=(loc.getLocationCoordsLong());
double townBoundaryLatUppermost=Double.parseDouble(allTowns.get(i).getTownUppermostCoordsLat());
double townBoundaryLatLowermost=Double.parseDouble(allTowns.get(i).getTownLowermostCoordsLat());
double townBoundaryLongLeftmost=Double.parseDouble(allTowns.get(i).getTownLeftmostCoordsLong());
double townBoundaryLongRightmost=Double.parseDouble(allTowns.get(i).getTownRightmostCoordsLong());
// check coords within respective town boundary (boundary decided by rough google maps red-line)
if ( (inpLat<=townBoundaryLatUppermost)&& (inpLat>=townBoundaryLatLowermost) && (inpLong>=townBoundaryLongLeftmost) && (inpLong<=townBoundaryLongRightmost)){
// location within boundary returns true
return true;
}}
} return false; // if location outside boundary, return true won't function and it wil return false.
}
......
......@@ -9,6 +9,10 @@ body{
.submitLand{
grid-area: submitButton;
}
.reviewLand{
grid-area: reviewButton;
}
.Banner {
margin-top: 20px;
background-color: darkslategrey;
......@@ -149,7 +153,7 @@ a{
grid-template-rows: auto;
grid-template-areas:
". pageTitle pageTitle pageTitle pageTitle ."
". . . submitButton submitButton .";
". reviewButton . submitButton submitButton .";
}
.gridContainer2 {
......
......@@ -6,13 +6,45 @@
<link rel="stylesheet" th:href="@{css/templatingstyle.css}">
<script src="/scripts/locationApprovalForm.js"></script>
<style>
body{
background: rgb(41, 41, 41);
color: wheat;
}
main {
background-color: rgb(206, 153, 253);
color: black;
border-color: white;
align-content: center;
text-align: center;
border-radius: 25px;
max-width: 620px;
margin: 0 auto
}
#formHeader{
padding-top: 10px;
color:white;
text-align: center;}
table, th,tr{
margin: 0 auto;
border: white 2px solid;
align-content: center;
text-align: center;
}
</style>
</head>
<body>
<header th:insert="~{/fragments/Templating.html :: header}"></header>
<hr style="height:20px; visibility:hidden;" />
<main>
<H1 id="formHeader">Locations To Be Approved:</H1>
<form action="/checkpointSubmitted" method="post" name="adminCheckpointApproval" th:object="${locationCoord}" onsubmit="return acceptanceValidation()">
<label> Location To Be Approved:
<form action="/checkpointSubmitted" method="post" id="adminCheckpointApproval" name="adminCheckpointApproval" th:object="${locationCoord}" onsubmit="return acceptanceValidation()">
<label> Location:
<select th:object="${location}" th:field="*{locationName}"}>
<!-- <select th:field="*{locationName}">-->
<option value="" hidden="true">Select Location</option>
......@@ -34,7 +66,33 @@
</form>
<hr style="height:20px; visibility:hidden;" />
<section id =unapprovedList >
<H2>To Be Approved:</H2>
<table>
<tr>
<th>Business Name</th>
<th>Town</th>
<th>Contact Address</th>
<th>Description</th>
</tr>
<div th:each="uloc:${uLocs}">
<tr>
<td th:text="${uloc.getLocationName()}+' ('+${uloc.getLocationTrailID()}+')'" ></td>
<td th:text="${uloc.getLocationPlace()}"></td>
<td th:text="${uloc.getLocationEmail()}"></td>
<td th:text="${uloc.getLocationDescription()}"></td>
</tr>
</div>
<tr>
</table>
</section>
<hr style="height:20px; visibility:hidden;" />
</main>
<footer th:insert="~{/fragments/Templating.html :: footer}"></footer>
</body>
......
......@@ -13,6 +13,7 @@
<div class="gridContainer1">
<H1 id="homeTitle"> VZTA Smart Towns - Trails</H1>
<a class="submitLand" href="/landmarkSubmission"> <button> Submit Landmark!</button></a>
<a class="reviewLand" href="/checkpointApproval"> <button> Review Landmark!</button></a>
<!-- <div th:text="${towns}">-->
</div>
......
......@@ -45,7 +45,7 @@ public class LocationRepositoryTest {
// }
@Test
public void testGetAllApprovedLocations() {
public void testGetAllApprovedLocations() { // test to amke sure all approved locations are called
List<Location> approvedLocations = locationRepository.getAllApprovedLocations();
List<Location> allLocations = locationRepository.getAllLocation();
for (int i=0;i<allLocations.size();i++){ // iterate over all location, removing authorised=true
......@@ -67,7 +67,7 @@ public class LocationRepositoryTest {
@Test
public void testGetAllUnapprovedLocations() {
public void testGetAllUnapprovedLocations() { // test to make sure all unapproved coordinates are called
List<Location> unapprovedLocations = locationRepository.getAllUnapprovedLocations();
List<Location> allLocations = locationRepository.getAllLocation();
for (int i=0;i<allLocations.size();i++){ // iterate over all location, removing authorised=false
......@@ -76,17 +76,17 @@ public class LocationRepositoryTest {
allLocations.remove(allLocations.get(i));
}
}
} boolean noUnapporvedLeft=false;
} boolean noUnapprovedLeft=false;
for (Location loc2: allLocations){
if (!loc2.isLocationApproved()){
noUnapporvedLeft=false;
noUnapprovedLeft=false;
break;
} else{
noUnapporvedLeft=true;
noUnapprovedLeft=true;
}
} assertTrue(noUnapporvedLeft);
} assertTrue(noUnapprovedLeft);
}
@Test
@Test// test to ensure that the number of approved locations and number of associated locations with coordinates are equal
public void ensureApprovedLocationsAndCoordinatessAreTheSameSize(){
List<Location> approvedLocations = locationRepository.getAllApprovedLocations();
List<LocationsCoordinates> coordinatesLocations = placesRepository.getAllLocationCoords();
......@@ -95,11 +95,10 @@ public class LocationRepositoryTest {
}
@Test
@Test // test to ensure that all default locations and location coordinates match
public void ensureApprovedLocationsAndCoordinatessTableLineUpTest(){
List<Location> approvedLocations = locationRepository.getAllApprovedLocations();
List<LocationsCoordinates> coordinatesLocations = placesRepository.getAllLocationCoords();
List<Integer> coordinatesLocationsID = new ArrayList<>();
boolean doTheyMatch=false;
for (int i=0;i<coordinatesLocations.size();i++){
int locID=coordinatesLocations.get(i).getLocationID();
......@@ -119,9 +118,9 @@ public class LocationRepositoryTest {
@Test
public void doesApporvalUpdateTest(){
public void doesApprovalUpdateTest(){ //tests whether locations that are approved have their database approval changed to true
int approvedLocationsTotal = locationRepository.getAllApprovedLocations().size();
Location unapprovedLocation = new Location("test","test@email","","Caerphilly","301",false);
Location unapprovedLocation = new Location("test","test@email","","Caerphilly","102",false);
locationRepository.addLocation(unapprovedLocation);
int newID=locationRepository.nametoLocationID( unapprovedLocation.getLocationName());
locationRepository.updateApprovalStatus(newID);
......
......@@ -102,4 +102,24 @@ class PlacesCoordinatesTest {
}
@Test // test to see if
public void checkIfCoordsAreWithinTownBoundaryTest(){
// initiate second instance of location without Caerphilly bounds.
List<Location> locationList = locationRepository.getAllLocation();
Location unapprovedLocation = new Location("test","test@email","","Caerphilly","102",false);
locationRepository.addLocation(unapprovedLocation);
int newID=locationRepository.nametoLocationID( unapprovedLocation.getLocationName());
LocationsCoordinates newCoord = new LocationsCoordinates(newID,0.00,0.00);
boolean falseIfOutOfBounds = placesCoordinatesRepository.checkIfCoordsAreWithinTownBoundary(newCoord);
// initiate second instance of location within Caerphilly bounds.
Location unapprovedLocationTwo = new Location("test2","test2@email","","Caerphilly","103",false);
locationRepository.addLocation(unapprovedLocationTwo);
int newIDTwo=locationRepository.nametoLocationID( unapprovedLocationTwo.getLocationName());
LocationsCoordinates newCoordTwo = new LocationsCoordinates(newIDTwo,51.57903,-3.22075 );
boolean falseIfOutOfBoundsTwo = placesCoordinatesRepository.checkIfCoordsAreWithinTownBoundary(newCoordTwo);
assertNotEquals(falseIfOutOfBounds,falseIfOutOfBoundsTwo);
}
}
\ No newline at end of file
......@@ -53,7 +53,7 @@ public class testUsers {
}
@Test
public void canUsersUnlockStickersTest(){
public void canUsersUnlockStickersTest(){ // tests if users can unlock stickers
NewUser newuser = new NewUser("MeowMeowMeow","WoofMeowMeow","CatMeowMeow@Dogs.com");
Boolean newUser = userRepository.addUser(newuser.getName(), newuser.getEmail(), newuser.getPassword());
Boolean doesStickerUnlock = userRepository.unlockSticker(newuser.getName(),2,2);
......@@ -61,7 +61,7 @@ public class testUsers {
assertTrue(doesStickerUnlock);
}
@Test
public void canUsersUnlockStickersAndViewThemTest(){
public void canUsersUnlockStickersAndViewThemTest(){ // tests if users who unlock stickers can view them
NewUser newuser = new NewUser("MeowMeowMeowMeow","WoofMeowMeowMeow","CatMeowMeowMeow@Dogs.com");
NewUser newuserTwo = new NewUser("Jumper","Baa","Sheep@Wool.com");
Boolean newUser = userRepository.addUser(newuser.getName(), newuser.getEmail(), newuser.getPassword());
......
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