From 5c459a2d90d410edc133dca7c183e6cbb3a8080c Mon Sep 17 00:00:00 2001 From: Flor Date: Wed, 31 Mar 2021 17:50:27 +0200 Subject: [PATCH 1/8] =?UTF-8?q?Version=201=20de=20rese=C3=B1as.=20falta:?= =?UTF-8?q?=20a=C3=B1adir=20nombre=20del=20usuario=20el=20boton=20de=20edi?= =?UTF-8?q?tar=20no=20aparezca=20en=20todas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springframework/cheapy/model/Review.java | 43 +++++++++ .../cheapy/repository/ReviewRepository.java | 22 +++++ .../cheapy/service/ReviewService.java | 40 ++++++++ .../cheapy/web/ReviewController.java | 92 +++++++++++++++++++ .../resources/messages/messages_es.properties | 6 +- .../WEB-INF/jsp/offers/myOffersList.jsp | 2 +- .../jsp/reviews/createOrUpdateReviewForm.jsp | 33 +++++++ .../WEB-INF/jsp/reviews/reviewsList.jsp | 50 ++++++++++ .../WEB-INF/jsp/reviews/reviewsShow.jsp | 38 ++++++++ src/main/webapp/WEB-INF/tags/menu.tag | 13 ++- 10 files changed, 335 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/springframework/cheapy/model/Review.java create mode 100644 src/main/java/org/springframework/cheapy/repository/ReviewRepository.java create mode 100644 src/main/java/org/springframework/cheapy/service/ReviewService.java create mode 100644 src/main/java/org/springframework/cheapy/web/ReviewController.java create mode 100644 src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp create mode 100644 src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp create mode 100644 src/main/webapp/WEB-INF/jsp/reviews/reviewsShow.jsp diff --git a/src/main/java/org/springframework/cheapy/model/Review.java b/src/main/java/org/springframework/cheapy/model/Review.java new file mode 100644 index 000000000..9bf152071 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/model/Review.java @@ -0,0 +1,43 @@ +package org.springframework.cheapy.model; + +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 + private String opinion; + + @NotNull + @Range(min = 1, max = 5) + private Integer stars; + + + 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; + } + +} diff --git a/src/main/java/org/springframework/cheapy/repository/ReviewRepository.java b/src/main/java/org/springframework/cheapy/repository/ReviewRepository.java new file mode 100644 index 000000000..754e2650f --- /dev/null +++ b/src/main/java/org/springframework/cheapy/repository/ReviewRepository.java @@ -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 { + + @Query("SELECT r FROM Review r") + @Transactional(readOnly = true) + List findAllReviews(); + + void save(Review review); + + @Query("SELECT r FROM Review r WHERE id =:id") + @Transactional(readOnly = true) + Review findReviewById(@Param("id") Integer id); +} diff --git a/src/main/java/org/springframework/cheapy/service/ReviewService.java b/src/main/java/org/springframework/cheapy/service/ReviewService.java new file mode 100644 index 000000000..2b7bc9301 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/service/ReviewService.java @@ -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 findAllReviews() { + return this.reviewRepository.findAllReviews(); + } + + @Transactional + public void saveReview(final Review Review) throws DataAccessException { + this.reviewRepository.save(Review); + } + +} diff --git a/src/main/java/org/springframework/cheapy/web/ReviewController.java b/src/main/java/org/springframework/cheapy/web/ReviewController.java new file mode 100644 index 000000000..d51b851e5 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/web/ReviewController.java @@ -0,0 +1,92 @@ +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.service.ReviewService; +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; + + public ReviewController(final ReviewService reviewService) { + this.reviewService = reviewService; + } + @GetMapping("/reviews") + public String processFindForm( Map model) { + + List reviewsLs=this.reviewService.findAllReviews(); + model.put("reviewsLs", reviewsLs); + + return "reviews/reviewsList"; + + } + + @GetMapping("/reviews/new") + public String initCreationForm(Map 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 { + this.reviewService.saveReview(review); + return "redirect:/reviews/" + review.getId(); + } + } + + + + @GetMapping("/reviews/{reviewId}") + public String processShowForm(@PathVariable("reviewId") int reviewId, Map 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) { + + + 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 (result.hasErrors()) { + model.addAttribute("review", reviewEdit); + return ReviewController.VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM; + + } else { + this.reviewService.saveReview(reviewEdit); + return "redirect:/reviews/" + reviewEdit.getId(); + } + + } + +} diff --git a/src/main/resources/messages/messages_es.properties b/src/main/resources/messages/messages_es.properties index 10a321d09..ccf24729e 100644 --- a/src/main/resources/messages/messages_es.properties +++ b/src/main/resources/messages/messages_es.properties @@ -31,4 +31,8 @@ duplicate=Ya se encuentra en uso 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 \ No newline at end of file +typeMismatch.birthDate=Fecha inválida +review= Reseña +reviews= Reseñas +stars= Estrellas +opinion= Opinión \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/offers/myOffersList.jsp b/src/main/webapp/WEB-INF/jsp/offers/myOffersList.jsp index 201065542..56efb42be 100644 --- a/src/main/webapp/WEB-INF/jsp/offers/myOffersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/offers/myOffersList.jsp @@ -6,7 +6,7 @@ <%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> - +

