src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt

changeset 186
05eec764facd
parent 185
5ec9fcfbdf9c
child 191
193ee4828767
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Sun Apr 04 11:52:30 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Sun Apr 04 13:03:41 2021 +0200
@@ -63,9 +63,9 @@
 
         get("/%project/issues/%version/%component/%issue", this::issue)
         get("/%project/issues/%version/%component/%issue/edit", this::issueForm)
-        get("/%project/issues/%version/%component/%issue/comment", this::issueComment)
+        post("/%project/issues/%version/%component/%issue/comment", this::issueComment)
         get("/%project/issues/%version/%component/-/create", this::issueForm)
-        get("/%project/issues/%version/%component/-/commit", this::issueCommit)
+        post("/%project/issues/%version/%component/-/commit", this::issueCommit)
     }
 
     fun projects(http: HttpRequest, dao: DataAccessObject) {
@@ -508,7 +508,7 @@
                         else -> dao.findUser(it)
                     }
                 }
-                eta = http.param("eta")?.let { Date.valueOf(it) }
+                eta = http.param("eta")?.let { if (it.isBlank()) null else Date.valueOf(it) }
 
                 affectedVersions = http.paramArray("affected")
                     .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, projectInfo.project.id) } }
@@ -516,10 +516,17 @@
                     .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, projectInfo.project.id) } }
             }
 
-            if (http.param("more").toBoolean()) {
+            val openId = if (issue.id < 0) {
+                dao.insertIssue(issue)
+            } else {
+                dao.updateIssue(issue)
+                issue.id
+            }
+
+            if (http.param("more") != null) {
                 http.renderCommit("${issuesHref}-/create")
             } else {
-                http.renderCommit("${issuesHref}${issue.id}")
+                http.renderCommit("${issuesHref}${openId}")
             }
         }
     }

mercurial