diff --git a/app/controllers/ApiController.scala b/app/controllers/ApiController.scala
index 89cfa412..56b785da 100644
--- a/app/controllers/ApiController.scala
+++ b/app/controllers/ApiController.scala
@@ -343,9 +343,7 @@ case class ApiController @Inject() (
"Accès non autorisé au dashboard de déploiement"
) { () =>
val userGroups = userGroupService.allOrThrow.filter(group =>
- group.organisation
- .orElse(Organisation.deductedFromName(group.name))
- .exists(_.id === Organisation.franceServicesId)
+ group.organisation.exists(_.id === Organisation.franceServicesId)
)
val franceServiceInstances = organisationService.franceServiceInfos.instances
val doNotMatchTheseEmails =
@@ -439,11 +437,7 @@ case class ApiController @Inject() (
for {
group <- userGroups.filter(group =>
group.areaIds.contains[UUID](area.id)
- && organisationSet.exists(
- group.organisation
- .orElse(Organisation.deductedFromName(group.name))
- .contains[Organisation]
- )
+ && organisationSet.exists(group.organisation.contains[Organisation])
)
user <- users if user.groupIds.contains[UUID](group.id)
} yield user
diff --git a/app/models/Organisation.scala b/app/models/Organisation.scala
index efd8e1a3..df5bd4e2 100644
--- a/app/models/Organisation.scala
+++ b/app/models/Organisation.scala
@@ -157,15 +157,4 @@ object Organisation {
subjects: Seq[Subject]
)
- def deductedFromName(name: String): Option[Organisation] = {
- val lowerCaseName = name.toLowerCase().stripSpecialChars
- // Hack: `.reverse` the orgs so we can match first MSAP before MSA and
- // Sous-Préf before Préf
- all.reverse
- .find { organisation =>
- lowerCaseName.contains(organisation.shortName.toLowerCase().stripSpecialChars) ||
- lowerCaseName.contains(organisation.name.toLowerCase().stripSpecialChars)
- }
- }
-
}
diff --git a/app/serializers/UserAndGroupCsvSerializer.scala b/app/serializers/UserAndGroupCsvSerializer.scala
index 929a5bfe..70b349d9 100644
--- a/app/serializers/UserAndGroupCsvSerializer.scala
+++ b/app/serializers/UserAndGroupCsvSerializer.scala
@@ -264,11 +264,22 @@ object UserAndGroupCsvSerializer {
}
}
+ def organisationFromNameHeuristic(name: String): Option[Organisation] = {
+ val lowerCaseName = name.toLowerCase().stripSpecialChars
+ // Hack: `.reverse` the orgs so we can match first MSAP before MSA and
+ // Sous-Préf before Préf
+ Organisation.all.reverse
+ .find { organisation =>
+ lowerCaseName.contains(organisation.shortName.toLowerCase().stripSpecialChars) ||
+ lowerCaseName.contains(organisation.name.toLowerCase().stripSpecialChars)
+ }
+ }
+
def matchOrganisationId: CSVMap = {
val optionOrganisation = csvMap
.get(GROUP_ORGANISATION.key)
.orElse(csvMap.get(GROUP_NAME.key))
- .flatMap(Organisation.deductedFromName)
+ .flatMap(organisationFromNameHeuristic)
optionOrganisation match {
case Some(organisation) =>
csvMap + (GROUP_ORGANISATION.key -> organisation.id.id)
diff --git a/app/views/allUsersByGroup.scala.html b/app/views/allUsersByGroup.scala.html
index fdf420bc..379f22da 100644
--- a/app/views/allUsersByGroup.scala.html
+++ b/app/views/allUsersByGroup.scala.html
@@ -93,11 +93,10 @@
}
@userGroup.areaIds.flatMap(Area.fromId).map(_.name).sorted.mkString(", ") /
- @userGroup.name / @(userGroup.organisation, Organisation.deductedFromName(userGroup.name)) match {
- case (Some(organisation), _) => {
+ @userGroup.name / @userGroup.organisation match {
+ case Some(organisation) => {
@organisation.shortName / }
- case (_, Some(organisation)) => { @organisation.shortName / }
- case _ => {}
+ case None => {}
} INSEE : @userGroup.inseeCode
@userGroup.description
}{
diff --git a/app/views/deploymentDashboard.scala.html b/app/views/deploymentDashboard.scala.html
index 6aeacb87..9b6f1c70 100644
--- a/app/views/deploymentDashboard.scala.html
+++ b/app/views/deploymentDashboard.scala.html
@@ -5,8 +5,8 @@