mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 07:45:49 +00:00
Merge pull request #38 from cheapy-ispp/develop
Actualizacion de la rama de cambio de vistas
This commit is contained in:
commit
8fc8fb0874
6 changed files with 30 additions and 78 deletions
|
@ -36,20 +36,21 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||
.antMatchers(HttpMethod.GET, "/", "/oups").permitAll()
|
||||
.antMatchers("/users/new").permitAll()
|
||||
|
||||
.antMatchers("/nuOffers/**").hasAnyAuthority("admin","cliente")
|
||||
.antMatchers("/timeOffers/**").hasAnyAuthority("admin","client")
|
||||
.antMatchers("/offers/nu/**").hasAnyAuthority("admin","cliente")
|
||||
.antMatchers("/offers/time/**").hasAnyAuthority("admin","cliente")
|
||||
|
||||
.antMatchers("/login/**").anonymous()
|
||||
.antMatchers("/logout").permitAll()
|
||||
|
||||
.antMatchers("/usuarios/new").permitAll()
|
||||
.antMatchers("/admin/**").hasAnyAuthority("admin")
|
||||
.antMatchers("/speedOffers/**").hasAnyAuthority("admin", "client")
|
||||
.antMatchers("/foodOffers/**").hasAnyAuthority("admin", "client")
|
||||
.antMatchers("/offers/speed/**").hasAnyAuthority("admin", "cliente")
|
||||
.antMatchers("/offers/food/**").hasAnyAuthority("admin", "cliente")
|
||||
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
|
||||
|
||||
.antMatchers("/clients/new").permitAll()
|
||||
.antMatchers("/offers/**").hasAnyAuthority("admin", "cliente")
|
||||
.antMatchers("/offers").permitAll()
|
||||
|
||||
|
||||
|
||||
.and().formLogin()
|
||||
|
|
|
@ -29,7 +29,7 @@ public class FoodOfferController {
|
|||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
private boolean checkIdentity(final int foodOfferId) {
|
||||
/*private boolean checkIdentity(final int foodOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
|
@ -38,7 +38,7 @@ public class FoodOfferController {
|
|||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}*/
|
||||
|
||||
@GetMapping("/foodOffers/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
|
@ -56,7 +56,7 @@ public class FoodOfferController {
|
|||
foodOffer.setClient(client);
|
||||
foodOffer.setStatus(StatusOffer.hidden);
|
||||
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||
return "redirect:/foodOffers/" + foodOffer.getId();
|
||||
return "redirect:/offers/food/" + foodOffer.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,18 +80,17 @@ public class FoodOfferController {
|
|||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
|
||||
model.put("foodOffer", foodOffer);
|
||||
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
|
||||
return "foodOffers/foodOffersShow";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
model.addAttribute("foodOffer", foodOffer);
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
@ -101,10 +100,6 @@ public class FoodOfferController {
|
|||
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result,
|
||||
final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("foodOffer", foodOfferEdit);
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
@ -118,9 +113,6 @@ public class FoodOfferController {
|
|||
@GetMapping(value = "/offers/food/{foodOfferId}/disable")
|
||||
public String disableFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
model.put("foodOffer", foodOffer);
|
||||
|
@ -130,9 +122,6 @@ public class FoodOfferController {
|
|||
@PostMapping(value = "/offers/food/{foodOfferId}/disable")
|
||||
public String disableFoodOfferForm(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -32,7 +33,7 @@ public class NuOfferController {
|
|||
|
||||
}
|
||||
|
||||
private boolean checkIdentity(final int nuOfferId) {
|
||||
/*private boolean checkIdentity(final int nuOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
|
@ -41,7 +42,7 @@ public class NuOfferController {
|
|||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}*/
|
||||
|
||||
@GetMapping("/nuOffers/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
|
@ -87,6 +88,7 @@ public class NuOfferController {
|
|||
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
model.put("nuOffer", nuOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "nuOffers/nuOffersShow";
|
||||
|
||||
}
|
||||
|
@ -94,9 +96,6 @@ public class NuOfferController {
|
|||
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
model.addAttribute("nuOffer", nuOffer);
|
||||
|
@ -106,10 +105,6 @@ public class NuOfferController {
|
|||
@PostMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("nuOffer", nuOfferEdit);
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
@ -124,9 +119,6 @@ public class NuOfferController {
|
|||
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
|
||||
final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
model.put("nuOffer", nuOffer);
|
||||
|
@ -137,9 +129,6 @@ public class NuOfferController {
|
|||
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
|
||||
final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
nuOffer.setStatus(StatusOffer.inactive);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -29,7 +30,7 @@ public class SpeedOfferController {
|
|||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
private boolean checkIdentity(final int speedOfferId) {
|
||||
/*private boolean checkIdentity(final int speedOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
|
@ -38,7 +39,7 @@ public class SpeedOfferController {
|
|||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}*/
|
||||
|
||||
@GetMapping("/speedOffers/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
|
@ -79,8 +80,6 @@ public class SpeedOfferController {
|
|||
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
model.put("speedOffer", speedOffer);
|
||||
|
||||
//Se añade formateador de fecha al modelo
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "speedOffers/speedOffersShow";
|
||||
}
|
||||
|
@ -88,10 +87,6 @@ public class SpeedOfferController {
|
|||
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
model.addAttribute("speedOffer", speedOffer);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
@ -100,10 +95,6 @@ public class SpeedOfferController {
|
|||
@PostMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("speedOffer", speedOfferEdit);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
@ -117,10 +108,7 @@ public class SpeedOfferController {
|
|||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/disable")
|
||||
public String disableSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
model.put("speedOffer", speedOffer);
|
||||
|
@ -130,9 +118,6 @@ public class SpeedOfferController {
|
|||
@PostMapping(value = "/offers/speed/{speedOfferId}/disable")
|
||||
public String disableSpeedOfferForm(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.springframework.cheapy.web;
|
||||
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -31,7 +32,7 @@ public class TimeOfferController {
|
|||
|
||||
}
|
||||
|
||||
private boolean checkIdentity(final int timeOfferId) {
|
||||
/*private boolean checkIdentity(final int timeOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
|
@ -41,7 +42,7 @@ public class TimeOfferController {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
*/
|
||||
@GetMapping("/timeOffers/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
TimeOffer timeOffer = new TimeOffer();
|
||||
|
@ -89,6 +90,8 @@ public class TimeOfferController {
|
|||
|
||||
model.put("timeOffer", timeOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
return "timeOffers/timeOffersShow";
|
||||
|
||||
}
|
||||
|
@ -96,9 +99,6 @@ public class TimeOfferController {
|
|||
@GetMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
model.addAttribute("timeOffer", timeOffer);
|
||||
|
@ -108,9 +108,6 @@ public class TimeOfferController {
|
|||
@PostMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("timeOffer", timeOfferEdit);
|
||||
|
@ -125,10 +122,7 @@ public class TimeOfferController {
|
|||
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/disable")
|
||||
public String disableTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
model.put("timeOffer", timeOffer);
|
||||
|
@ -138,9 +132,6 @@ public class TimeOfferController {
|
|||
@PostMapping(value = "/offers/time/{timeOfferId}/disable")
|
||||
public String disableTimeOfferForm(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
|
||||
|
|
|
@ -31,10 +31,7 @@
|
|||
<th><fmt:message key="discount"/></th>
|
||||
<td><c:out value="${foodOffer.discount}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="cuantity"/></th>
|
||||
<td><c:out value="${foodOffer.units}"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><fmt:message key="offerCode"/></th>
|
||||
<td><c:out value="${foodOffer.code}"/></td>
|
||||
|
@ -57,5 +54,5 @@
|
|||
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
|
||||
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
Loading…
Reference in a new issue