From 41bd00d6450ad61cd0c6928dc7cb320c66fee607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D1=81=D0=B8=D0=BD=20=D0=90=D0=BD=D1=82=D0=BE?= =?UTF-8?q?=D0=BD?= Date: Tue, 23 Apr 2019 13:40:11 +0300 Subject: [PATCH 1/3] project dashboard edited --- src/main/java/ru/ulstu/project/model/ProjectDto.java | 11 +++++++++++ .../projects/fragments/projectDashboardFragment.html | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/ulstu/project/model/ProjectDto.java b/src/main/java/ru/ulstu/project/model/ProjectDto.java index 4e03365..a2827ad 100644 --- a/src/main/java/ru/ulstu/project/model/ProjectDto.java +++ b/src/main/java/ru/ulstu/project/model/ProjectDto.java @@ -15,6 +15,7 @@ public class ProjectDto { @NotEmpty private String title; private Project.ProjectStatus status; + private String statusName; private String description; private List deadlines = new ArrayList<>(); private GrantDto grant; @@ -39,6 +40,7 @@ public class ProjectDto { this.id = id; this.title = title; this.status = status; + this.statusName = status.getStatusName(); this.description = description; this.grant = grant; this.repository = repository; @@ -51,6 +53,7 @@ public class ProjectDto { this.id = project.getId(); this.title = project.getTitle(); this.status = project.getStatus(); + this.statusName = project.getStatus().getStatusName(); this.description = project.getDescription(); this.applicationFileName = project.getApplication() == null ? null : project.getApplication().getName(); this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant()); @@ -82,6 +85,14 @@ public class ProjectDto { this.status = status; } + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + public String getDescription() { return description; } diff --git a/src/main/resources/templates/projects/fragments/projectDashboardFragment.html b/src/main/resources/templates/projects/fragments/projectDashboardFragment.html index 1f66c4f..4e6f1e6 100644 --- a/src/main/resources/templates/projects/fragments/projectDashboardFragment.html +++ b/src/main/resources/templates/projects/fragments/projectDashboardFragment.html @@ -11,7 +11,7 @@
title -

status

+

status

From c78ea05255eb3ad5e73a1ff8d38ead001497b99b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D1=81=D0=B8=D0=BD=20=D0=90=D0=BD=D1=82=D0=BE?= =?UTF-8?q?=D0=BD?= Date: Tue, 23 Apr 2019 14:11:42 +0300 Subject: [PATCH 2/3] #114 update edited --- .../project/controller/ProjectController.java | 2 -- .../ru/ulstu/project/service/ProjectService.java | 16 ++++++++++++---- src/main/resources/templates/index.html | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/ru/ulstu/project/controller/ProjectController.java b/src/main/java/ru/ulstu/project/controller/ProjectController.java index 1d0272d..affdaec 100644 --- a/src/main/java/ru/ulstu/project/controller/ProjectController.java +++ b/src/main/java/ru/ulstu/project/controller/ProjectController.java @@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import ru.ulstu.deadline.model.Deadline; -import ru.ulstu.grant.model.GrantDto; import ru.ulstu.project.model.Project; import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.service.ProjectService; @@ -21,7 +20,6 @@ import java.util.List; import java.util.stream.Collectors; import static org.springframework.util.StringUtils.isEmpty; -import static ru.ulstu.core.controller.Navigation.hasErrors; @Controller() @RequestMapping(value = "/projects") diff --git a/src/main/java/ru/ulstu/project/service/ProjectService.java b/src/main/java/ru/ulstu/project/service/ProjectService.java index c15d590..b411c3b 100644 --- a/src/main/java/ru/ulstu/project/service/ProjectService.java +++ b/src/main/java/ru/ulstu/project/service/ProjectService.java @@ -5,6 +5,8 @@ import org.springframework.transaction.annotation.Transactional; import org.thymeleaf.util.StringUtils; import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.file.service.FileService; +import ru.ulstu.grant.model.Grant; +import ru.ulstu.grant.model.GrantDto; import ru.ulstu.grant.repository.GrantRepository; import ru.ulstu.project.model.Project; import ru.ulstu.project.model.ProjectDto; @@ -62,6 +64,16 @@ public class ProjectService { return newProject; } + @Transactional + public Project update(ProjectDto projectDto) throws IOException { + Project project = projectRepository.findOne(projectDto.getId()); + if (projectDto.getApplicationFileName() != null && project.getApplication() != null) { + fileService.deleteFile(project.getApplication()); + } + projectRepository.save(copyFromDto(project, projectDto)); + return project; + } + private Project copyFromDto(Project project, ProjectDto projectDto) throws IOException { project.setDescription(projectDto.getDescription()); project.setStatus(projectDto.getStatus() == null ? APPLICATION : projectDto.getStatus()); @@ -85,10 +97,6 @@ public class ProjectService { } } - private Project update(ProjectDto projectDto) { - throw new RuntimeException("not implemented yet"); - } - public Project findById(Integer id) { return projectRepository.findOne(id); } diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 6bb134e..f821549 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -40,7 +40,7 @@