Skip to content

Commit aa10131

Browse files
committed
fix(app): solve errors
1 parent 79ef045 commit aa10131

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

src/main/java/controllers/admin/PostController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ public String processPost(
109109
RedirectAttributes model) throws IOException, SQLException{
110110

111111
String url = "redirect:/admin/posts/all";
112+
113+
if(post.getImage() == null && postImage != null && postImage.isEmpty()){
114+
bindingResult.rejectValue("image", "post.image.notnull");
115+
}
112116

113117
if (bindingResult.hasErrors()) {
114118
model.addFlashAttribute(BINDING_RESULT_NAME, bindingResult);

src/main/java/models/Post.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class Post implements Serializable {
4949
@Column(nullable = false)
5050
private Date date = new Date();
5151

52+
@NotNull(message="{post.image.notnull}")
5253
@OneToOne(optional = false, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
5354
private FileImage image;
5455

src/main/resources/ValidationMessages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ post.subtitle.notnull = El subt\u00edtulo no puede estar vac\u00edo.
88
post.subtitle.size = El subt\u00edtulo debe tener entre {min} y {max} caracteres de longitud.
99
post.body.notnull = El contenido del art\u00edculo no puede estar vac\u00edo.
1010
post.published.notnull = Debes seleccionar el estado del art\u00edculo.
11+
post.image.notnull = Debes proporcionar una imagen de portada para el art\u00edculo.
1112

1213
user.username.notnull = El nombre de usuario no puede estar vac\u00edo.
1314
user.username.size = El nombre de usuario debe tener entre {min} y {max} caracteres de longitud.

src/main/webapp/WEB-INF/templates/frontend/layout.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
<li sec:authorize="!isAuthenticated()">
5252
<a th:href="@{/admin/login}" th:text="#{frontend.navigation.login}">Login to access admin panel</a>
5353
</li>
54-
<li>
55-
<a href="contact.html">Contact</a>
56-
</li>
5754
</ul>
5855
</div>
5956
<!-- /.navbar-collapse -->

0 commit comments

Comments
 (0)