From 3078114acdb4468cd561204a2b05a554ca8d2dc5 Mon Sep 17 00:00:00 2001 From: Julien DAUPHANT <1238254+jdauphant@users.noreply.github.com> Date: Tue, 23 Mar 2021 19:12:08 +0100 Subject: [PATCH 01/21] =?UTF-8?q?Mise=20=C3=A0=20jour=20sentry=20=C3=A0=20?= =?UTF-8?q?la=20derni=C3=A8re=20version=20pour=20passage=20=C3=A0=20Sentry?= =?UTF-8?q?.io=20(#973)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .scala-steward.conf | 1 - build.sbt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.scala-steward.conf b/.scala-steward.conf index 7ba62d410..d5d4ebec9 100644 --- a/.scala-steward.conf +++ b/.scala-steward.conf @@ -1,2 +1 @@ -updates.ignore = [ { groupId = "io.sentry", artifactId = "sentry-logback" } ] updates.pin = [ { groupId = "com.fasterxml.jackson.core", artifactId = "jackson-databind", version="x.y." } ] diff --git a/build.sbt b/build.sbt index e2d1723aa..397fa61c6 100644 --- a/build.sbt +++ b/build.sbt @@ -112,7 +112,7 @@ libraryDependencies ++= Seq( "org.webjars.npm" % "xlsx" % "0.16.9" ) // Crash -libraryDependencies += "io.sentry" % "sentry-logback" % "1.7.30" +libraryDependencies += "io.sentry" % "sentry-logback" % "4.3.0" // Adds additional packages into Twirl TwirlKeys.templateImports += "constants.Constants" From 1962bffeb4df5dff58e04411c8845e9c792198c3 Mon Sep 17 00:00:00 2001 From: niladic Date: Tue, 23 Mar 2021 19:13:02 +0100 Subject: [PATCH 02/21] =?UTF-8?q?R=C3=A9pare=20l=E2=80=99erreur=20d?= =?UTF-8?q?=E2=80=99export=20des=20demandes=20en=20CSV=20(#975)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/UserGroupService.scala | 6 ++++-- app/services/UserService.scala | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/services/UserGroupService.scala b/app/services/UserGroupService.scala index a999ea8a3..1ef6cd0d2 100644 --- a/app/services/UserGroupService.scala +++ b/app/services/UserGroupService.scala @@ -101,7 +101,8 @@ class UserGroupService @Inject() ( def byIds(groupIds: List[UUID]): List[UserGroup] = db.withConnection { implicit connection => - SQL"SELECT * FROM user_group WHERE ARRAY[$groupIds]::uuid[] @> ARRAY[id]::uuid[]".as( + val ids = groupIds.distinct + SQL"SELECT * FROM user_group WHERE ARRAY[$ids]::uuid[] @> ARRAY[id]::uuid[]".as( simpleUserGroup.* ) } @@ -109,7 +110,8 @@ class UserGroupService @Inject() ( def byIdsFuture(groupIds: List[UUID]): Future[List[UserGroup]] = Future { db.withConnection { implicit connection => - SQL"SELECT * FROM user_group WHERE ARRAY[$groupIds]::uuid[] @> ARRAY[id]::uuid[]".as( + val ids = groupIds.distinct + SQL"SELECT * FROM user_group WHERE ARRAY[$ids]::uuid[] @> ARRAY[id]::uuid[]".as( simpleUserGroup.* ) } diff --git a/app/services/UserService.scala b/app/services/UserService.scala index 61c4c3f02..5fb384a6c 100644 --- a/app/services/UserService.scala +++ b/app/services/UserService.scala @@ -123,8 +123,9 @@ class UserService @Inject() ( results.headOption } - def byIds(ids: List[UUID], includeDisabled: Boolean = false): List[User] = + def byIds(userIds: List[UUID], includeDisabled: Boolean = false): List[User] = db.withConnection { implicit connection => + val ids = userIds.distinct val disabledSQL: String = if (includeDisabled) { "" } else { From fde30d97b9ab18295ec50a25f7924343683e862b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Mar 2021 09:38:34 +0100 Subject: [PATCH 03/21] Bump webpack-cli from 4.3.1 to 4.5.0 (#945) Bumps [webpack-cli](https://github.com/webpack/webpack-cli) from 4.3.1 to 4.5.0. - [Release notes](https://github.com/webpack/webpack-cli/releases) - [Changelog](https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md) - [Commits](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.3.1...webpack-cli@4.5.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eda9f3c49..843db488f 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "ts-loader": "8.0.14", "typescript": "4.1.3", "webpack": "5.21.2", - "webpack-cli": "4.3.1", + "webpack-cli": "4.5.0", "webpack-merge": "5.7.3" } } From c7fa7251533ea50894729815eab07090f01236a3 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Wed, 24 Mar 2021 09:48:43 +0100 Subject: [PATCH 04/21] Update postgresql to 42.2.19 (#955) --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 397fa61c6..125f2ab2f 100644 --- a/build.sbt +++ b/build.sbt @@ -79,7 +79,7 @@ libraryDependencies += specs2 % Test libraryDependencies += guice libraryDependencies ++= Seq( - "org.postgresql" % "postgresql" % "42.2.18", + "org.postgresql" % "postgresql" % "42.2.19", "org.playframework.anorm" %% "anorm" % "2.6.9", "com.typesafe.play" %% "play-mailer" % "8.0.1", "com.sun.mail" % "javax.mail" % "1.6.2", From 787def3616e55ce626f3ca16741b1b2862c1755b Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Wed, 24 Mar 2021 09:49:54 +0100 Subject: [PATCH 05/21] Update sbt-scalafix to 0.9.26 (#960) --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index cbc2e6222..473c90236 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -15,4 +15,4 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") // Makes available sbt commands results to project scala code addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.25") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.26") From 7d7adc97f2e46d98455459233aca12a5699ef62a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Mar 2021 09:50:21 +0100 Subject: [PATCH 06/21] Bump webpack from 5.21.2 to 5.27.2 (#976) Bumps [webpack](https://github.com/webpack/webpack) from 5.21.2 to 5.27.2. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.21.2...v5.27.2) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 843db488f..c86970401 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "rimraf": "3.0.2", "ts-loader": "8.0.14", "typescript": "4.1.3", - "webpack": "5.21.2", + "webpack": "5.27.2", "webpack-cli": "4.5.0", "webpack-merge": "5.7.3" } From ae6f9cbdfd1b8d079f530e193c28622e29e30c65 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Wed, 24 Mar 2021 10:37:46 +0100 Subject: [PATCH 07/21] Update sbt to 1.4.9 (#969) --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 0b2e09c5a..dbae93bcf 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.7 +sbt.version=1.4.9 From 3b0c070f2098dfed2d88c9d35cfe1811646a3458 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Mar 2021 10:51:24 +0100 Subject: [PATCH 08/21] Bump typescript from 4.1.3 to 4.2.3 (#968) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.1.3 to 4.2.3. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.1.3...v4.2.3) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c86970401..9f99667f4 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@types/tabulator-tables": "4.8.0", "rimraf": "3.0.2", "ts-loader": "8.0.14", - "typescript": "4.1.3", + "typescript": "4.2.3", "webpack": "5.27.2", "webpack-cli": "4.5.0", "webpack-merge": "5.7.3" From beedfb6d17d093046d3563f5d0e120a30732084f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Mar 2021 10:52:48 +0100 Subject: [PATCH 09/21] Bump actions/setup-node from v2.1.4 to v2.1.5 (#963) Bumps [actions/setup-node](https://github.com/actions/setup-node) from v2.1.4 to v2.1.5. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v2.1.4...46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f94fc9035..7bd6b09b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Node 10 - uses: actions/setup-node@v2.1.4 + uses: actions/setup-node@v2.1.5 with: node-version: '10.x' - name: Install npm dependencies From e73404237864ee1500362fefaf814a4886d1cf86 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Wed, 24 Mar 2021 10:58:30 +0100 Subject: [PATCH 10/21] Update scala-csv to 1.3.7 (#959) --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 125f2ab2f..989299c65 100644 --- a/build.sbt +++ b/build.sbt @@ -86,7 +86,7 @@ libraryDependencies ++= Seq( "com.typesafe.play" %% "play-mailer-guice" % "8.0.1", "net.jcazevedo" %% "moultingyaml" % "0.4.2", "com.google.guava" % "guava" % "28.1-jre", - "com.github.tototoshi" %% "scala-csv" % "1.3.6", + "com.github.tototoshi" %% "scala-csv" % "1.3.7", ws, "com.lihaoyi" %% "scalatags" % "0.9.3", "org.typelevel" %% "cats-core" % "2.4.2", From 1c1ed74fe3b65c1fc0a1ca3040f3bf505e522906 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Mar 2021 11:17:14 +0100 Subject: [PATCH 11/21] Bump ts-loader from 8.0.14 to 8.0.18 (#970) Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 8.0.14 to 8.0.18. - [Release notes](https://github.com/TypeStrong/ts-loader/releases) - [Changelog](https://github.com/TypeStrong/ts-loader/blob/master/CHANGELOG.md) - [Commits](https://github.com/TypeStrong/ts-loader/compare/v8.0.14...v8.0.18) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f99667f4..b052f9b73 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "@types/tabulator-tables": "4.8.0", "rimraf": "3.0.2", - "ts-loader": "8.0.14", + "ts-loader": "8.0.18", "typescript": "4.2.3", "webpack": "5.27.2", "webpack-cli": "4.5.0", From 6b83818ef888f1bbb3f04f6b592dfc5c782d65e6 Mon Sep 17 00:00:00 2001 From: niladic Date: Wed, 24 Mar 2021 11:21:36 +0100 Subject: [PATCH 12/21] Update .scala-steward.conf (#977) --- .scala-steward.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/.scala-steward.conf b/.scala-steward.conf index d5d4ebec9..1c237bf69 100644 --- a/.scala-steward.conf +++ b/.scala-steward.conf @@ -1 +1,2 @@ +updatePullRequests = "always" updates.pin = [ { groupId = "com.fasterxml.jackson.core", artifactId = "jackson-databind", version="x.y." } ] From 868385b3c9b2f5ff23266b0fd3c5ce3e2a841254 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Wed, 24 Mar 2021 11:51:06 +0100 Subject: [PATCH 13/21] Update anorm to 2.6.10 (#965) --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 989299c65..28b116547 100644 --- a/build.sbt +++ b/build.sbt @@ -80,7 +80,7 @@ libraryDependencies += guice libraryDependencies ++= Seq( "org.postgresql" % "postgresql" % "42.2.19", - "org.playframework.anorm" %% "anorm" % "2.6.9", + "org.playframework.anorm" %% "anorm" % "2.6.10", "com.typesafe.play" %% "play-mailer" % "8.0.1", "com.sun.mail" % "javax.mail" % "1.6.2", "com.typesafe.play" %% "play-mailer-guice" % "8.0.1", From 10da374e707e43d68aacd33865fcb708326af56b Mon Sep 17 00:00:00 2001 From: niladic Date: Wed, 24 Mar 2021 11:56:51 +0100 Subject: [PATCH 14/21] Update vers scala 2.13.5 (#978) --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 28b116547..407d6cb32 100644 --- a/build.sbt +++ b/build.sbt @@ -16,7 +16,7 @@ lazy val root = (project in file(".")) inThisBuild( List( - scalaVersion := "2.13.3", + scalaVersion := "2.13.5", semanticdbEnabled := true, // enable SemanticDB semanticdbVersion := scalafixSemanticdb.revision // use Scalafix compatible version ) From 4ee6890b68fa9ddf19fc064671d9029c55bda5eb Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Wed, 24 Mar 2021 16:02:12 +0100 Subject: [PATCH 15/21] Update material-design-icons to 4.0.0 (#943) --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 407d6cb32..4433571a2 100644 --- a/build.sbt +++ b/build.sbt @@ -101,7 +101,7 @@ libraryDependencies ++= Seq( libraryDependencies ++= Seq( "org.webjars" %% "webjars-play" % "2.8.0-1", "org.webjars.bower" % "material-design-lite" % "1.3.0", - "org.webjars" % "material-design-icons" % "3.0.1", + "org.webjars" % "material-design-icons" % "4.0.0", "org.webjars.npm" % "roboto-fontface" % "0.10.0", "org.webjars.npm" % "slim-select" % "1.24.0", "org.webjars.npm" % "dialog-polyfill" % "0.4.10", From 9027b2f0f660c9699068bda01f513f2fe0388226 Mon Sep 17 00:00:00 2001 From: niladic Date: Thu, 25 Mar 2021 15:35:06 +0100 Subject: [PATCH 16/21] Ajoute l'organisme Association (#979) --- app/models/Organisation.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/Organisation.scala b/app/models/Organisation.scala index 9e32f0fb1..2ceed1c24 100644 --- a/app/models/Organisation.scala +++ b/app/models/Organisation.scala @@ -52,6 +52,7 @@ object Organisation { def byId(id: Id): Option[Organisation] = all.find(org => org.id === id) + val association = Organisation("Association", "Association") val cafId = Organisation.Id("CAF") val caf = Organisation(cafId, "CAF", "Caisse d’allocations familiale") val cpamId = Organisation.Id("CPAM") @@ -73,6 +74,7 @@ object Organisation { val all = List( Organisation("ANAH", "Agence nationale de l'habitat"), Organisation("ANTS", "Agence nationale des titres sécurisés"), + association, Organisation("BDF", "Banque de France"), caf, //Département Organisation("CARSAT", "Caisse d'assurance retraite et de la santé au travail"), // @@ -103,7 +105,7 @@ object Organisation { ) ) - val organismesAidants: List[Organisation] = List(franceServices, msap, hopital) + val organismesAidants: List[Organisation] = List(association, franceServices, msap, hopital) val organismesOperateurs: List[Organisation] = all.filter(!organismesAidants.contains[Organisation](_)) From 5c5134e0569bd52acc0cb252fc4f223811636b63 Mon Sep 17 00:00:00 2001 From: niladic Date: Thu, 25 Mar 2021 15:35:51 +0100 Subject: [PATCH 17/21] Ajoute la BAL dans la liste des utilisateurs (#980) --- app/views/allUsersNew.scala.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/allUsersNew.scala.html b/app/views/allUsersNew.scala.html index eba1877fa..dc55d975c 100644 --- a/app/views/allUsersNew.scala.html +++ b/app/views/allUsersNew.scala.html @@ -1,4 +1,5 @@ @import models._ +@import cats.implicits.catsSyntaxEq @(currentUser: User, currentUserRights: Authorization.UserRights)(userGroups: List[UserGroup], allUsers: List[User], selectedArea: Area)(implicit webJarsUtil: org.webjars.play.WebJarsUtil, flash: Flash, request: RequestHeader) @@ -57,10 +58,15 @@ } ], groups: [ - @for(group <- user.groupIds.flatMap( groupId => userGroups.find( _.id == groupId ) ).map(_.name)){ + @for(group <- user.groupIds.flatMap( groupId => userGroups.find( _.id === groupId ) ).map(_.name)){ "@group", } ], + groupEmails: [ + @for(email <- user.groupIds.flatMap( groupId => userGroups.find( _.id === groupId ) ).flatMap(_.email)){ + "@email", + } + ], groupAdmin: @user.groupAdmin, admin: @user.admin, expert: @user.expert, @@ -199,6 +205,7 @@ headerVertical: verticalHeader, bottomCalc: "count" }, + { title: "BALs", field: "groupEmails", headerFilter: "input" }, { title: "Départements", field: "areas", headerFilter: "input" }, ] }); From b85b355a5444f7da61a4ced69a4248e93efde40a Mon Sep 17 00:00:00 2001 From: niladic Date: Thu, 25 Mar 2021 15:36:39 +0100 Subject: [PATCH 18/21] =?UTF-8?q?Les=20noms=20de=20groupes=20peuvent=20fai?= =?UTF-8?q?re=20jusqu=E2=80=99=C3=A0=20100=20caract=C3=A8res=20(#981)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/CSVImportController.scala | 2 +- app/controllers/GroupController.scala | 2 +- app/models/UserGroup.scala | 6 ++++++ app/views/allUsersNew.scala.html | 2 +- app/views/editGroup.scala.html | 2 +- conf/evolutions/default/48.sql | 5 +++++ 6 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 conf/evolutions/default/48.sql diff --git a/app/controllers/CSVImportController.scala b/app/controllers/CSVImportController.scala index 45c3ae831..164314c83 100644 --- a/app/controllers/CSVImportController.scala +++ b/app/controllers/CSVImportController.scala @@ -186,7 +186,7 @@ case class CSVImportController @Inject() ( }, Option.apply ), - "name" -> text(maxLength = 60) + "name" -> text(maxLength = UserGroup.nameMaxLength) .transform[String](commonStringInputNormalization, commonStringInputNormalization), "description" -> optional(text).transform[Option[String]]( _.map(commonStringInputNormalization).filter(_.nonEmpty), diff --git a/app/controllers/GroupController.scala b/app/controllers/GroupController.scala index 03bcd5c23..75e9bb3d4 100644 --- a/app/controllers/GroupController.scala +++ b/app/controllers/GroupController.scala @@ -209,7 +209,7 @@ case class GroupController @Inject() ( Form( mapping( "id" -> ignored(UUID.randomUUID()), - "name" -> text(maxLength = 60) + "name" -> text(maxLength = UserGroup.nameMaxLength) .transform[String](commonStringInputNormalization, commonStringInputNormalization), "description" -> optional(text).transform[Option[String]]( _.map(commonStringInputNormalization).filter(_.nonEmpty), diff --git a/app/models/UserGroup.scala b/app/models/UserGroup.scala index ddc46c54e..0cd1bebe3 100644 --- a/app/models/UserGroup.scala +++ b/app/models/UserGroup.scala @@ -5,6 +5,12 @@ import helper.StringHelper.withQuotes import java.time.ZonedDateTime import java.util.UUID +object UserGroup { + + val nameMaxLength: Int = 100 + +} + case class UserGroup( id: UUID, name: String, diff --git a/app/views/allUsersNew.scala.html b/app/views/allUsersNew.scala.html index dc55d975c..91031f4a4 100644 --- a/app/views/allUsersNew.scala.html +++ b/app/views/allUsersNew.scala.html @@ -219,7 +219,7 @@

Ajouter un groupe


@helper.form(routes.GroupController.addGroup(), "method" -> "post", "class" -> "mdl-cell mdl-cell--9-col") { @helper.CSRF.formField
- +
diff --git a/app/views/editGroup.scala.html b/app/views/editGroup.scala.html index c692b808c..a81026783 100644 --- a/app/views/editGroup.scala.html +++ b/app/views/editGroup.scala.html @@ -12,7 +12,7 @@ @helper.form(routes.GroupController.editGroupPost(userGroup.id), "method" -> "post") { @helper.CSRF.formField
- +
diff --git a/conf/evolutions/default/48.sql b/conf/evolutions/default/48.sql new file mode 100644 index 000000000..32b7f025a --- /dev/null +++ b/conf/evolutions/default/48.sql @@ -0,0 +1,5 @@ +# --- !Ups +ALTER TABLE "user_group" ALTER COLUMN "name" SET DATA TYPE character varying(100); + +# --- !Downs +ALTER TABLE "user_group" ALTER COLUMN "name" SET DATA TYPE character varying(60) USING SUBSTR("name", 1, 60); From 61d76c7cca504e87cd9234c79d8014425da9c2e4 Mon Sep 17 00:00:00 2001 From: niladic Date: Thu, 25 Mar 2021 15:37:49 +0100 Subject: [PATCH 19/21] Corrige le deprecation warning onFailuresWithBackoff (#982) --- app/services/NotificationService.scala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/services/NotificationService.scala b/app/services/NotificationService.scala index 3f560d02c..74c2f7092 100644 --- a/app/services/NotificationService.scala +++ b/app/services/NotificationService.scala @@ -3,7 +3,7 @@ package services import java.util.UUID import akka.stream.scaladsl.{RestartSource, Sink, Source} -import akka.stream.{ActorAttributes, Materializer, Supervision} +import akka.stream.{ActorAttributes, Materializer, RestartSettings, Supervision} import cats.syntax.all._ import constants.Constants import controllers.routes @@ -100,10 +100,12 @@ class NotificationService @Inject() ( private def sendEmail(email: Email): Future[Unit] = RestartSource .onFailuresWithBackoff( - minBackoff = 10.seconds, - maxBackoff = 40.seconds, - randomFactor = 0.2, - maxRestarts = 3 + RestartSettings( + minBackoff = 10.seconds, + maxBackoff = 40.seconds, + randomFactor = 0.2 + ) + .withMaxRestarts(count = 3, within = 10.seconds) ) { () => Source.future { // `sendMail` is executed on the `dependencies.mailerExecutionContext` thread pool From 7a72fdbd7fe0fc1e272b360c4d2a41a0a023a0c7 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Thu, 25 Mar 2021 15:39:10 +0100 Subject: [PATCH 20/21] Update scalatags to 0.9.4 (#983) --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 4433571a2..6d718fb4d 100644 --- a/build.sbt +++ b/build.sbt @@ -88,7 +88,7 @@ libraryDependencies ++= Seq( "com.google.guava" % "guava" % "28.1-jre", "com.github.tototoshi" %% "scala-csv" % "1.3.7", ws, - "com.lihaoyi" %% "scalatags" % "0.9.3", + "com.lihaoyi" %% "scalatags" % "0.9.4", "org.typelevel" %% "cats-core" % "2.4.2", // To ensure that the version of jackson that do not have // known security vulnerabilities is used From 4fd8c5b8ef820a507157563bc2f2120b442985dd Mon Sep 17 00:00:00 2001 From: niladic Date: Tue, 30 Mar 2021 18:31:33 +0200 Subject: [PATCH 21/21] Ajout d'infos manquantes dans les logs (utilisateur et demande) (#987) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ajout d’infos manquantes dans les logs (utilisateur et demande) * Ajout de logs pour les créations de demande et invitation * Simplification de EventService --- app/controllers/ApplicationController.scala | 75 +++++++++++++++------ app/controllers/CSVImportController.scala | 2 +- app/controllers/UserController.scala | 52 +++++++++----- app/services/EventService.scala | 10 +-- app/tasks/AutoAddExpertTask.scala | 4 +- 5 files changed, 96 insertions(+), 47 deletions(-) diff --git a/app/controllers/ApplicationController.scala b/app/controllers/ApplicationController.scala index a4d6462e7..dec754195 100644 --- a/app/controllers/ApplicationController.scala +++ b/app/controllers/ApplicationController.scala @@ -326,8 +326,16 @@ case class ApplicationController @Inject() ( eventService.log( ApplicationCreated, s"La demande ${application.id} a été créée", - Some(application) + application = application.some ) + application.invitedUsers.foreach { case (userId, _) => + eventService.log( + ApplicationCreated, + s"Envoi de la nouvelle demande ${application.id} à l'utilisateur $userId", + application = application.some, + involvesUser = userId.some + ) + } applicationData.linkedMandat.foreach { mandatId => mandatService .linkToApplication(Mandat.Id(mandatId), applicationId) @@ -340,7 +348,7 @@ case class ApplicationController @Inject() ( underlyingException = Some(error) ) case Success(Left(error)) => - eventService.logError(error, application = Some(application)) + eventService.logError(error, application = application.some) case Success(Right(_)) => eventService.log( ApplicationLinkedToMandat, @@ -669,7 +677,7 @@ case class ApplicationController @Inject() ( eventService.log( AllAsUnauthorized, s"L'utilisateur n'a pas de droit d'afficher la vue de l'utilisateur $userId", - involvesUser = Some(user) + involvesUser = Some(user.id) ) Future( Unauthorized( @@ -680,7 +688,7 @@ case class ApplicationController @Inject() ( eventService.log( AllAsUnauthorized, s"L'utilisateur n'a pas de droit d'afficher la vue de l'utilisateur admin $userId", - involvesUser = Some(user) + involvesUser = Some(user.id) ) Future( Unauthorized( @@ -695,7 +703,7 @@ case class ApplicationController @Inject() ( .log( AllAsShowed, s"Visualise la vue de l'utilisateur $userId", - involvesUser = Some(user) + involvesUser = Some(user.id) ) val applications = applicationService.allForUserId( userId = targetUserId, @@ -999,7 +1007,8 @@ case class ApplicationController @Inject() ( case Some(answer) if answer.files.getOrElse(Map.empty).contains(filename) => eventService.log( FileOpened, - s"Le fichier de la réponse $answerId sur la demande $applicationId a été ouvert" + s"Le fichier de la réponse $answerId sur la demande $applicationId a été ouvert", + application = application.some ) sendFile( Paths.get(s"$filesPath/ans_$answerId-$filename"), @@ -1009,7 +1018,8 @@ case class ApplicationController @Inject() ( case _ => eventService.log( FileNotFound, - s"Le fichier de la réponse $answerId sur la demande $applicationId n'existe pas" + s"Le fichier de la réponse $answerId sur la demande $applicationId n'existe pas", + application = application.some ) Future(NotFound("Nous n'avons pas trouvé ce fichier")) } @@ -1020,7 +1030,11 @@ case class ApplicationController @Inject() ( ) => if (application.files.contains(filename)) { eventService - .log(FileOpened, s"Le fichier de la demande $applicationId a été ouvert") + .log( + FileOpened, + s"Le fichier de la demande $applicationId a été ouvert", + application = application.some + ) sendFile( Paths.get(s"$filesPath/app_$applicationId-$filename"), filename, @@ -1029,7 +1043,8 @@ case class ApplicationController @Inject() ( } else { eventService.log( FileNotFound, - s"Le fichier de la demande $applicationId n'existe pas" + s"Le fichier de la demande $applicationId n'existe pas", + application = application.some ) Future(NotFound("Nous n'avons pas trouvé ce fichier")) } @@ -1070,7 +1085,7 @@ case class ApplicationController @Inject() ( formWithErrors => { val error = s"Erreur dans le formulaire de réponse (${formWithErrors.errors.map(_.message).mkString(", ")})." - eventService.log(AnswerNotCreated, s"$error") + eventService.log(AnswerNotCreated, s"$error", application = application.some) Future( Redirect( routes.ApplicationController.show(applicationId).withFragment("answer-error") @@ -1137,7 +1152,7 @@ case class ApplicationController @Inject() ( eventService.log( AnswerNotCreated, s"La réponse ${answer.id} n'a pas été créée sur la demande $applicationId : problème BDD", - Some(application) + application.some ) Future(InternalServerError("Votre réponse n'a pas pu être envoyée")) } @@ -1164,7 +1179,7 @@ case class ApplicationController @Inject() ( formWithErrors => { val error = s"Erreur dans le formulaire d’invitation (${formWithErrors.errors.map(_.message).mkString(", ")})." - eventService.log(InviteNotCreated, error) + eventService.log(InviteNotCreated, error, application = application.some) Future( Redirect( routes.ApplicationController.show(applicationId).withFragment("answer-error") @@ -1176,7 +1191,7 @@ case class ApplicationController @Inject() ( if (inviteData.invitedUsers.isEmpty && inviteData.invitedGroups.isEmpty) { val error = s"Erreur dans le formulaire d’invitation (une personne ou un organisme doit être sélectionné)." - eventService.log(InviteNotCreated, error) + eventService.log(InviteNotCreated, error, application = application.some) Future( Redirect( routes.ApplicationController.show(applicationId).withFragment("answer-error") @@ -1218,16 +1233,24 @@ case class ApplicationController @Inject() ( notificationsService.newAnswer(application, answer) eventService.log( AgentsAdded, - s"L'ajout d'utilisateur ${answer.id} a été créé sur la demande $applicationId", - Some(application) + s"L'ajout d'utilisateur (réponse ${answer.id}) a été créé sur la demande $applicationId", + application = application.some ) + answer.invitedUsers.foreach { case (userId, _) => + eventService.log( + AgentsAdded, + s"Utilisateur $userId invité sur la demande $applicationId (réponse ${answer.id})", + application = application.some, + involvesUser = userId.some + ) + } Redirect(routes.ApplicationController.myApplications()) .flashing(success -> "Les utilisateurs ont été invités sur la demande") } else { eventService.log( AgentsNotAdded, s"L'ajout d'utilisateur ${answer.id} n'a pas été créé sur la demande $applicationId : problème BDD", - Some(application) + application = application.some ) InternalServerError("Les utilisateurs n'ont pas pu être invités") } @@ -1266,8 +1289,16 @@ case class ApplicationController @Inject() ( eventService.log( AddExpertCreated, s"La réponse ${answer.id} a été créée sur la demande $applicationId", - Some(application) + application = application.some ) + answer.invitedUsers.foreach { case (userId, _) => + eventService.log( + AddExpertCreated, + s"Expert $userId invité sur la demande $applicationId (réponse ${answer.id})", + application = application.some, + involvesUser = userId.some + ) + } Redirect(routes.ApplicationController.myApplications()) .flashing(success -> "Un expert a été invité sur la demande") } else { @@ -1298,7 +1329,6 @@ case class ApplicationController @Inject() ( def reopen(applicationId: UUID): Action[AnyContent] = loginAction.async { implicit request => withApplication(applicationId) { application: Application => - import eventService._ successful(application.canBeOpenedBy(request.currentUser)).flatMap { case true => applicationService @@ -1306,17 +1336,17 @@ case class ApplicationController @Inject() ( .filter(identity) .map { _ => val message = "La demande a bien été réouverte" - log(ReopenCompleted, message, application.some) + eventService.log(ReopenCompleted, message, application.some) Redirect(routes.ApplicationController.myApplications()).flashing(success -> message) } .recover { _ => val message = "La demande n'a pas pu être réouverte" - log(ReopenError, message, application.some) + eventService.log(ReopenError, message, application.some) InternalServerError(message) } case false => val message = s"Non autorisé à réouvrir la demande $applicationId" - log(ReopenUnauthorized, message, application.some) + eventService.log(ReopenUnauthorized, message, application.some) successful(Unauthorized(message)) } } @@ -1330,7 +1360,8 @@ case class ApplicationController @Inject() ( eventService .log( TerminateIncompleted, - s"La demande de clôture pour $applicationId est incomplète" + s"La demande de clôture pour $applicationId est incomplète", + application = application.some ) Future( BadGateway( diff --git a/app/controllers/CSVImportController.scala b/app/controllers/CSVImportController.scala index 164314c83..f8ff7ca21 100644 --- a/app/controllers/CSVImportController.scala +++ b/app/controllers/CSVImportController.scala @@ -433,7 +433,7 @@ case class CSVImportController @Inject() ( eventService.log( UserCreated, s"Utilisateur ajouté ${user.toLogString}", - involvesUser = Some(user) + involvesUser = Some(user.id) ) } eventService diff --git a/app/controllers/UserController.scala b/app/controllers/UserController.scala index e26fec331..3bd4abd59 100644 --- a/app/controllers/UserController.scala +++ b/app/controllers/UserController.scala @@ -133,7 +133,8 @@ case class UserController @Inject() ( if usersInGroup.map(_.id).contains[UUID](userToAdd.id) => eventService.log( EditMyGroupBadUserInput, - s"Tentative d'ajout de l'utilisateur ${userToAdd.id} déjà présent au groupe $groupId" + s"Tentative d'ajout de l'utilisateur ${userToAdd.id} déjà présent au groupe $groupId", + involvesUser = userToAdd.id.some ) successful( Redirect(routes.UserController.showEditMyGroups()) @@ -145,7 +146,8 @@ case class UserController @Inject() ( .map { _ => eventService.log( EditMyGroupUpdated, - s"Utilisateur ${userToAdd.id} ajouté au groupe $groupId" + s"Utilisateur ${userToAdd.id} ajouté au groupe $groupId", + involvesUser = userToAdd.id.some ) Redirect(routes.UserController.showEditMyGroups()) .flashing("success" -> "L’utilisateur a été ajouté au groupe") @@ -155,21 +157,24 @@ case class UserController @Inject() ( ) } - def removeFromGroup(id: UUID, groupId: UUID) = + def removeFromGroup(userId: UUID, groupId: UUID) = loginAction.async { implicit request => - val user = request.currentUser - if (user.belongsTo(groupId)) + if (request.currentUser.belongsTo(groupId)) userService - .removeFromGroup(id, groupId) + .removeFromGroup(userId, groupId) .map { _ => - eventService.log(EditMyGroupUpdated, s"Utilisateur $id retiré du groupe $groupId") + eventService.log( + EditMyGroupUpdated, + s"Utilisateur $userId retiré du groupe $groupId", + involvesUser = userId.some + ) Redirect(routes.UserController.showEditMyGroups()) .flashing("success" -> "L’utilisateur a bien été retiré du groupe.") } .recover { e => eventService.log( EditMyGroupUpdatedError, - s"Erreur lors de la tentative d'ajout de l'utilisateur $id au groupe $groupId : ${e.getMessage}" + s"Erreur lors de la tentative d'ajout de l'utilisateur $userId au groupe $groupId : ${e.getMessage}" ) Redirect(routes.UserController.showEditMyGroups()) .flashing("error" -> "Une erreur technique est survenue") @@ -461,7 +466,7 @@ case class UserController @Inject() ( .log( UserShowed, "Visualise la vue de modification l'utilisateur ", - involvesUser = Some(user) + involvesUser = Some(user.id) ) Future( Ok( @@ -476,7 +481,11 @@ case class UserController @Inject() ( ) ) case _ => - eventService.log(ViewUserUnauthorized, s"Accès non autorisé pour voir $userId") + eventService.log( + ViewUserUnauthorized, + s"Accès non autorisé pour voir $userId", + involvesUser = userId.some + ) Future(Unauthorized("Vous n'avez pas le droit de faire ça")) } } @@ -492,7 +501,11 @@ case class UserController @Inject() ( DeleteUserUnauthorized -> s"Suppression de l'utilisateur $userId refusée." } { () => if (isAccountUsed(user)) { - eventService.log(UserIsUsed, description = s"Le compte ${user.id} est utilisé.") + eventService.log( + UserIsUsed, + description = s"Le compte ${user.id} est utilisé.", + involvesUser = user.id.some + ) Future(Unauthorized("User is not unused.")) } else { userService.deleteById(userId) @@ -500,7 +513,7 @@ case class UserController @Inject() ( eventService.log( UserDeleted, s"Utilisateur ${user.toLogString} supprimé", - involvesUser = Some(user) + involvesUser = Some(user.id) ) Future( Redirect(routes.UserController.home()).flashing("success" -> flashMessage) @@ -526,7 +539,8 @@ case class UserController @Inject() ( val groups = groupService.allGroups eventService.log( AddUserError, - s"Essai de modification de l'utilisateur $userId avec des erreurs de validation" + s"Essai de modification de l'utilisateur $userId avec des erreurs de validation", + involvesUser = user.id.some ) Future( BadRequest( @@ -548,7 +562,11 @@ case class UserController @Inject() ( val rights = request.rights if (not(Authorization.canEditOtherUser(oldUser)(rights))) { eventService - .log(PostEditUserUnauthorized, s"Accès non autorisé à modifier $userId") + .log( + PostEditUserUnauthorized, + s"Accès non autorisé à modifier $userId", + involvesUser = oldUser.id.some + ) Future(Unauthorized("Vous n'avez pas le droit de faire ça")) } else { val userToUpdate = oldUser.copy( @@ -575,7 +593,7 @@ case class UserController @Inject() ( .log( UserEdited, s"Utilisateur $userId modifié ${oldUser.toDiffLogString(userToUpdate)}", - involvesUser = Some(userToUpdate) + involvesUser = Some(userToUpdate.id) ) Redirect(routes.UserController.editUser(userId)) .flashing("success" -> "Utilisateur modifié") @@ -589,7 +607,7 @@ case class UserController @Inject() ( eventService.log( EditUserError, s"Impossible de modifier l'utilisateur dans la BDD ${oldUser.toDiffLogString(userToUpdate)}", - involvesUser = Some(oldUser) + involvesUser = Some(oldUser.id) ) InternalServerError( views.html @@ -681,7 +699,7 @@ case class UserController @Inject() ( eventService.log( EventType.UserCreated, s"Utilisateur ajouté ${user.toLogString}", - involvesUser = Some(user) + involvesUser = Some(user.id) ) } eventService.log(UsersCreated, "Utilisateurs ajoutés") diff --git a/app/services/EventService.scala b/app/services/EventService.scala index ff15d6e97..3a0973bcb 100644 --- a/app/services/EventService.scala +++ b/app/services/EventService.scala @@ -40,7 +40,7 @@ class EventService @Inject() (db: Database, dependencies: ServicesDependencies) description: String, application: Option[Application] = None, /** Not the logged-in `User`, but if the op is about some other `User`. */ - involvesUser: Option[User] = None, + involvesUser: Option[UUID] = None, /** If the warn/error has an exception as cause. */ underlyingException: Option[Throwable] = None )(implicit request: RequestWithUserData[_]) = @@ -57,7 +57,7 @@ class EventService @Inject() (db: Database, dependencies: ServicesDependencies) def logError( error: models.Error, application: Option[Application] = None, - involvesUser: Option[User] = None + involvesUser: Option[UUID] = None )(implicit request: RequestWithUserData[_]) = log( event = error.eventType, @@ -76,7 +76,7 @@ class EventService @Inject() (db: Database, dependencies: ServicesDependencies) event: EventType, description: String, application: Option[Application] = None, - involvesUser: Option[User] = None, + involvesUser: Option[UUID] = None, underlyingException: Option[Throwable] = None )(implicit request: Request[_]): Unit = register(event.level)( @@ -95,7 +95,7 @@ class EventService @Inject() (db: Database, dependencies: ServicesDependencies) code: String, description: String, application: Option[Application], - involvesUser: Option[User], + involvesUser: Option[UUID], underlyingException: Option[Throwable] ): Unit = { val event = Event( @@ -108,7 +108,7 @@ class EventService @Inject() (db: Database, dependencies: ServicesDependencies) description, Area.notApplicable.id, application.map(_.id), - involvesUser.map(_.id), + involvesUser, remoteAddress ) addEvent(event) diff --git a/app/tasks/AutoAddExpertTask.scala b/app/tasks/AutoAddExpertTask.scala index 5242100d6..5d92641e1 100644 --- a/app/tasks/AutoAddExpertTask.scala +++ b/app/tasks/AutoAddExpertTask.scala @@ -77,7 +77,7 @@ class AutoAddExpertTask @Inject() ( "ADD_EXPERT_CREATED", s"Les experts ont été automatiquement ajoutés ${answer.id} sur la demande ${application.id}", application.some, - Option.empty[User], + expert.id.some, Option.empty[Throwable] ) } else { @@ -87,7 +87,7 @@ class AutoAddExpertTask @Inject() ( "ANSWER_NOT_CREATED", s"Les experts n'ont pas pu être automatiquement ajoutés ${answer.id} sur la demande ${application.id} : problème BDD", application.some, - Option.empty[User], + expert.id.some, Option.empty[Throwable] ) }