mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 07:45:49 +00:00
Merge branch '012-valoraciones' of https://github.com/cheapy-ispp/cheapy into 012-valoraciones
This commit is contained in:
commit
ef846967a1
27 changed files with 243 additions and 265 deletions
133
readme.md
133
readme.md
|
@ -1,133 +0,0 @@
|
|||
# Spring PetClinic Sample Application [](https://travis-ci.org/spring-projects/spring-petclinic/)
|
||||
|
||||
## Understanding the Spring Petclinic application with a few diagrams
|
||||
<a href="https://speakerdeck.com/michaelisvy/spring-petclinic-sample-application">See the presentation here</a>
|
||||
|
||||
## Running petclinic locally
|
||||
Petclinic is a [Spring Boot](https://spring.io/guides/gs/spring-boot) application built using [Maven](https://spring.io/guides/gs/maven/). You can build a jar file and run it from the command line:
|
||||
|
||||
|
||||
```
|
||||
git clone https://github.com/spring-projects/spring-petclinic.git
|
||||
cd spring-petclinic
|
||||
./mvnw package
|
||||
java -jar target/*.jar
|
||||
```
|
||||
|
||||
You can then access petclinic here: http://localhost:8080/
|
||||
|
||||
<img width="1042" alt="petclinic-screenshot" src="https://cloud.githubusercontent.com/assets/838318/19727082/2aee6d6c-9b8e-11e6-81fe-e889a5ddfded.png">
|
||||
|
||||
Or you can run it from Maven directly using the Spring Boot Maven plugin. If you do this it will pick up changes that you make in the project immediately (changes to Java source files require a compile as well - most people use an IDE for this):
|
||||
|
||||
```
|
||||
./mvnw spring-boot:run
|
||||
```
|
||||
|
||||
## In case you find a bug/suggested improvement for Spring Petclinic
|
||||
Our issue tracker is available here: https://github.com/spring-projects/spring-petclinic/issues
|
||||
|
||||
|
||||
## Database configuration
|
||||
|
||||
In its default configuration, Petclinic uses an in-memory database (H2) which
|
||||
gets populated at startup with data. The h2 console is automatically exposed at `http://localhost:8080/h2-console`
|
||||
and it is possible to inspect the content of the database using the `jdbc:h2:mem:testdb` url.
|
||||
|
||||
A similar setup is provided for MySql in case a persistent database configuration is needed. Note that whenever the database type is changed, the app needs to be run with a different profile: `spring.profiles.active=mysql` for MySql.
|
||||
|
||||
You could start MySql locally with whatever installer works for your OS, or with docker:
|
||||
|
||||
```
|
||||
docker run -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:5.7.8
|
||||
```
|
||||
|
||||
Further documentation is provided [here](https://github.com/spring-projects/spring-petclinic/blob/main/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt).
|
||||
|
||||
## Working with Petclinic in your IDE
|
||||
|
||||
### Prerequisites
|
||||
The following items should be installed in your system:
|
||||
* Java 8 or newer.
|
||||
* git command line tool (https://help.github.com/articles/set-up-git)
|
||||
* Your preferred IDE
|
||||
* Eclipse with the m2e plugin. Note: when m2e is available, there is an m2 icon in `Help -> About` dialog. If m2e is
|
||||
not there, just follow the install process here: https://www.eclipse.org/m2e/
|
||||
* [Spring Tools Suite](https://spring.io/tools) (STS)
|
||||
* IntelliJ IDEA
|
||||
* [VS Code](https://code.visualstudio.com)
|
||||
|
||||
### Steps:
|
||||
|
||||
1) On the command line
|
||||
```
|
||||
git clone https://github.com/spring-projects/spring-petclinic.git
|
||||
```
|
||||
2) Inside Eclipse or STS
|
||||
```
|
||||
File -> Import -> Maven -> Existing Maven project
|
||||
```
|
||||
|
||||
Then either build on the command line `./mvnw generate-resources` or using the Eclipse launcher (right click on project and `Run As -> Maven install`) to generate the css. Run the application main method by right clicking on it and choosing `Run As -> Java Application`.
|
||||
|
||||
3) Inside IntelliJ IDEA
|
||||
In the main menu, choose `File -> Open` and select the Petclinic [pom.xml](pom.xml). Click on the `Open` button.
|
||||
|
||||
CSS files are generated from the Maven build. You can either build them on the command line `./mvnw generate-resources` or right click on the `spring-petclinic` project then `Maven -> Generates sources and Update Folders`.
|
||||
|
||||
A run configuration named `PetClinicApplication` should have been created for you if you're using a recent Ultimate version. Otherwise, run the application by right clicking on the `PetClinicApplication` main class and choosing `Run 'PetClinicApplication'`.
|
||||
|
||||
4) Navigate to Petclinic
|
||||
|
||||
Visit [http://localhost:8080](http://localhost:8080) in your browser.
|
||||
|
||||
|
||||
## Looking for something in particular?
|
||||
|
||||
|Spring Boot Configuration | Class or Java property files |
|
||||
|--------------------------|---|
|
||||
|The Main Class | [PetClinicApplication](https://github.com/spring-projects/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java) |
|
||||
|Properties Files | [application.properties](https://github.com/spring-projects/spring-petclinic/blob/main/src/main/resources) |
|
||||
|Caching | [CacheConfiguration](https://github.com/spring-projects/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/system/CacheConfiguration.java) |
|
||||
|
||||
## Interesting Spring Petclinic branches and forks
|
||||
|
||||
The Spring Petclinic "main" branch in the [spring-projects](https://github.com/spring-projects/spring-petclinic)
|
||||
GitHub org is the "canonical" implementation, currently based on Spring Boot and Thymeleaf. There are
|
||||
[quite a few forks](https://spring-petclinic.github.io/docs/forks.html) in a special GitHub org
|
||||
[spring-petclinic](https://github.com/spring-petclinic). If you have a special interest in a different technology stack
|
||||
that could be used to implement the Pet Clinic then please join the community there.
|
||||
|
||||
|
||||
## Interaction with other open source projects
|
||||
|
||||
One of the best parts about working on the Spring Petclinic application is that we have the opportunity to work in direct contact with many Open Source projects. We found some bugs/suggested improvements on various topics such as Spring, Spring Data, Bean Validation and even Eclipse! In many cases, they've been fixed/implemented in just a few days.
|
||||
Here is a list of them:
|
||||
|
||||
| Name | Issue |
|
||||
|------|-------|
|
||||
| Spring JDBC: simplify usage of NamedParameterJdbcTemplate | [SPR-10256](https://jira.springsource.org/browse/SPR-10256) and [SPR-10257](https://jira.springsource.org/browse/SPR-10257) |
|
||||
| Bean Validation / Hibernate Validator: simplify Maven dependencies and backward compatibility |[HV-790](https://hibernate.atlassian.net/browse/HV-790) and [HV-792](https://hibernate.atlassian.net/browse/HV-792) |
|
||||
| Spring Data: provide more flexibility when working with JPQL queries | [DATAJPA-292](https://jira.springsource.org/browse/DATAJPA-292) |
|
||||
|
||||
|
||||
# Contributing
|
||||
|
||||
The [issue tracker](https://github.com/spring-projects/spring-petclinic/issues) is the preferred channel for bug reports, features requests and submitting pull requests.
|
||||
|
||||
For pull requests, editor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at <https://editorconfig.org>. If you have not previously done so, please fill out and submit the [Contributor License Agreement](https://cla.pivotal.io/sign/spring).
|
||||
|
||||
# License
|
||||
|
||||
The Spring PetClinic sample application is released under version 2.0 of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0).
|
||||
|
||||
[spring-petclinic]: https://github.com/spring-projects/spring-petclinic
|
||||
[spring-framework-petclinic]: https://github.com/spring-petclinic/spring-framework-petclinic
|
||||
[spring-petclinic-angularjs]: https://github.com/spring-petclinic/spring-petclinic-angularjs
|
||||
[javaconfig branch]: https://github.com/spring-petclinic/spring-framework-petclinic/tree/javaconfig
|
||||
[spring-petclinic-angular]: https://github.com/spring-petclinic/spring-petclinic-angular
|
||||
[spring-petclinic-microservices]: https://github.com/spring-petclinic/spring-petclinic-microservices
|
||||
[spring-petclinic-reactjs]: https://github.com/spring-petclinic/spring-petclinic-reactjs
|
||||
[spring-petclinic-graphql]: https://github.com/spring-petclinic/spring-petclinic-graphql
|
||||
[spring-petclinic-kotlin]: https://github.com/spring-petclinic/spring-petclinic-kotlin
|
||||
[spring-petclinic-rest]: https://github.com/spring-petclinic/spring-petclinic-rest
|
|
@ -17,10 +17,11 @@ package org.springframework.cheapy.model;
|
|||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
@Entity
|
||||
@Table(name = "food_offers")
|
||||
public class FoodOffer extends Offer {
|
||||
|
@ -28,11 +29,11 @@ public class FoodOffer extends Offer {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//Plato específico
|
||||
@NotBlank
|
||||
@NotBlank(message = "Debe rellenar la comida a ofertar")
|
||||
private String food;
|
||||
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el descuento que proporciona")
|
||||
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
|
||||
private Integer discount;
|
||||
|
||||
public String getFood() {
|
||||
|
|
|
@ -6,6 +6,8 @@ import javax.persistence.Table;
|
|||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
@Entity
|
||||
@Table(name = "nu_offers")
|
||||
public class NuOffer extends Offer {
|
||||
|
@ -13,31 +15,31 @@ public class NuOffer extends Offer {
|
|||
//Oferta por numero de comensales
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
@NotNull(message = "Debe rellenar el tiempo del rango oro")
|
||||
@Min(1)
|
||||
private Integer gold;
|
||||
|
||||
@Column(name = "discount_gold")
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el descuento del rango oro")
|
||||
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
|
||||
private Integer discountGold;
|
||||
|
||||
@NotNull
|
||||
@NotNull(message = "Debe rellenar el tiempo del rango plata")
|
||||
@Min(1)
|
||||
private Integer silver;
|
||||
|
||||
@Column(name = "discount_silver")
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el descuento del rango plata")
|
||||
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
|
||||
private Integer discountSilver;
|
||||
|
||||
@NotNull
|
||||
@NotNull(message = "Debe rellenar el tiempo del rango bronce")
|
||||
@Min(1)
|
||||
private Integer bronze;
|
||||
|
||||
@Column(name = "discount_bronze")
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el descuento del rango bronce")
|
||||
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
|
||||
private Integer discountBronze;
|
||||
|
||||
public Integer getGold() {
|
||||
|
|
|
@ -35,13 +35,13 @@ public class Offer extends BaseEntity {
|
|||
// Clase padre
|
||||
|
||||
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
||||
@NotNull
|
||||
@Future
|
||||
@NotNull(message = "Debe introducir una fecha de inicio")
|
||||
@Future(message = "La fecha debe debe ser futura")
|
||||
private LocalDateTime start;
|
||||
|
||||
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
||||
@NotNull
|
||||
@Future
|
||||
@NotNull(message = "Debe introducir una fecha de fin")
|
||||
@Future(message = "La fecha debe debe ser futura")
|
||||
private LocalDateTime end;
|
||||
|
||||
private String code;
|
||||
|
|
|
@ -6,6 +6,8 @@ import javax.persistence.Table;
|
|||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
@Entity
|
||||
@Table(name = "speed_offers")
|
||||
public class SpeedOffer extends Offer {
|
||||
|
@ -13,31 +15,31 @@ public class SpeedOffer extends Offer {
|
|||
// Ofertar por rapidez comiendo
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el tiempo del rango oro")
|
||||
@Min(1)
|
||||
private Integer gold;
|
||||
|
||||
@Column(name = "discount_gold")
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el descuento del rango oro")
|
||||
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
|
||||
private Integer discountGold;
|
||||
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el tiempo del rango plata")
|
||||
@Min(1)
|
||||
private Integer silver;
|
||||
|
||||
@Column(name = "discount_silver")
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el descuento del rango plata")
|
||||
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
|
||||
private Integer discountSilver;
|
||||
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el tiempo del rango bronce")
|
||||
@Min(1)
|
||||
private Integer bronze;
|
||||
|
||||
@Column(name = "discount_bronze")
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@NotNull(message = "Debe rellenar el descuento del rango bronce")
|
||||
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
|
||||
private Integer discountBronze;
|
||||
|
||||
public Integer getGold() {
|
||||
|
|
|
@ -17,14 +17,14 @@ public class TimeOffer extends Offer {
|
|||
// Oferta por franja horaria
|
||||
|
||||
@DateTimeFormat(pattern = "HH:mm")
|
||||
@NotNull
|
||||
@NotNull(message = "Debe introducir una hora de inicio")
|
||||
private LocalTime init;
|
||||
|
||||
@DateTimeFormat(pattern = "HH:mm")
|
||||
@NotNull
|
||||
@NotNull(message = "Debe introducir una hora de fin")
|
||||
private LocalTime finish;
|
||||
|
||||
@NotNull
|
||||
@NotNull(message = "Debe rellenar el descuento")
|
||||
private Integer discount;
|
||||
|
||||
public LocalTime getInit() {
|
||||
|
|
|
@ -26,12 +26,6 @@ import org.springframework.cheapy.repository.AuthoritiesRepository;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Mostly used as a facade for all Petclinic controllers Also a placeholder
|
||||
* for @Transactional and @Cacheable annotations
|
||||
*
|
||||
* @author Michael Isvy
|
||||
*/
|
||||
@Service
|
||||
public class AuthoritiesService {
|
||||
/*
|
||||
|
|
|
@ -30,7 +30,17 @@ public class FoodOfferController {
|
|||
this.foodOfferService = foodOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkIdentity(final int foodOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
Client clientOffer = foodOffer.getClient();
|
||||
if (client.equals(clientOffer)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/food/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
|
@ -76,7 +86,6 @@ public class FoodOfferController {
|
|||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
|
||||
return "offers/food/foodOffersShow";
|
||||
|
||||
}
|
||||
|
@ -84,14 +93,21 @@ public class FoodOfferController {
|
|||
@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;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result,
|
||||
final ModelMap model) {
|
||||
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);
|
||||
|
@ -105,16 +121,22 @@ 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);
|
||||
return "foodOffers/foodOffersDisable";
|
||||
return "offers/food/foodOffersDisable";
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
|
@ -122,7 +144,7 @@ public class FoodOfferController {
|
|||
|
||||
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||
|
||||
return "redirect:/offers";
|
||||
return "redirect:/myOffers";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,17 @@ public class NuOfferController {
|
|||
model.put("nuOffer", nuOffer);
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
private boolean checkIdentity(final int nuOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
Client clientOffer = nuOffer.getClient();
|
||||
if (client.equals(clientOffer)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/nu/new")
|
||||
public String processCreationForm(@Valid NuOffer nuOffer, BindingResult result) {
|
||||
|
@ -83,7 +94,10 @@ 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);
|
||||
|
@ -92,6 +106,10 @@ 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);
|
||||
|
@ -104,24 +122,28 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
|
||||
final ModelMap model) {
|
||||
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);
|
||||
return "nuOffers/nuOffersDisable";
|
||||
return "offers/nu/nuOffersDisable";
|
||||
}
|
||||
|
||||
@PostMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
|
||||
final ModelMap model) {
|
||||
|
||||
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);
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
return "redirect:/offers";
|
||||
return "redirect:/myOffers";
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,17 @@ public class SpeedOfferController {
|
|||
this.speedOfferService = speedOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkIdentity(final int speedOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
Client clientOffer = speedOffer.getClient();
|
||||
if (client.equals(clientOffer)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/speed/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
|
@ -79,6 +89,10 @@ 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;
|
||||
|
@ -87,6 +101,10 @@ 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;
|
||||
|
@ -100,16 +118,22 @@ 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);
|
||||
return "speedOffers/speedOffersDisable";
|
||||
return "offers/speed/speedOffersDisable";
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
|
@ -117,7 +141,7 @@ public class SpeedOfferController {
|
|||
|
||||
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||
|
||||
return "redirect:/offers";
|
||||
return "redirect:/myOffers";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class TimeOfferController {
|
||||
|
||||
|
||||
private static final String VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM = "offers/time/createOrUpdateTimeOfferForm";
|
||||
private final TimeOfferService timeOfferService;
|
||||
private final ClientService clientService;
|
||||
|
@ -30,6 +29,17 @@ public class TimeOfferController {
|
|||
this.timeOfferService = timeOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
private boolean checkIdentity(final int timeOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
Client clientOffer = timeOffer.getClient();
|
||||
if (client.equals(clientOffer)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/time/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
|
@ -88,6 +98,9 @@ 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);
|
||||
|
@ -97,6 +110,9 @@ 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);
|
||||
|
@ -111,16 +127,22 @@ 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);
|
||||
return "timeOffers/timeOffersDisable";
|
||||
return "offers/time/timeOffersDisable";
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
|
@ -128,7 +150,7 @@ public class TimeOfferController {
|
|||
|
||||
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||
|
||||
return "redirect:/offers";
|
||||
return "redirect:/myOffers";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
|
||||
__^__ __^__
|
||||
( ___ )------------------------------------( ___ )
|
||||
| / | | \ |
|
||||
|
@ -5,5 +7,4 @@
|
|||
|___| |___|
|
||||
(_____)------------------------------------(_____)
|
||||
|
||||
:: Built with Spring Boot :: ${spring-boot.version}
|
||||
|
||||
-- Built with Spring Boot -- (${spring-boot.version})
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
<petclinic:layout pageName="foodOffers">
|
||||
<cheapy:layout pageName="foodOffers">
|
||||
<h2>
|
||||
<c:if test="${foodOffer['new']}">Nueva </c:if> Oferta de plato específico
|
||||
</h2>
|
||||
|
@ -15,10 +15,10 @@
|
|||
<form:hidden path="id"/>
|
||||
<form:hidden path="code"/>
|
||||
<form:hidden path="status"/>
|
||||
<petclinic:inputField label="Fecha de inicio" placeholder="15/06/2021 14:00" name="start"/>
|
||||
<petclinic:inputField label="Fecha de fin" placeholder="15/06/2021 16:00" name="end"/>
|
||||
<petclinic:inputField label="Food" name="food"/>
|
||||
<petclinic:inputField label="Discount" name="discount"/>
|
||||
<cheapy:inputField label="Fecha de inicio" placeholder="15/06/2021 14:00" name="start"/>
|
||||
<cheapy:inputField label="Fecha de fin" placeholder="15/06/2021 16:00" name="end"/>
|
||||
<cheapy:inputField label="Comida" name="food"/>
|
||||
<cheapy:inputField label="Descuento" name="discount"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
|
@ -33,4 +33,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</form:form>
|
||||
</petclinic:layout>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
|
||||
<petclinic:layout pageName="foodOffer">
|
||||
<cheapy:layout pageName="foodOffer">
|
||||
|
||||
<jsp:body>
|
||||
<h2> ¿Está seguro de que quiere eliminar su oferta? </h2>
|
||||
|
@ -20,4 +20,4 @@
|
|||
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||
|
||||
</jsp:body>
|
||||
</petclinic:layout>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="foodOffer">
|
||||
|
@ -29,7 +30,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="discount"/></th>
|
||||
<td><c:out value="${foodOffer.discount}"/></td>
|
||||
<td><c:out value="${foodOffer.discount} %"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
@ -44,15 +45,19 @@
|
|||
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('client')">
|
||||
<spring:url value="{foodOfferId}/edit" var="editUrl">
|
||||
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||
</sec:authorize>
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('client')">
|
||||
<spring:url value="{foodOfferId}/disable" var="editUrl">
|
||||
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
|
||||
</sec:authorize>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
<petclinic:layout pageName="NumOffers">
|
||||
<cheapy:layout pageName="NumOffers">
|
||||
<h2>
|
||||
<c:if test="${nuOffer['new']}">Nueva </c:if> Oferta por número de comensales
|
||||
</h2>
|
||||
|
@ -15,15 +15,15 @@
|
|||
<form:hidden path="id"/>
|
||||
<form:hidden path="code"/>
|
||||
<form:hidden path="status"/>
|
||||
<petclinic:inputField label="Fecha de inicio" placeholder="15/06/2021 14:00" name="start"/>
|
||||
<petclinic:inputField label="Fecha de fin" placeholder="15/06/2021 16:00" name="end"/>
|
||||
<cheapy:inputField label="Fecha de inicio" placeholder="15/06/2021 14:00" name="start"/>
|
||||
<cheapy:inputField label="Fecha de fin" placeholder="15/06/2021 16:00" name="end"/>
|
||||
|
||||
<petclinic:inputField label="Oro" name="gold"/>
|
||||
<petclinic:inputField label="Descuento de oro" name="discountGold"/>
|
||||
<petclinic:inputField label="Plata" name="silver"/>
|
||||
<petclinic:inputField label="Descuento de plata" name="discountSilver"/>
|
||||
<petclinic:inputField label="Bronce" name="bronze"/>
|
||||
<petclinic:inputField label="Descuento de bronce" name="discountBronze"/>
|
||||
<cheapy:inputField label="Oro" name="gold"/>
|
||||
<cheapy:inputField label="Descuento de oro" name="discountGold"/>
|
||||
<cheapy:inputField label="Plata" name="silver"/>
|
||||
<cheapy:inputField label="Descuento de plata" name="discountSilver"/>
|
||||
<cheapy:inputField label="Bronce" name="bronze"/>
|
||||
<cheapy:inputField label="Descuento de bronce" name="discountBronze"/>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -39,4 +39,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</form:form>
|
||||
</petclinic:layout>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
|
||||
<petclinic:layout pageName="nuOffer">
|
||||
<cheapy:layout pageName="nuOffer">
|
||||
|
||||
<jsp:body>
|
||||
<h2> ¿Está seguro de que quiere dar de baja su oferta? </h2>
|
||||
|
@ -24,4 +24,4 @@
|
|||
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||
|
||||
</jsp:body>
|
||||
</petclinic:layout>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="nuOffer">
|
||||
|
@ -26,7 +27,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="goldDiscount"/></th>
|
||||
<td><c:out value="${nuOffer.discountGold}"/></td>
|
||||
<td><c:out value="${nuOffer.discountGold} %"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="silverGoal"/></th>
|
||||
|
@ -34,7 +35,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="silverDiscount"/></th>
|
||||
<td><c:out value="${nuOffer.discountSilver}"/></td>
|
||||
<td><c:out value="${nuOffer.discountSilver} %"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="bronzeGoal"/></th>
|
||||
|
@ -42,7 +43,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="bronzeDiscount"/></th>
|
||||
<td><c:out value="${nuOffer.discountBronze}"/></td>
|
||||
<td><c:out value="${nuOffer.discountBronze} %"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="offerCode"/></th>
|
||||
|
@ -55,15 +56,19 @@
|
|||
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('client')">
|
||||
<spring:url value="{nuOfferId}/edit" var="editUrl">
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||
</sec:authorize>
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('client')">
|
||||
<spring:url value="{nuOfferId}/disable" var="editUrl">
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
|
||||
</sec:authorize>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
<petclinic:layout pageName="speedOffers">
|
||||
<cheapy:layout pageName="speedOffers">
|
||||
<h2>
|
||||
<c:if test="${speedOffer['new']}">Nueva </c:if> Oferta por velocidad
|
||||
</h2>
|
||||
|
@ -15,14 +15,14 @@
|
|||
<form:hidden path="id"/>
|
||||
<form:hidden path="code"/>
|
||||
<form:hidden path="status"/>
|
||||
<petclinic:inputField label="Fecha de inicio" placeholder="15/06/2021 14:00" name="start"/>
|
||||
<petclinic:inputField label="Fecha de fin" placeholder="15/06/2021 16:00" name="end"/>
|
||||
<petclinic:inputField label="Oro" name="gold"/>
|
||||
<petclinic:inputField label="Descuento oro" name="discountGold"/>
|
||||
<petclinic:inputField label="Plata" name="silver"/>
|
||||
<petclinic:inputField label="Descuento plata" name="discountSilver"/>
|
||||
<petclinic:inputField label="Bronce" name="bronze"/>
|
||||
<petclinic:inputField label="Descuento bronce" name="discountBronze"/>
|
||||
<cheapy:inputField label="Fecha de inicio" placeholder="15/06/2021 14:00" name="start"/>
|
||||
<cheapy:inputField label="Fecha de fin" placeholder="15/06/2021 16:00" name="end"/>
|
||||
<cheapy:inputField label="Oro" name="gold"/>
|
||||
<cheapy:inputField label="Descuento oro" name="discountGold"/>
|
||||
<cheapy:inputField label="Plata" name="silver"/>
|
||||
<cheapy:inputField label="Descuento plata" name="discountSilver"/>
|
||||
<cheapy:inputField label="Bronce" name="bronze"/>
|
||||
<cheapy:inputField label="Descuento bronce" name="discountBronze"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
|
@ -37,4 +37,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</form:form>
|
||||
</petclinic:layout>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
|
||||
<petclinic:layout pageName="speedOffer">
|
||||
<cheapy:layout pageName="speedOffer">
|
||||
|
||||
<jsp:body>
|
||||
<h2> ¿Está seguro de que quiere dar de baja su oferta? </h2>
|
||||
|
@ -24,4 +24,4 @@
|
|||
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||
|
||||
</jsp:body>
|
||||
</petclinic:layout>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="speedOffer">
|
||||
|
@ -26,7 +27,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="goldDiscount"/></th>
|
||||
<td><c:out value="${speedOffer.discountGold}"/></td>
|
||||
<td><c:out value="${speedOffer.discountGold} %"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="silverGoal"/></th>
|
||||
|
@ -34,7 +35,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="silverDiscount"/></th>
|
||||
<td><c:out value="${speedOffer.discountSilver}"/></td>
|
||||
<td><c:out value="${speedOffer.discountSilver} %"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="bronzeGoal"/></th>
|
||||
|
@ -42,7 +43,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="bronzeDiscount"/></th>
|
||||
<td><c:out value="${speedOffer.discountBronze}"/></td>
|
||||
<td><c:out value="${speedOffer.discountBronze} %"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="offerCode"/></th>
|
||||
|
@ -56,14 +57,18 @@
|
|||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('client')">
|
||||
<spring:url value="{speedOfferId}/edit" var="editUrl">
|
||||
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||
</sec:authorize>
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('client')">
|
||||
<spring:url value="{speedOfferId}/disable" var="editUrl">
|
||||
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
|
||||
</sec:authorize>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
<petclinic:layout pageName="TimeOffers">
|
||||
<cheapy:layout pageName="TimeOffers">
|
||||
<h2>
|
||||
<c:if test="${timeOffer['new']}">Nueva </c:if> Oferta por tiempo
|
||||
</h2>
|
||||
|
@ -15,12 +15,12 @@
|
|||
<form:hidden path="id"/>
|
||||
<form:hidden path="code"/>
|
||||
<form:hidden path="status"/>
|
||||
<petclinic:inputField label="Fecha de inicio" placeholder="15/06/2021 14:00" name="start"/>
|
||||
<petclinic:inputField label="Fecha de fin" placeholder="15/06/2021 16:00" name="end"/>
|
||||
<cheapy:inputField label="Fecha de inicio" placeholder="15/06/2021 14:00" name="start"/>
|
||||
<cheapy:inputField label="Fecha de fin" placeholder="15/06/2021 16:00" name="end"/>
|
||||
|
||||
<petclinic:inputField label="Hora de inicio" name="init"/>
|
||||
<petclinic:inputField label="Hora de final" name="finish"/>
|
||||
<petclinic:inputField label="Descuento" name="discount"/>
|
||||
<cheapy:inputField label="Hora de inicio" name="init"/>
|
||||
<cheapy:inputField label="Hora de final" name="finish"/>
|
||||
<cheapy:inputField label="Descuento" name="discount"/>
|
||||
|
||||
|
||||
</div>
|
||||
|
@ -37,4 +37,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</form:form>
|
||||
</petclinic:layout>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
|
||||
<petclinic:layout pageName="foodOffer">
|
||||
<cheapy:layout pageName="foodOffer">
|
||||
|
||||
<jsp:body>
|
||||
<h2> ¿Está seguro de que quiere eliminar su oferta? </h2>
|
||||
|
@ -21,4 +21,4 @@
|
|||
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||
|
||||
</jsp:body>
|
||||
</petclinic:layout>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="timeOffer">
|
||||
|
@ -23,7 +24,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="discount"/></th>
|
||||
<td><c:out value="${timeOffer.discount}"/></td>
|
||||
<td><c:out value="${timeOffer.discount} %"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="offerCode"/></th>
|
||||
|
@ -31,16 +32,20 @@
|
|||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('client')">
|
||||
<spring:url value="{timeOfferId}/edit" var="editUrl">
|
||||
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
|
||||
</sec:authorize>
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('client')">
|
||||
<spring:url value="{timeOfferId}/disable" var="editUrl">
|
||||
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
|
||||
</sec:authorize>
|
||||
|
||||
<div class="btn-return">
|
||||
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
|
|
|
@ -14,7 +14,7 @@ Cheapy :: a Spring Framework demonstration
|
|||
<spring:url value="/resources/images/faviconChikito.png" var="favicon"/>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="${favicon}">
|
||||
|
||||
<title>Cheapy : eat fast, eat cheapy</title>
|
||||
<title>Cheapy: Eat fast, eat cheapy</title>
|
||||
|
||||
<%-- CSS generated from LESS --%>
|
||||
<spring:url value="/resources/css/cheapy.css" var="cheapyCss"/>
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
description="Name of corresponding property in bean object" %>
|
||||
<%@ attribute name="label" required="true" rtexprvalue="true"
|
||||
description="Label appears in red color if input is considered as invalid after submission" %>
|
||||
<%@ attribute name="placeholder" required="false" rtexprvalue="true"
|
||||
description="Example for input field" %>
|
||||
|
||||
<spring:bind path="${name}">
|
||||
<c:set var="cssGroup" value="form-group ${status.error ? 'has-error' : '' }"/>
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
<span>Inicio</span>
|
||||
</cheapy:menuItem>
|
||||
|
||||
<cheapy:menuItem active="${name eq 'ofertas'}" url="/offers"
|
||||
title="ofertas">
|
||||
<cheapy:menuItem active="${name eq 'ofertas'}" url="/offers" title="ofertas">
|
||||
<span class="glyphicon glyphicon-cutlery" aria-hidden="true"></span>
|
||||
<span>Ver ofertas</span>
|
||||
</cheapy:menuItem>
|
||||
|
@ -44,7 +43,7 @@
|
|||
<cheapy:menuItem active="${name eq 'contactanos'}" url="/contactanos"
|
||||
title="contactanos">
|
||||
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
|
||||
<span>Contáctanos</span>
|
||||
<span>Cont<EFBFBD>ctanos</span>
|
||||
</cheapy:menuItem>
|
||||
-->
|
||||
<sec:authorize access="isAuthenticated()">
|
||||
|
@ -52,9 +51,9 @@
|
|||
<span class="glyphicon glyphicon-cutlery" aria-hidden="true"></span>
|
||||
<span>Opiniones</span>
|
||||
</cheapy:menuItem>
|
||||
<cheapy:menuItem active="${name eq 'reviewsN'}" url="/reviews/new" title="valóranos">
|
||||
<cheapy:menuItem active="${name eq 'reviewsN'}" url="/reviews/new" title="val<EFBFBD>ranos">
|
||||
<span class="glyphicon glyphicon-cutlery" aria-hidden="true"></span>
|
||||
<span>Valóranos</span>
|
||||
<span>Val<EFBFBD>ranos</span>
|
||||
</cheapy:menuItem>
|
||||
</sec:authorize>
|
||||
|
||||
|
@ -63,12 +62,12 @@
|
|||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<sec:authorize access="!isAuthenticated()">
|
||||
<li><a href="<c:url value="/login" />">Login</a></li>
|
||||
<li><a href="<c:url value="/login" />">Iniciar sesi<73>n</a></li>
|
||||
<!--<li><a href="<c:url value="/users/new" />">Register</a></li>-->
|
||||
</sec:authorize>
|
||||
<sec:authorize access="isAuthenticated()">
|
||||
<li class="dropdown"><a href="#" class="dropdown-toggle"
|
||||
data-toggle="dropdown"> <span class="glyphicon glyphicon-user"></span>
|
||||
data-toggle="dropdown"> <span class="glyphicon glyphicon-user"></span><EFBFBD>
|
||||
<strong><sec:authentication property="name" /></strong> <span
|
||||
class="glyphicon glyphicon-chevron-down"></span>
|
||||
</a>
|
||||
|
|
Loading…
Reference in a new issue