mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Merge branch 'develop' into travis
This commit is contained in:
commit
03c741b770
41 changed files with 632 additions and 114 deletions
|
@ -37,7 +37,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||
.antMatchers("/users/new").permitAll()
|
||||
|
||||
.antMatchers("/login/**").anonymous()
|
||||
.antMatchers("/logout").permitAll()
|
||||
.antMatchers("/logout").authenticated()
|
||||
|
||||
.antMatchers("/usuarios/new").permitAll()
|
||||
.antMatchers("/admin/**").hasAnyAuthority("admin")
|
||||
|
@ -53,11 +53,12 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||
.antMatchers("/offersCreate").hasAuthority("client")
|
||||
|
||||
|
||||
.antMatchers("/reviews/**").authenticated()
|
||||
|
||||
.and().formLogin()
|
||||
.loginPage("/login").permitAll()
|
||||
.loginPage("/login")
|
||||
.failureUrl("/login?error")
|
||||
.and().logout().logoutSuccessUrl("/login");
|
||||
.and().logout().logoutSuccessUrl("/");
|
||||
|
||||
// Configuración para que funcione la consola de administración
|
||||
// de la BD H2 (deshabilitar las cabeceras de protección contra
|
||||
|
|
56
src/main/java/org/springframework/cheapy/model/Review.java
Normal file
56
src/main/java/org/springframework/cheapy/model/Review.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package org.springframework.cheapy.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import com.sun.istack.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "review")
|
||||
public class Review extends BaseEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "Debe rellenar la valoración de Cheapy")
|
||||
@Column(length=16777215)
|
||||
private String opinion;
|
||||
|
||||
@NotNull
|
||||
@Range(min = 1, max = 5)
|
||||
private Integer stars;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "username", referencedColumnName = "username")
|
||||
private User escritor;
|
||||
|
||||
public User getEscritor() {
|
||||
return escritor;
|
||||
}
|
||||
|
||||
public void setEscritor(User escritor) {
|
||||
this.escritor = escritor;
|
||||
}
|
||||
|
||||
public String getOpinion() {
|
||||
return opinion;
|
||||
}
|
||||
|
||||
public void setOpinion(String opinion) {
|
||||
this.opinion = opinion;
|
||||
}
|
||||
|
||||
public Integer getStars() {
|
||||
return stars;
|
||||
}
|
||||
|
||||
public void setStars(Integer stars) {
|
||||
this.stars = stars;
|
||||
}
|
||||
|
||||
}
|
|
@ -28,4 +28,8 @@ public interface FoodOfferRepository extends Repository<FoodOffer, Integer> {
|
|||
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE foodOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<FoodOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT foodOffer FROM FoodOffer foodOffer WHERE foodOffer.client.id =:id AND foodOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<FoodOffer> findFoodOfferActOclByUserId(@Param("id") Integer id);
|
||||
}
|
||||
|
|
|
@ -27,4 +27,8 @@ public interface NuOfferRepository extends Repository<NuOffer, Integer> {
|
|||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.id =:id AND nuOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findNuOfferActOclByUserId(@Param("id") Integer id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cheapy.model.Review;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface ReviewRepository extends Repository<Review, Integer> {
|
||||
|
||||
@Query("SELECT r FROM Review r")
|
||||
@Transactional(readOnly = true)
|
||||
List<Review> findAllReviews();
|
||||
|
||||
void save(Review review);
|
||||
|
||||
@Query("SELECT r FROM Review r WHERE id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
Review findReviewById(@Param("id") Integer id);
|
||||
}
|
|
@ -29,4 +29,8 @@ public interface SpeedOfferRepository extends Repository<SpeedOffer, Integer> {
|
|||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.id =:id AND speedOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findSpeedOfferActOclByUserId(@Param("id") Integer id);
|
||||
}
|
||||
|
|
|
@ -26,4 +26,8 @@ public interface TimeOfferRepository extends Repository<TimeOffer, Integer> {
|
|||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.id =:id AND timeOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findTimeOfferActOclByUserId(@Param("id") Integer id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.model.Usuario;
|
||||
|
||||
public interface UserRepository extends CrudRepository<Usuario, String> {
|
||||
|
||||
@Query("SELECT u FROM User u WHERE username =:username")
|
||||
@Transactional(readOnly = true)
|
||||
User findByUsername(String username);
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.cheapy.model.Usuario;
|
||||
|
||||
public interface UsuarioRepository extends CrudRepository<Usuario, String> {
|
||||
|
||||
//Usuario findByUsername(String currentPrincipalName);
|
||||
|
||||
}
|
|
@ -37,4 +37,8 @@ public class FoodOfferService {
|
|||
public List<FoodOffer> findFoodOfferByUserId(final int id) {
|
||||
return this.foodOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
public List<FoodOffer> findFoodOfferActOclByUserId(final int id) {
|
||||
return this.foodOfferRepository.findFoodOfferActOclByUserId(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,4 +47,8 @@ public class NuOfferService {
|
|||
public List<NuOffer> findNuOfferByUserId(final int id) {
|
||||
return this.nuOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
public List<NuOffer> findNuOfferActOclByUserId(final int id) {
|
||||
return this.nuOfferRepository.findNuOfferActOclByUserId(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.Review;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.repository.ReviewRepository;
|
||||
import org.springframework.cheapy.repository.TimeOfferRepository;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class ReviewService {
|
||||
private ReviewRepository reviewRepository;
|
||||
|
||||
@Autowired
|
||||
public ReviewService(final ReviewRepository reviewRepository) {
|
||||
this.reviewRepository = reviewRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Review findReviewById(final int id) {
|
||||
return this.reviewRepository.findReviewById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Review> findAllReviews() {
|
||||
return this.reviewRepository.findAllReviews();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveReview(final Review Review) throws DataAccessException {
|
||||
this.reviewRepository.save(Review);
|
||||
}
|
||||
|
||||
}
|
|
@ -44,4 +44,8 @@ public class SpeedOfferService {
|
|||
public List<SpeedOffer> findSpeedOfferByUserId(final int id) {
|
||||
return this.speedOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
public List<SpeedOffer> findSpeedOfferActOclByUserId(final int id) {
|
||||
return this.speedOfferRepository.findSpeedOfferActOclByUserId(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,4 +40,8 @@ public class TimeOfferService {
|
|||
public List<TimeOffer> findTimeOfferByUserId(final int id) {
|
||||
return this.timeOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
public List<TimeOffer> findTimeOfferActOclByUserId(final int id) {
|
||||
return this.timeOfferRepository.findTimeOfferActOclByUserId(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package org.springframework.cheapy.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.repository.UserRepository;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
public UserService(final UserRepository userRepository) {
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public User getCurrentUser() throws DataAccessException {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String username = authentication.getName();
|
||||
return this.userRepository.findByUsername(username);
|
||||
}
|
||||
|
||||
}
|
|
@ -104,13 +104,15 @@ public class FoodOfferController {
|
|||
public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map<String, Object> model) {
|
||||
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
|
||||
if(!foodOffer.getStatus().equals(StatusOffer.active)) {
|
||||
return "error";
|
||||
}else {
|
||||
model.put("foodOffer", foodOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
return "offers/food/foodOffersShow";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
|
|
|
@ -133,10 +133,14 @@ public class NuOfferController {
|
|||
@GetMapping("/offers/nu/{nuOfferId}")
|
||||
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
if(!nuOffer.getStatus().equals(StatusOffer.active)) {
|
||||
return "error";
|
||||
}else {
|
||||
model.put("nuOffer", nuOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -174,15 +178,15 @@ public class NuOfferController {
|
|||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
if(!this.checkDates(nuOffer)) {
|
||||
if(!this.checkDates(nuOfferEdit)) {
|
||||
//Poner aqui mensaje de error
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
if(!this.checkConditions(nuOffer)) {
|
||||
if(!this.checkConditions(nuOfferEdit)) {
|
||||
//Poner aqui mensaje de error
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
if(!this.checkDiscounts(nuOffer)) {
|
||||
if(!this.checkDiscounts(nuOfferEdit)) {
|
||||
//Poner aqui mensaje de error
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ public class OfertaController {
|
|||
|
||||
int actual = this.clientService.getCurrentClient().getId();
|
||||
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findFoodOfferByUserId(actual);
|
||||
List<NuOffer> nuOfferLs = this.nuOfferService.findNuOfferByUserId(actual);
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findSpeedOfferByUserId(actual);
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findTimeOfferByUserId(actual);
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findFoodOfferActOclByUserId(actual);
|
||||
List<NuOffer> nuOfferLs = this.nuOfferService.findNuOfferActOclByUserId(actual);
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findSpeedOfferActOclByUserId(actual);
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findTimeOfferActOclByUserId(actual);
|
||||
|
||||
model.put("foodOfferLs", foodOfferLs);
|
||||
model.put("nuOfferLs", nuOfferLs);
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.cheapy.model.Review;
|
||||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.service.ReviewService;
|
||||
import org.springframework.cheapy.service.UserService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@Controller
|
||||
public class ReviewController {
|
||||
|
||||
|
||||
private static final String VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM = "reviews/createOrUpdateReviewForm";
|
||||
private final ReviewService reviewService;
|
||||
private final UserService userService;
|
||||
|
||||
public ReviewController(final ReviewService reviewService, final UserService userService) {
|
||||
this.reviewService = reviewService;
|
||||
this.userService = userService;
|
||||
}
|
||||
private boolean checkIdentity(final int reviewId) {
|
||||
boolean res = false;
|
||||
User user = this.userService.getCurrentUser();
|
||||
Review review = this.reviewService.findReviewById(reviewId);
|
||||
User reviewsAuthor = review.getEscritor();
|
||||
if (user.equals(reviewsAuthor)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@GetMapping("/reviews")
|
||||
public String processFindForm( Map<String, Object> model) {
|
||||
|
||||
List<Review> reviewsLs=this.reviewService.findAllReviews();
|
||||
model.put("reviewsLs", reviewsLs);
|
||||
|
||||
return "reviews/reviewsList";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/reviews/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
Review review = new Review();
|
||||
model.put("review", review);
|
||||
return VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/reviews/new")
|
||||
public String processCreationForm(@Valid Review review, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
} else {
|
||||
User escritor = this.userService.getCurrentUser();
|
||||
review.setEscritor(escritor);
|
||||
|
||||
this.reviewService.saveReview(review);
|
||||
return "redirect:/reviews/" + review.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/reviews/{reviewId}")
|
||||
public String processShowForm(@PathVariable("reviewId") int reviewId, Map<String, Object> model) {
|
||||
|
||||
Review review = this.reviewService.findReviewById(reviewId);
|
||||
|
||||
model.put("review", review);
|
||||
|
||||
|
||||
return "reviews/reviewsShow";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/reviews/{reviewId}/edit")
|
||||
public String updateReview(@PathVariable("reviewId") final int reviewId, final ModelMap model) {
|
||||
if (!this.checkIdentity(reviewId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
Review review = this.reviewService.findReviewById(reviewId);
|
||||
model.addAttribute("review", review);
|
||||
return ReviewController.VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/reviews/{reviewId}/edit")
|
||||
public String updateReview(@Valid final Review reviewEdit, final BindingResult result, final ModelMap model) {
|
||||
if (!this.checkIdentity(reviewEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("review", reviewEdit);
|
||||
return ReviewController.VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
User escritor = this.userService.getCurrentUser();
|
||||
reviewEdit.setEscritor(escritor);
|
||||
|
||||
this.reviewService.saveReview(reviewEdit);
|
||||
return "redirect:/reviews/" + reviewEdit.getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -125,12 +125,15 @@ public class SpeedOfferController {
|
|||
|
||||
@GetMapping("/offers/speed/{speedOfferId}")
|
||||
public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map<String, Object> model) {
|
||||
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
if(!speedOffer.getStatus().equals(StatusOffer.active)) {
|
||||
return "error";
|
||||
}else {
|
||||
model.put("speedOffer", speedOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
|
@ -167,15 +170,15 @@ public class SpeedOfferController {
|
|||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
if(!this.checkDates(speedOffer)) {
|
||||
if(!this.checkDates(speedOfferEdit)) {
|
||||
//Poner aqui mensaje de error
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
if(!this.checkConditions(speedOffer)) {
|
||||
if(!this.checkConditions(speedOfferEdit)) {
|
||||
//Poner aqui mensaje de error
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
if(!this.checkDiscounts(speedOffer)) {
|
||||
if(!this.checkDiscounts(speedOfferEdit)) {
|
||||
//Poner aqui mensaje de error
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
|
|
@ -121,12 +121,15 @@ public class TimeOfferController {
|
|||
public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map<String, Object> model) {
|
||||
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
|
||||
if(!timeOffer.getStatus().equals(StatusOffer.active)) {
|
||||
return "error";
|
||||
}else {
|
||||
model.put("timeOffer", timeOffer);
|
||||
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
return "offers/time/timeOffersShow";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -165,11 +168,11 @@ public class TimeOfferController {
|
|||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
} else {
|
||||
if(!this.checkDates(timeOffer)) {
|
||||
if(!this.checkDates(timeOfferEdit)) {
|
||||
//Poner aqui mensaje de error
|
||||
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
if(!this.checkTimes(timeOffer)) {
|
||||
if(!this.checkTimes(timeOfferEdit)) {
|
||||
//Poner aqui mensaje de error
|
||||
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ spring.jpa.properties.javax.persistence.schema-generation.drop-script-source=dro
|
|||
|
||||
# Internationalization
|
||||
spring.messages.basename=messages/messages
|
||||
|
||||
spring.messages.encoding=UTF-8
|
||||
|
||||
# Views
|
||||
spring.mvc.view.prefix: /WEB-INF/jsp/
|
||||
|
@ -35,4 +35,4 @@ logging.level.org.springframework=INFO
|
|||
# logging.level.org.springframework.context.annotation=TRACE
|
||||
|
||||
# Maximum time static resources should be cached
|
||||
spring.resources.cache.cachecontrol.max-age=12h
|
||||
spring.resources.cache.cachecontrol.max-age=12h
|
||||
|
|
|
@ -37,8 +37,13 @@ nonNumeric=Solo debe contener números
|
|||
duplicateFormSubmission=No se permite el envío de formularios duplicados
|
||||
typeMismatch.date=Fecha inválida
|
||||
typeMismatch.birthDate=Fecha inválida
|
||||
createFoodOffers= Crear ofertas por plato espec<65>fico
|
||||
createNuOffers= Crear ofertas por n<>mero de comensales
|
||||
review= Reseña
|
||||
reviews= Reseñas
|
||||
stars= Estrellas
|
||||
opinion= Opinión
|
||||
user = Nombre de usuario
|
||||
createFoodOffers= Crear ofertas por plato específico
|
||||
createNuOffers= Crear ofertas por número de comensales
|
||||
createSpeedOffers= Crear ofertas por rapidez comiendo
|
||||
createTimeOffers= Crear ofertas por franja horaria
|
||||
init= Inicio del intervalo
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
|
||||
<cheapy:layout pageName="error">
|
||||
|
||||
<h2 style="text-align:center">Algo malo ha pasado...</h2>
|
||||
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>Algo malo ha pasado...</em></h2>
|
||||
|
||||
<spring:url value="/resources/images/Logo Cheapy.png" htmlEscape="true" var="cheapyImage"/>
|
||||
<img class="img-responsive" src="${cheapyImage}"/>
|
||||
|
|
|
@ -282,26 +282,24 @@
|
|||
<div class="fadeIn first">
|
||||
<img src="/resources/images/Logo Cheapy.png" id="icon" />
|
||||
<c:if test= "${not empty param}" >
|
||||
<p class="text-danger"> El usuario y/o la contraseña son incorrectos </p>
|
||||
<p class="text-danger"> El usuario y/o la contraseña son incorrectos </p>
|
||||
|
||||
</c:if>
|
||||
</div>
|
||||
<div th:if="${param.error}">
|
||||
<p class="text-danger">Nombre de usuario o contraseña inválido</p>
|
||||
</div>
|
||||
|
||||
<!-- Login Form -->
|
||||
<form class='form-signin' action="/login" method='POST'>
|
||||
<input type="text" id="username" class="fadeIn second" name="username" placeholder="nombre de usuario" required autofocus>
|
||||
<input type="password" id="password" class="fadeIn third" name="password" placeholder="contraseña" required>
|
||||
<input type="text" id="username" class="fadeIn second" name="username" placeholder="Usuario" required autofocus>
|
||||
<input type="password" id="password" class="fadeIn third" name="password" placeholder="Contraseña" required>
|
||||
<sec:csrfInput />
|
||||
<input type="submit" class="fadeIn fourth" value="Acceder">
|
||||
<input type="submit" class="fadeIn fourth" value="Iniciar sesión">
|
||||
</form>
|
||||
|
||||
<!-- Remind Passowrd
|
||||
<!-- Remind Passowrd
|
||||
<div id="formFooter">
|
||||
<a class="underlineHover" href="#">¿Olvidó su contraseña?</a>
|
||||
<a class="underlineHover" href="#">¿Olvidó su contraseña?</a>
|
||||
</div>
|
||||
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -4,21 +4,32 @@
|
|||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<cheapy:layout pageName="foodOffer">
|
||||
|
||||
<jsp:body>
|
||||
<h2> ¿Está seguro de que quiere eliminar su oferta? </h2>
|
||||
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>¿Está seguro de que quiere eliminar su oferta?</em></h2>
|
||||
|
||||
<form:form modelAttribute="foodOffer" class="form-horizontal">
|
||||
|
||||
<input type="hidden" name="food" value="${foodOffer.food}" />
|
||||
<input type="hidden" name="discount" value="${foodOffer.discount}" />
|
||||
|
||||
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
|
||||
<div class="btns-edit">
|
||||
<button type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Dar de baja</button>
|
||||
</div>
|
||||
</form:form>
|
||||
|
||||
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||
|
||||
<div class="btn-return">
|
||||
<button type="button" role="link" onclick="goBack()" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back()
|
||||
}
|
||||
</script>
|
||||
</jsp:body>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Editar oferta</button>
|
||||
|
||||
<c:if test="${foodOffer.status eq 'inactive' }">
|
||||
<c:if test="${foodOffer.status eq 'hidden' }">
|
||||
<spring:url value="{foodOfferId}/activate" var="activateUrl">
|
||||
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||
</spring:url>
|
||||
|
@ -72,9 +72,8 @@
|
|||
Desactivar oferta</button>
|
||||
</c:if>
|
||||
</div>
|
||||
|
||||
</sec:authorize>
|
||||
</div>
|
||||
</sec:authorize>
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back()
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="myOffers">
|
||||
<cheapy:layout pageName="ofertasM">
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
|
||||
<c:if test="${empty foodOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
<cheapy:inputField label="Fecha de Inicio" placeholder="dd/MM/yyyy HH:mm" name="start"/>
|
||||
<cheapy:inputField label="Fecha de Fin" placeholder="dd/MM/yyyy HH:mm" name="end"/>
|
||||
|
||||
<cheapy:inputField label="Número de comensales (nivel Oro)" placeholder="XX (Ej. 6)" name="gold"/>
|
||||
<cheapy:inputField label="Número de comensales (nivel Oro)" placeholder="XX (Ej. 6)" name="gold"/>
|
||||
<cheapy:inputField label="Descuento de nivel oro" placeholder="XX% (Ej. 30)" name="discountGold"/>
|
||||
<cheapy:inputField label="Número de comensales (nivel Plata)" placeholder="XX (Ej. 4)" name="silver"/>
|
||||
<cheapy:inputField label="Número de comensales (nivel Plata)" placeholder="XX (Ej. 4)" name="silver"/>
|
||||
<cheapy:inputField label="Descuento de plata" placeholder="XX% (Ej. 15)" name="discountSilver"/>
|
||||
<cheapy:inputField label="Número de comensales (nivel Bronce)" placeholder="XX (Ej. 2)" name="bronze"/>
|
||||
<cheapy:inputField label="Número de comensales (nivel Bronce)" placeholder="XX (Ej. 2)" name="bronze"/>
|
||||
<cheapy:inputField label="Descuento de bronce" placeholder="XX% (Ej. 5)" name="discountBronze"/>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -4,24 +4,32 @@
|
|||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<petclinic:layout pageName="nuOfferDisable">
|
||||
<cheapy:layout pageName="nuOfferDisable">
|
||||
|
||||
<jsp:body>
|
||||
<h2> ¿Está seguro de que quiere dar de baja su offer? </h2>
|
||||
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>¿Está seguro de que quiere eliminar su oferta?</em></h2>
|
||||
|
||||
<form:form modelAttribute="nuOffer" class="form-horizontal">
|
||||
<input type="hidden" name="gold" value="${nuOffer.gold}" />
|
||||
<input type="hidden" name="discountGold" value="${nuOffer.discountGold}" />
|
||||
<input type="hidden" name="silver" value="${nuOffer.silver}" />
|
||||
<input type="hidden" name="discountSilver" value="${nuOffer.discountSilver}" />
|
||||
<input type="hidden" name="bronze" value="${nuOffer.bronze}" />
|
||||
<input type="hidden" name="discountBronze" value="${nuOffer.discountBronze}" />
|
||||
|
||||
<button class="btn btn-default" type="submit">Dar de baja</button>
|
||||
<div class="btns-edit">
|
||||
<button type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Dar de baja</button>
|
||||
</div>
|
||||
</form:form>
|
||||
|
||||
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||
<div class="btn-return">
|
||||
<button type="button" role="link" onclick="goBack()" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back()
|
||||
}
|
||||
</script>
|
||||
|
||||
</jsp:body>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(editUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Editar oferta</button>
|
||||
<c:if test="${nuOffer.status eq 'inactive' }">
|
||||
<c:if test="${nuOffer.status eq 'hidden' }">
|
||||
<spring:url value="{nuOfferId}/activate" var="activateUrl">
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
</spring:url>
|
||||
|
@ -84,8 +84,8 @@
|
|||
Desactivar oferta</button>
|
||||
</c:if>
|
||||
</div>
|
||||
</sec:authorize>
|
||||
</div>
|
||||
</sec:authorize>
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back()
|
||||
|
|
|
@ -4,25 +4,32 @@
|
|||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<cheapy:layout pageName="speedOffer">
|
||||
|
||||
<jsp:body>
|
||||
<h2> <20>Est<73> seguro de que quiere dar de baja su oferta? </h2>
|
||||
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>¿Está seguro de que quiere eliminar su oferta?</em></h2>
|
||||
|
||||
<form:form modelAttribute="speedOffer" class="form-horizontal">
|
||||
|
||||
<input type="hidden" name="gold" value="${speedOffer.gold}" />
|
||||
<input type="hidden" name="discountGold" value="${speedOffer.discountGold}" />
|
||||
<input type="hidden" name="silver" value="${speedOffer.silver}" />
|
||||
<input type="hidden" name="discountSilver" value="${speedOffer.discountSilver}" />
|
||||
<input type="hidden" name="bronze" value="${speedOffer.bronze}" />
|
||||
<input type="hidden" name="discountBronze" value="${speedOffer.discountBronze}" />
|
||||
|
||||
<button class="btn btn-default" type="submit">Dar de baja</button>
|
||||
<div class="btns-edit">
|
||||
<button type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Dar de baja</button>
|
||||
</div>
|
||||
</form:form>
|
||||
|
||||
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||
<div class="btn-return">
|
||||
<button type="button" role="link" onclick="goBack()" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back()
|
||||
}
|
||||
</script>
|
||||
|
||||
</jsp:body>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Editar oferta</button>
|
||||
|
||||
<c:if test="${speedOffer.status eq 'inactive' }">
|
||||
<c:if test="${speedOffer.status eq 'hidden' }">
|
||||
<spring:url value="{speedOfferId}/activate" var="activateUrl">
|
||||
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||
</spring:url>
|
||||
|
@ -85,8 +85,9 @@
|
|||
Desactivar oferta</button>
|
||||
</c:if>
|
||||
</div>
|
||||
</sec:authorize>
|
||||
</div>
|
||||
</sec:authorize>
|
||||
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back()
|
||||
|
|
|
@ -4,21 +4,32 @@
|
|||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<petclinic:layout pageName="timeOffer">
|
||||
<cheapy:layout pageName="timeOffer">
|
||||
|
||||
<jsp:body>
|
||||
<h2> <20>Est<73> seguro de que quiere eliminar su oferta? </h2>
|
||||
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>¿Está seguro de que quiere eliminar su oferta?</em></h2>
|
||||
|
||||
<form:form modelAttribute="timeOffer" class="form-horizontal">
|
||||
<input type="hidden" name="init" value="${timeOffer.init}" />
|
||||
<input type="hidden" name="finish" value="${timeOffer.finish}" />
|
||||
<input type="hidden" name="discount" value="${timeOffer.discount}" />
|
||||
|
||||
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
|
||||
<div class="btns-edit">
|
||||
<button type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Dar de baja</button>
|
||||
</div>
|
||||
</form:form>
|
||||
|
||||
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||
<div class="btn-return">
|
||||
<button type="button" role="link" onclick="goBack()" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back()
|
||||
}
|
||||
</script>
|
||||
|
||||
</jsp:body>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Editar oferta</button>
|
||||
|
||||
<c:if test="${timeOffer.status eq 'inactive' }">
|
||||
<c:if test="${timeOffer.status eq 'hidden' }">
|
||||
<spring:url value="{timeOfferId}/activate" var="activateUrl">
|
||||
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
|
||||
</spring:url>
|
||||
|
@ -75,8 +75,9 @@
|
|||
</c:if>
|
||||
|
||||
</div>
|
||||
</sec:authorize>
|
||||
</div>
|
||||
</sec:authorize>
|
||||
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back()
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ 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="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
<cheapy:layout pageName="reviewsN">
|
||||
<h2>
|
||||
<c:if test="${review['new']}">Nueva </c:if> Reseña
|
||||
</h2>
|
||||
<form:form modelAttribute="review" class="form-horizontal" id="add-review-form">
|
||||
<div class="form-group has-feedback">
|
||||
<form:hidden path="id"/>
|
||||
<cheapy:textAreaField label="Opinión" name="opinion"/>
|
||||
<cheapy:inputField label="Estrellas" name="stars"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<c:choose>
|
||||
<c:when test="${review['new']}">
|
||||
<button class="btn btn-default" type="submit">Crear Reseña</button>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<button class="btn btn-default" type="submit">Modificar Reseña</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
</div>
|
||||
</form:form>
|
||||
</cheapy:layout>
|
59
src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp
Normal file
59
src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp
Normal file
|
@ -0,0 +1,59 @@
|
|||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ 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" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="reviews">
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="reviews"/></h2>
|
||||
|
||||
<table id="reviewTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style="width: 150px;">Restaurante</th> -->
|
||||
<th><fmt:message key="user"/></th>
|
||||
<th><fmt:message key="stars"/></th>
|
||||
<th><fmt:message key="opinion"/></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:choose>
|
||||
<c:when test="${fn:length(reviewsLs) == 0}">
|
||||
<tr><td colspan="4"><em><c:out value="No se ha realizado ninguna valoración por el momento."/></em></td></tr>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<c:forEach items="${reviewsLs}" var="review">
|
||||
<tr>
|
||||
<!-- <td> -->
|
||||
<%-- <c:out value="nombre por definir"/> <!-- ${review.usuario.nombre},${review.usuario.apellidos} --> --%>
|
||||
<!-- </td> -->
|
||||
<td>
|
||||
<c:out value="${review.escritor.username}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${review.stars}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${review.opinion}"/>
|
||||
</td>
|
||||
<td>
|
||||
<spring:url value="/reviews/{reviewId}" var="reviewUrl">
|
||||
<spring:param name="reviewId" value="${review.id}"/>
|
||||
</spring:url>
|
||||
<div class="btn-detalles">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(reviewUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="details"/></button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</tbody>
|
||||
</table>
|
||||
</cheapy:layout>
|
51
src/main/webapp/WEB-INF/jsp/reviews/reviewsShow.jsp
Normal file
51
src/main/webapp/WEB-INF/jsp/reviews/reviewsShow.jsp
Normal file
|
@ -0,0 +1,51 @@
|
|||
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ 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="review">
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="review"/></h2>
|
||||
|
||||
|
||||
<table class="table table-striped" id="review-table">
|
||||
<tr>
|
||||
<th><fmt:message key="stars"/></th>
|
||||
<td><c:out value="${review.stars}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="opinion"/></th>
|
||||
<td><c:out value="${review.opinion}"/></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<div class="btn-return">
|
||||
<button type="button" role="link" onclick="goBack()" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
|
||||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
|
||||
<sec:authentication var="principal" property="principal" />
|
||||
<div class="btns-edit">
|
||||
<c:if test="${ principal.username eq review.escritor.username }">
|
||||
<spring:url value="{reviewId}/edit" var="editUrl">
|
||||
<spring:param name="reviewId" value="${review.id}"/>
|
||||
</spring:url>
|
||||
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(editUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Editar opinión</button>
|
||||
</c:if>
|
||||
</div>
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back()
|
||||
}
|
||||
</script>
|
||||
|
||||
</cheapy:layout>
|
|
@ -34,30 +34,30 @@
|
|||
</cheapy:menuItem>
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('client')">
|
||||
<cheapy:menuItem active="${name eq 'ofertass'}" url="/myOffers" title="misOfertas">
|
||||
<span class="glyphicon glyphicon-cutlery" aria-hidden="true"></span>
|
||||
<span>Mis ofertas</span>
|
||||
</cheapy:menuItem>
|
||||
</sec:authorize>
|
||||
|
||||
<sec:authorize access="hasAnyAuthority('usuario')">
|
||||
<cheapy:menuItem active="${name eq 'ofertas'}" url="/myOffers" title="valoranos">
|
||||
<span class="glyphicon glyphicon-star" aria-hidden="true"></span>
|
||||
<span>Valóranos</span>
|
||||
</cheapy:menuItem>
|
||||
<cheapy:menuItem active="${name eq 'ofertasM'}" url="/myOffers" title="misOfertas">
|
||||
<span class="glyphicon glyphicon-cutlery" aria-hidden="true"></span>
|
||||
<span>Mis ofertas</span>
|
||||
</cheapy:menuItem>
|
||||
</sec:authorize>
|
||||
<!--
|
||||
<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�ctanos</span>
|
||||
</cheapy:menuItem>
|
||||
-->
|
||||
|
||||
|
||||
<sec:authorize access="isAuthenticated()">
|
||||
<cheapy:menuItem active="${name eq 'reviews'}" url="/reviews" title="opiniones">
|
||||
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
|
||||
<span>Reseñas</span>
|
||||
</cheapy:menuItem>
|
||||
<cheapy:menuItem active="${name eq 'reviewsN'}" url="/reviews/new" title="valóranos">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
|
||||
<span>Valóranos</span>
|
||||
</cheapy:menuItem>
|
||||
</sec:authorize>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<sec:authorize access="!isAuthenticated()">
|
||||
<li><a href="<c:url value="/login" />">Iniciar sesión</a></li>
|
||||
|
@ -65,7 +65,7 @@
|
|||
</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>
|
||||
<strong><sec:authentication property="name" /></strong> <span
|
||||
class="glyphicon glyphicon-chevron-down"></span>
|
||||
</a>
|
||||
|
@ -110,8 +110,5 @@
|
|||
</sec:authorize>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
|
28
src/main/webapp/WEB-INF/tags/textAreaField.tag
Normal file
28
src/main/webapp/WEB-INF/tags/textAreaField.tag
Normal file
|
@ -0,0 +1,28 @@
|
|||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ attribute name="name" required="true" rtexprvalue="true"
|
||||
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' : '' }"/>
|
||||
<c:set var="valid" value="${not status.error and not empty status.actualValue}"/>
|
||||
<div class="${cssGroup}">
|
||||
<label class="col-sm-2 control-label">${label}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<form:textarea class="form-control" rows = "5" cols = "30" path="${name}"/>
|
||||
<c:if test="${valid}">
|
||||
<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
|
||||
</c:if>
|
||||
<c:if test="${status.error}">
|
||||
<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>
|
||||
<span class="help-inline">${status.errorMessage}</span>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
</spring:bind>
|
|
@ -97,11 +97,11 @@ class NuOfferControllerTest {
|
|||
.with(SecurityMockMvcRequestPostProcessors.csrf())
|
||||
.param("start", "23/12/2021 12:30")
|
||||
.param("end", "23/12/2022 12:30")
|
||||
.param("gold", "5")
|
||||
.param("gold", "15")
|
||||
.param("discountGold", "15")
|
||||
.param("silver", "10")
|
||||
.param("discountSilver", "10")
|
||||
.param("bronze", "15")
|
||||
.param("bronze", "5")
|
||||
.param("discountBronze", "5"))
|
||||
.andExpect(status().is3xxRedirection());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue