fixes project creation not working

Sat, 05 Jun 2021 09:04:13 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 05 Jun 2021 09:04:13 +0200
changeset 200
a5ddfaf6b469
parent 199
59393c8cc557
child 201
73c632c1c7e5

fixes project creation not working

src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt file | annotate | diff | comparison | revisions
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Sat May 15 16:19:29 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Sat Jun 05 09:04:13 2021 +0200
@@ -210,21 +210,23 @@
     }
 
     private fun projectForm(http: HttpRequest, dao: DataAccessObject) {
-        val projectInfo = obtainProjectInfo(http, dao)
-        if (projectInfo == null) {
-            http.response.sendError(404)
-            return
-        }
-
-        with(http) {
-            view = ProjectEditView(projectInfo.project, dao.listUsers())
-            navigationMenu = activeProjectNavMenu(
+        if (!http.pathParams.containsKey("project")) {
+            http.view = ProjectEditView(Project(-1), dao.listUsers())
+            http.navigationMenu = projectNavMenu(dao.listProjects())
+        } else {
+            val projectInfo = obtainProjectInfo(http, dao)
+            if (projectInfo == null) {
+                http.response.sendError(404)
+                return
+            }
+            http.view = ProjectEditView(projectInfo.project, dao.listUsers())
+            http.navigationMenu = activeProjectNavMenu(
                 dao.listProjects(),
                 projectInfo
             )
-            styleSheets = listOf("projects")
-            render("project-form")
         }
+        http.styleSheets = listOf("projects")
+        http.render("project-form")
     }
 
     private fun projectCommit(http: HttpRequest, dao: DataAccessObject) {

mercurial