From e178cd163909119693001cf225a96dc8eee71bc3 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sat, 27 Apr 2019 09:45:47 +0400 Subject: [PATCH] #70 added checking empty fields of deadline, fix bug on EventDto --- .../ulstu/conference/controller/ConferenceController.java | 6 ++++++ src/main/java/ru/ulstu/timeline/model/EventDto.java | 8 ++++++-- src/main/resources/templates/conferences/conference.html | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 4c5ea91..d324eb4 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -78,6 +78,12 @@ public class ConferenceController { @PostMapping(value = "/conference", params = "save") public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { filterEmptyDeadlines(conferenceDto); + for (Deadline deadline : conferenceDto.getDeadlines()) { + if (deadline.getDate() == null || deadline.getDescription().isEmpty()) { + errors.rejectValue("deadlines", "errorCode", "Все поля дедлайна должны быть заполнены"); + return CONFERENCE_PAGE; + } + } if (errors.hasErrors()) { return CONFERENCE_PAGE; } diff --git a/src/main/java/ru/ulstu/timeline/model/EventDto.java b/src/main/java/ru/ulstu/timeline/model/EventDto.java index 1d2a29a..e92d2cb 100644 --- a/src/main/java/ru/ulstu/timeline/model/EventDto.java +++ b/src/main/java/ru/ulstu/timeline/model/EventDto.java @@ -62,9 +62,13 @@ public class EventDto { this.createDate = event.getCreateDate(); this.updateDate = event.getUpdateDate(); this.description = event.getDescription(); - this.paperDto = new PaperDto(event.getPaper()); this.recipients = convert(event.getRecipients(), UserDto::new); - this.conferenceDto = new ConferenceDto(event.getConference()); + if (paperDto != null) { + this.paperDto = new PaperDto(event.getPaper()); + } + if (conferenceDto != null) { + this.conferenceDto = new ConferenceDto(event.getConference()); + } } public Integer getId() { diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 69c754a..d5906b6 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -150,10 +150,10 @@ + Имя статьи -