From 689a7799e3803f5bc4f21a3584c39beaee4de2b2 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 8 Apr 2019 22:04:30 +0400 Subject: [PATCH] #55 added method in controller --- .../conference/controller/ConferenceController.java | 9 +++++++++ src/main/resources/templates/conferences/conference.html | 2 +- .../conferences/fragments/confNavigationFragment.html | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 528975c..1de420b 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam; import ru.ulstu.conference.model.ConferenceDto; import ru.ulstu.conference.model.ConferenceFilterDto; import ru.ulstu.conference.service.ConferenceService; +import ru.ulstu.deadline.model.Deadline; import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; @@ -61,6 +62,14 @@ public class ConferenceController { } + @PostMapping(value = "/conference", params = "addDeadline") + public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) { + filterEmptyDeadlines(conferenceDto); + hasErrors(errors, CONFERENCE_PAGE); + conferenceDto.getDeadlines().add(new Deadline()); + return CONFERENCE_PAGE; + } + private void filterEmptyDeadlines(ConferenceDto conferenceDto) { conferenceDto.setDeadlines(conferenceDto.getDeadlines().stream() .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 3330bed..3917128 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -68,7 +68,7 @@ class="alert alert-danger">Incorrect title

-
diff --git a/src/main/resources/templates/conferences/fragments/confNavigationFragment.html b/src/main/resources/templates/conferences/fragments/confNavigationFragment.html index 31cc00f..45a945e 100644 --- a/src/main/resources/templates/conferences/fragments/confNavigationFragment.html +++ b/src/main/resources/templates/conferences/fragments/confNavigationFragment.html @@ -21,7 +21,7 @@
- Добавить конференцию + Новая конференцию