diff --git a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java index 7189740f2..e2c866bb3 100644 --- a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java +++ b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java @@ -44,11 +44,14 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .antMatchers("/owners/**").hasAnyAuthority("owner", "admin") + .antMatchers("/offers/**/edit").hasAnyAuthority("admin", "client") .antMatchers("/offers/**/new").hasAnyAuthority("admin", "client") .antMatchers("/offers/**/activate").hasAnyAuthority("admin","client") - + .antMatchers("/clients/new").permitAll() - .antMatchers("/offers/**").permitAll() + .antMatchers("/offers").permitAll() + .antMatchers("/offersCreate").hasAuthority("client") + .and().formLogin() @@ -69,7 +72,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { public void configure(final AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().dataSource(this.dataSource) //[login de admin,owner y vet] .usersByUsernameQuery("select username,password,enabled " + "from users " + "where username = ?") - .usersByUsernameQuery("select username, password, enabled from users where username=?").authoritiesByUsernameQuery("select username, authority " + "from authorities " + "where username = ?") + .usersByUsernameQuery("select username, password, enabled from users where username=?").authoritiesByUsernameQuery("select username, authority " + "from authorities " + "where username = ?") .passwordEncoder(this.passwordEncoder()); } diff --git a/src/main/java/org/springframework/cheapy/web/OfertaController.java b/src/main/java/org/springframework/cheapy/web/OfertaController.java index 73b3553cd..2ae80261c 100644 --- a/src/main/java/org/springframework/cheapy/web/OfertaController.java +++ b/src/main/java/org/springframework/cheapy/web/OfertaController.java @@ -13,16 +13,19 @@ import org.springframework.cheapy.service.FoodOfferService; import org.springframework.cheapy.service.NuOfferService; import org.springframework.cheapy.service.SpeedOfferService; import org.springframework.cheapy.service.TimeOfferService; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @Controller public class OfertaController { - + private final ClientService clientService; - + private final FoodOfferService foodOfferService; - private final NuOfferService nuOfferService; + private final NuOfferService nuOfferService; private final SpeedOfferService speedOfferService; private final TimeOfferService timeOfferService; @@ -42,40 +45,49 @@ public class OfertaController { List nuOfferLs=this.nuOfferService.findActiveNuOffer(); List speedOfferLs=this.speedOfferService.findActiveSpeedOffer(); List timeOfferLs=this.timeOfferService.findActiveTimeOffer(); - + model.put("foodOfferLs", foodOfferLs); model.put("nuOfferLs", nuOfferLs); model.put("speedOfferLs", speedOfferLs); model.put("timeOfferLs", timeOfferLs); - - //Se añade formateador de fecha al modelo + + //Se añade formateador de fecha al modelo model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); - + return "offers/offersList"; } - + + @GetMapping("/myOffers") public String processMyOffersForm( Map model) { - + int actual = this.clientService.getCurrentClient().getId(); - + List foodOfferLs = this.foodOfferService.findFoodOfferByUserId(actual); List nuOfferLs = this.nuOfferService.findNuOfferByUserId(actual); List speedOfferLs = this.speedOfferService.findSpeedOfferByUserId(actual); List timeOfferLs = this.timeOfferService.findTimeOfferByUserId(actual); - + model.put("foodOfferLs", foodOfferLs); model.put("nuOfferLs", nuOfferLs); model.put("speedOfferLs", speedOfferLs); model.put("timeOfferLs", timeOfferLs); - - //Se añade formateador de fecha al modelo - model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); - - return "offers/myOffersList"; - } + //Se añade formateador de fecha al modelo + model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")); + + return "offers/myOffersList"; + } + + @GetMapping("/offersCreate") + public String createOffers() { + + return "offers/offersCreate"; + } + + + // @GetMapping("/owners/{ownerId}/edit") // public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) { // Owner owner = this.ownerService.findOwnerById(ownerId); @@ -99,10 +111,10 @@ public class OfertaController { // public ModelAndView showOwner(@PathVariable("ownerId") int ownerId) { // ModelAndView mav = new ModelAndView("owners/ownerDetails"); // Owner owner = this.ownerService.findOwnerById(ownerId); -// +// // mav.addObject(owner); // return mav; // } - - + + } diff --git a/src/main/less/cheapy.less b/src/main/less/cheapy.less index 2ad446686..a0bff3551 100644 --- a/src/main/less/cheapy.less +++ b/src/main/less/cheapy.less @@ -56,7 +56,7 @@ .table-filter { background-color: @spring-brown; - padding: 9px 12px; + padding: 5px 12px; } .nav > li > a { @@ -240,20 +240,81 @@ img.img-responsive{ background-color: rgb(40, 140, 215); } +.btn-home{ + display: table; + margin: 0 auto; +} + +.btn-create button { + background-color: rgb(40, 140, 215); + border: 1px solid rgb(0, 0, 160); + color: white; + padding: 10px 24px; + cursor: pointer; + width: 70%; + display: block; + +} + +.btn-create button:not(:last-child) { + border-bottom: none; +} + + +.btn-create button:hover { + background-color: rgb(0, 64, 128) +} + +.btn-create-max button { + padding: 20px; + margin-left:auto; + margin-right: auto; + margin-bottom: 20px; +} + +.btn-mod{ + display: table; + margin: 0 auto; + float:left; +} + +.btn-mod button { + background-color: rgb(0, 64, 128); + border: 1px solid rgb(0, 0, 160); + color: white; + padding: 10px 24px; + cursor: pointer; + display: block; +} + +.btn-mod button:not(:last-child) { + border-bottom: none; +} + + +.btn-mod button:hover { + background-color: rgb(40, 140, 215); +} + #foodOfferTable th { width: 25%; + text-align: center; + } #nuOfferTable th { - width: 33%; + width: 25%; +text-align: center; } #speedOfferTable th { - width: 33%; + width: 25%; +text-align: center; } #timeOfferTable th { - width: 33%; + width: 25%; +text-align: center; } .btn-detalles button { @@ -278,7 +339,52 @@ img.img-responsive{ .btn-return{ display: table; margin: 0 auto; - width: 100%; + float:left; +} + +.btns-edit{ + display: table; + margin: 0 auto; + float:right; +} + +.btns-edit button{ + background-color: rgb(0, 64, 128); + border: 1px solid rgb(0, 0, 160); + color: white; + padding: 10px 24px; + cursor: pointer; +} + +.btns-edit button:not(:last-child) { + border-bottom: none; +} + + +.btns-edit button:hover { + background-color: rgb(40, 140, 215); +} + +.btns-delete{ + display: table; + margin: 0 auto; + float:left; +} + +.btns-delete button{ + background-color: rgb(0, 64, 128); + border: 1px solid rgb(0, 0, 160); + color: white; + padding: 10px 24px; + cursor: pointer; +} + +.btns-delete button:not(:last-child) { + border-bottom: none; +} + +.btns-delete button:hover { + background-color: rgb(40, 140, 215); } .btn-return button { @@ -288,32 +394,50 @@ img.img-responsive{ padding: 10px 24px; cursor: pointer; display: block; - left: 0%; } .btn-return button:not(:last-child) { border-bottom: none; } - .btn-return button:hover { background-color: rgb(40, 140, 215); } #foodOfferTable td{ vertical-align:middle; +text-align: center; } #nuOfferTable td{ vertical-align:middle; +text-align: center; } #speedOfferTable td{ vertical-align:middle; +text-align: center; } #timeOfferTable td{ vertical-align:middle; +text-align: center; +} + +#nuOffer-table th{ + text-align: center; +} + +#nuOffer-table td{ + text-align: center; +} + +#speedOffer-table th{ + text-align: center; +} + +#speedOffer-table td{ + text-align: center; } #nuOffer-table tr:nth-child(3){ @@ -364,6 +488,13 @@ img.img-responsive{ background-color: rgb(204, 128, 51); } +#vacio { + text-align:center; + font-size: 120%; + padding:10px; + color: rgb(29, 142, 226); +} + .alert-success { .alert-variant(fade(@alert-success-bg, 70%); @alert-success-border; @alert-success-text); } diff --git a/src/main/resources/messages/messages_es.properties b/src/main/resources/messages/messages_es.properties index 10a321d09..dc3680cfd 100644 --- a/src/main/resources/messages/messages_es.properties +++ b/src/main/resources/messages/messages_es.properties @@ -1,5 +1,10 @@ welcome=Bienvenido a +new=Nueva +deleteOffer=Eliminar Oferta +cancel=Cancelar +deleteOfferMessage=Confirme que quiere eliminar su oferta listOffers=Ver Ofertas +createOffers=Crear Ofertas foodOffers=Ofertas por plato específico foodOffer=Oferta por plato específico nuOffers=Ofertas por número de comensales @@ -31,4 +36,10 @@ 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 +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 +finish= Fin del intervalo diff --git a/src/main/webapp/WEB-INF/jsp/login.jsp b/src/main/webapp/WEB-INF/jsp/login.jsp index d48b3e296..7c1b61609 100644 --- a/src/main/webapp/WEB-INF/jsp/login.jsp +++ b/src/main/webapp/WEB-INF/jsp/login.jsp @@ -1,6 +1,8 @@ <%@ 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" %> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> @@ -275,25 +277,29 @@
- +
+ +

El usuario y/o la contraseña son incorrectos

+ +
-

Nombre de usuario o contraseña inválido

+

Nombre de usuario o contraseña inválido

diff --git a/src/main/webapp/WEB-INF/tags/inputField.tag b/src/main/webapp/WEB-INF/tags/inputField.tag index 8983bd5f7..72de53f0b 100644 --- a/src/main/webapp/WEB-INF/tags/inputField.tag +++ b/src/main/webapp/WEB-INF/tags/inputField.tag @@ -6,16 +6,16 @@ <%@ 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" %> + description="Placeholder para los campos en los input fields" %>
- +
- +