diff --git a/src/main/java/org/springframework/cheapy/web/FoodOfferController.java b/src/main/java/org/springframework/cheapy/web/FoodOfferController.java index e599775b7..2fef1c882 100644 --- a/src/main/java/org/springframework/cheapy/web/FoodOfferController.java +++ b/src/main/java/org/springframework/cheapy/web/FoodOfferController.java @@ -105,14 +105,17 @@ public class FoodOfferController { public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map model) { FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId); - if(!foodOffer.getStatus().equals(StatusOffer.active)) { - return "error"; + if(foodOffer.getStatus().equals(StatusOffer.active)) { + model.put("foodOffer", foodOffer); + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); + return "offers/food/foodOffersShow"; + + }else if(foodOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(foodOfferId))) { + model.put("foodOffer", foodOffer); + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); + return "offers/food/foodOffersShow"; }else { - model.put("foodOffer", foodOffer); - - model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); - - return "offers/food/foodOffersShow"; + return "error"; } } diff --git a/src/main/java/org/springframework/cheapy/web/NuOfferController.java b/src/main/java/org/springframework/cheapy/web/NuOfferController.java index fb0b24104..a6c79db67 100644 --- a/src/main/java/org/springframework/cheapy/web/NuOfferController.java +++ b/src/main/java/org/springframework/cheapy/web/NuOfferController.java @@ -136,13 +136,17 @@ public class NuOfferController { @GetMapping("/offers/nu/{nuOfferId}") public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map model) { NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId); - if(!nuOffer.getStatus().equals(StatusOffer.active)) { - return "error"; + if(nuOffer.getStatus().equals(StatusOffer.active)) { + model.put("nuOffer", nuOffer); + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); + return "offers/nu/nuOffersShow"; + }else if(nuOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(nuOfferId))) { + model.put("nuOffer", nuOffer); + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); + return "offers/nu/nuOffersShow"; + }else { - model.put("nuOffer", nuOffer); - - model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); - return "offers/nu/nuOffersShow"; + return "error"; } } diff --git a/src/main/java/org/springframework/cheapy/web/SpeedOfferController.java b/src/main/java/org/springframework/cheapy/web/SpeedOfferController.java index f717f96e4..ab42eacb6 100644 --- a/src/main/java/org/springframework/cheapy/web/SpeedOfferController.java +++ b/src/main/java/org/springframework/cheapy/web/SpeedOfferController.java @@ -131,13 +131,17 @@ public class SpeedOfferController { @GetMapping("/offers/speed/{speedOfferId}") public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map model) { SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId); - if(!speedOffer.getStatus().equals(StatusOffer.active)) { - return "error"; + if(speedOffer.getStatus().equals(StatusOffer.active)) { + model.put("speedOffer", speedOffer); + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); + return "offers/speed/speedOffersShow"; + }else if(speedOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(speedOfferId))) { + model.put("speedOffer", speedOffer); + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); + return "offers/speed/speedOffersShow"; + }else { - model.put("speedOffer", speedOffer); - - model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); - return "offers/speed/speedOffersShow"; + return "error"; } } diff --git a/src/main/java/org/springframework/cheapy/web/TimeOfferController.java b/src/main/java/org/springframework/cheapy/web/TimeOfferController.java index 48c2f8b76..2e584cdea 100644 --- a/src/main/java/org/springframework/cheapy/web/TimeOfferController.java +++ b/src/main/java/org/springframework/cheapy/web/TimeOfferController.java @@ -120,18 +120,20 @@ public class TimeOfferController { @GetMapping("/offers/time/{timeOfferId}") public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map model) { - TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId); - if(!timeOffer.getStatus().equals(StatusOffer.active)) { - return "error"; + if(timeOffer.getStatus().equals(StatusOffer.active)) { + model.put("timeOffer", timeOffer); + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); + return "offers/time/timeOffersShow"; + + } else if(timeOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(timeOfferId))) { + model.put("timeOffer", timeOffer); + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); + return "offers/time/timeOffersShow"; + }else { - model.put("timeOffer", timeOffer); - - model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); - - return "offers/time/timeOffersShow"; + return "error"; } - } @GetMapping(value = "/offers/time/{timeOfferId}/edit") diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index afee236bf..b19f043cc 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,7 +5,7 @@ spring.datasource.data=classpath*:db/${database}/data.sql spring.h2.console.enabled=true spring.profiles.active=mysql spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/cheapy?serverTimezone=UTC} -spring.datasource.driver-class-name=org.postgresql.Driver + # Web spring.thymeleaf.mode=HTML