diff --git a/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp b/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp new file mode 100644 index 000000000..94e5a9e3e --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp @@ -0,0 +1,33 @@ +<%@ 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" %> + + +

+ Nueva Opinión +

+ +
+ + + + +
+
+
+ + + + + + + + +
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp b/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp new file mode 100644 index 000000000..2bd848cd9 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp @@ -0,0 +1,50 @@ +<%@ 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" %> + + + +

+ +
+ + + + + + + + + + + + +<%-- --%> + + + + + + + + +
+ + + + + + + +
+ +
+
+ + +
diff --git a/src/main/webapp/WEB-INF/jsp/reviews/reviewsShow.jsp b/src/main/webapp/WEB-INF/jsp/reviews/reviewsShow.jsp new file mode 100644 index 000000000..e10af0bea --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/reviews/reviewsShow.jsp @@ -0,0 +1,38 @@ +<%@ 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" %> + + + + +

+ + + + + + + + + + + + +
+ +
+ +
+ + + + + Editar opinión + + +
diff --git a/src/main/webapp/WEB-INF/tags/menu.tag b/src/main/webapp/WEB-INF/tags/menu.tag index 10a512467..3a9437e1b 100644 --- a/src/main/webapp/WEB-INF/tags/menu.tag +++ b/src/main/webapp/WEB-INF/tags/menu.tag @@ -35,7 +35,7 @@ - + Mis ofertas @@ -47,7 +47,16 @@ Contáctanos --> - + + + + Opiniones + + + + Valóranos + + From 7070ca6414421ef3f8b5c05c70507305527994fb Mon Sep 17 00:00:00 2001 From: Flor Date: Wed, 31 Mar 2021 19:42:53 +0200 Subject: [PATCH 2/8] =?UTF-8?q?Version=202=20(abrir):=20solo=20puedes=20mo?= =?UTF-8?q?dificar=20tu=20rese=C3=B1a=20aparece=20el=20username=20en=20la?= =?UTF-8?q?=20lista?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springframework/cheapy/model/Review.java | 11 +++++++ .../cheapy/repository/UserRepository.java | 15 +++++++++ .../cheapy/repository/UsuarioRepository.java | 11 ------- .../cheapy/service/UserService.java | 29 +++++++++++++++++ .../cheapy/web/ReviewController.java | 31 +++++++++++++++++-- .../resources/messages/messages_es.properties | 3 +- .../WEB-INF/jsp/reviews/reviewsList.jsp | 4 +++ 7 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 src/main/java/org/springframework/cheapy/repository/UserRepository.java delete mode 100644 src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java create mode 100644 src/main/java/org/springframework/cheapy/service/UserService.java diff --git a/src/main/java/org/springframework/cheapy/model/Review.java b/src/main/java/org/springframework/cheapy/model/Review.java index 9bf152071..b8259eb20 100644 --- a/src/main/java/org/springframework/cheapy/model/Review.java +++ b/src/main/java/org/springframework/cheapy/model/Review.java @@ -23,7 +23,18 @@ public class Review extends BaseEntity{ @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; } diff --git a/src/main/java/org/springframework/cheapy/repository/UserRepository.java b/src/main/java/org/springframework/cheapy/repository/UserRepository.java new file mode 100644 index 000000000..0c29a7bf6 --- /dev/null +++ b/src/main/java/org/springframework/cheapy/repository/UserRepository.java @@ -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 { + + @Query("SELECT u FROM User u WHERE username =:username") + @Transactional(readOnly = true) + User findByUsername(String username); +} diff --git a/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java b/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java deleted file mode 100644 index 1bd7c8ee2..000000000 --- a/src/main/java/org/springframework/cheapy/repository/UsuarioRepository.java +++ /dev/null @@ -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 findByUsername(String currentPrincipalName); - -} diff --git a/src/main/java/org/springframework/cheapy/service/UserService.java b/src/main/java/org/springframework/cheapy/service/UserService.java new file mode 100644 index 000000000..92b896e7f --- /dev/null +++ b/src/main/java/org/springframework/cheapy/service/UserService.java @@ -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); + } + +} diff --git a/src/main/java/org/springframework/cheapy/web/ReviewController.java b/src/main/java/org/springframework/cheapy/web/ReviewController.java index d51b851e5..34ad021a5 100644 --- a/src/main/java/org/springframework/cheapy/web/ReviewController.java +++ b/src/main/java/org/springframework/cheapy/web/ReviewController.java @@ -6,8 +6,11 @@ import java.util.Map; import javax.validation.Valid; +import org.springframework.cheapy.model.Client; 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; @@ -21,9 +24,21 @@ 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) { + 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 model) { @@ -47,6 +62,9 @@ public class ReviewController { 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(); } @@ -68,7 +86,9 @@ public class ReviewController { @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); @@ -77,12 +97,17 @@ public class ReviewController { @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(); } diff --git a/src/main/resources/messages/messages_es.properties b/src/main/resources/messages/messages_es.properties index ccf24729e..6a54b70ec 100644 --- a/src/main/resources/messages/messages_es.properties +++ b/src/main/resources/messages/messages_es.properties @@ -35,4 +35,5 @@ typeMismatch.birthDate=Fecha inválida review= Reseña reviews= Reseñas stars= Estrellas -opinion= Opinión \ No newline at end of file +opinion= Opinión +user = Nombre de usuario \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp b/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp index 2bd848cd9..3f91077ca 100644 --- a/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp +++ b/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp @@ -13,6 +13,7 @@ + @@ -24,6 +25,9 @@ <%-- --%> + + + From d482751b98d65f4059395b756567cb0362104524 Mon Sep 17 00:00:00 2001 From: Martinagr32 Date: Thu, 1 Apr 2021 00:40:42 +0200 Subject: [PATCH 3/8] Little changes --- .../springframework/cheapy/model/Review.java | 2 +- .../cheapy/web/ReviewController.java | 2 -- .../resources/messages/messages_es.properties | 14 +++++------ .../jsp/reviews/createOrUpdateReviewForm.jsp | 3 +-- src/main/webapp/WEB-INF/tags/menu.tag | 25 ++++++++----------- 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/springframework/cheapy/model/Review.java b/src/main/java/org/springframework/cheapy/model/Review.java index b8259eb20..b69a1f179 100644 --- a/src/main/java/org/springframework/cheapy/model/Review.java +++ b/src/main/java/org/springframework/cheapy/model/Review.java @@ -16,7 +16,7 @@ public class Review extends BaseEntity{ private static final long serialVersionUID = 1L; - @NotBlank + @NotBlank(message = "Debe rellenar la valoración de Cheapy") private String opinion; @NotNull diff --git a/src/main/java/org/springframework/cheapy/web/ReviewController.java b/src/main/java/org/springframework/cheapy/web/ReviewController.java index 34ad021a5..1ac9e93d4 100644 --- a/src/main/java/org/springframework/cheapy/web/ReviewController.java +++ b/src/main/java/org/springframework/cheapy/web/ReviewController.java @@ -1,12 +1,10 @@ package org.springframework.cheapy.web; - import java.util.List; import java.util.Map; import javax.validation.Valid; -import org.springframework.cheapy.model.Client; import org.springframework.cheapy.model.Review; import org.springframework.cheapy.model.User; import org.springframework.cheapy.service.ReviewService; diff --git a/src/main/resources/messages/messages_es.properties b/src/main/resources/messages/messages_es.properties index 6a54b70ec..d2c3b9aa6 100644 --- a/src/main/resources/messages/messages_es.properties +++ b/src/main/resources/messages/messages_es.properties @@ -1,9 +1,9 @@ welcome=Bienvenido a listOffers=Ver Ofertas -foodOffers=Ofertas por plato específico -foodOffer=Oferta por plato específico -nuOffers=Ofertas por número de comensales -nuOffer=Oferta por número de comensales +foodOffers=Ofertas por plato espec�fico +foodOffer=Oferta por plato espec�fico +nuOffers=Ofertas por n�mero de comensales +nuOffer=Oferta por n�mero de comensales speedOffers=Ofertas por tiempo empleado en comer speedOffer=Oferta por tiempo empleado en comer timeOffers=Ofertas por franja horaria @@ -32,8 +32,8 @@ 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 -review= Reseña -reviews= Reseñas +review= Reseña +reviews= Reseñas stars= Estrellas -opinion= Opinión +opinion= Opinión user = Nombre de usuario \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp b/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp index 94e5a9e3e..52ca88dcb 100644 --- a/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp @@ -13,9 +13,8 @@
- - +
diff --git a/src/main/webapp/WEB-INF/tags/menu.tag b/src/main/webapp/WEB-INF/tags/menu.tag index c9132fe1e..76de4b87b 100644 --- a/src/main/webapp/WEB-INF/tags/menu.tag +++ b/src/main/webapp/WEB-INF/tags/menu.tag @@ -47,27 +47,25 @@ --> - - - Opiniones - - - - Val�ranos - + + + Opiniones + + + + Valóranos + - -
- - -
From 342a157e692d86a02704957526a5bc36b61cd6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADnAGR?= <56026685+Martinagr32@users.noreply.github.com> Date: Thu, 1 Apr 2021 01:06:19 +0200 Subject: [PATCH 4/8] Update messages_es.properties --- src/main/resources/messages/messages_es.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/messages/messages_es.properties b/src/main/resources/messages/messages_es.properties index d2c3b9aa6..a4d3a0ddf 100644 --- a/src/main/resources/messages/messages_es.properties +++ b/src/main/resources/messages/messages_es.properties @@ -1,9 +1,9 @@ welcome=Bienvenido a listOffers=Ver Ofertas -foodOffers=Ofertas por plato espec�fico -foodOffer=Oferta por plato espec�fico -nuOffers=Ofertas por n�mero de comensales -nuOffer=Oferta por n�mero de comensales +foodOffers=Ofertas por plato específico +foodOffer=Oferta por plato específico +nuOffers=Ofertas por número de comensales +nuOffer=Oferta por número de comensales speedOffers=Ofertas por tiempo empleado en comer speedOffer=Oferta por tiempo empleado en comer timeOffers=Ofertas por franja horaria @@ -36,4 +36,4 @@ review= Reseña reviews= Reseñas stars= Estrellas opinion= Opinión -user = Nombre de usuario \ No newline at end of file +user = Nombre de usuario From e5340de5aadde66958588c70ddec47a98cd8d1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADnAGR?= <56026685+Martinagr32@users.noreply.github.com> Date: Thu, 1 Apr 2021 01:07:02 +0200 Subject: [PATCH 5/8] Update application.properties --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c93d5eac7..97ef60ff4 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -16,7 +16,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/ @@ -33,4 +33,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 \ No newline at end of file +spring.resources.cache.cachecontrol.max-age=12h From d26a7582e5d0193c4d161f446bcb3437874e659f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADnAGR?= <56026685+Martinagr32@users.noreply.github.com> Date: Thu, 1 Apr 2021 01:43:52 +0200 Subject: [PATCH 6/8] Reviews and login/logout security fixed --- .../cheapy/configuration/SecurityConfiguration.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java index 7189740f2..d9c57cdce 100644 --- a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java +++ b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java @@ -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") @@ -50,11 +50,12 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .antMatchers("/clients/new").permitAll() .antMatchers("/offers/**").permitAll() + .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 From dcfb78ec2ae6081efce3d6a86e2e74f986a3c283 Mon Sep 17 00:00:00 2001 From: Flor Date: Thu, 1 Apr 2021 14:13:11 +0200 Subject: [PATCH 7/8] =?UTF-8?q?Renombrado=20opini=C3=B3n=20por=20rese?= =?UTF-8?q?=C3=B1a=20en=20jsp=20y=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp | 6 +++--- src/main/webapp/WEB-INF/tags/menu.tag | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp b/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp index 52ca88dcb..a413cb8e5 100644 --- a/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp @@ -8,7 +8,7 @@

- Nueva Opinión + Nueva Reseña

@@ -20,10 +20,10 @@
- + - +
diff --git a/src/main/webapp/WEB-INF/tags/menu.tag b/src/main/webapp/WEB-INF/tags/menu.tag index 76de4b87b..40f426e7e 100644 --- a/src/main/webapp/WEB-INF/tags/menu.tag +++ b/src/main/webapp/WEB-INF/tags/menu.tag @@ -49,7 +49,7 @@ - Opiniones + Reseñas From 1bc2941f60123ba5a895fad216e369703ac71aa1 Mon Sep 17 00:00:00 2001 From: Martinagr32 Date: Sat, 3 Apr 2021 00:27:18 +0200 Subject: [PATCH 8/8] Review textArea and length fixed and improved --- .../springframework/cheapy/model/Review.java | 2 + .../jsp/reviews/createOrUpdateReviewForm.jsp | 2 +- .../WEB-INF/jsp/reviews/reviewsList.jsp | 77 ++++++++++--------- .../webapp/WEB-INF/tags/textAreaField.tag | 28 +++++++ 4 files changed, 72 insertions(+), 37 deletions(-) create mode 100644 src/main/webapp/WEB-INF/tags/textAreaField.tag diff --git a/src/main/java/org/springframework/cheapy/model/Review.java b/src/main/java/org/springframework/cheapy/model/Review.java index b69a1f179..b8cf0b6d4 100644 --- a/src/main/java/org/springframework/cheapy/model/Review.java +++ b/src/main/java/org/springframework/cheapy/model/Review.java @@ -1,5 +1,6 @@ package org.springframework.cheapy.model; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; @@ -17,6 +18,7 @@ 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 diff --git a/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp b/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp index a413cb8e5..5c8c53660 100644 --- a/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/reviews/createOrUpdateReviewForm.jsp @@ -13,7 +13,7 @@
- +
diff --git a/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp b/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp index 3f91077ca..f09f9dfd9 100644 --- a/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp +++ b/src/main/webapp/WEB-INF/jsp/reviews/reviewsList.jsp @@ -11,44 +11,49 @@ - - - - - - - + + + + + + + - - - -<%-- --%> - - - - - - - - + + + + + + + + + <%-- --%> + + + + + + + + + +
- - - - - - - - - -
- -
-
+ + + + + + + + + +
+ +
+
- - diff --git a/src/main/webapp/WEB-INF/tags/textAreaField.tag b/src/main/webapp/WEB-INF/tags/textAreaField.tag new file mode 100644 index 000000000..37d94fbde --- /dev/null +++ b/src/main/webapp/WEB-INF/tags/textAreaField.tag @@ -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" %> + + + + +
+ + +
+ + + + + + + ${status.errorMessage} + +
+
+