Skip to content

Commit

Permalink
Corrige association maison france service (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdauphant authored Feb 27, 2020
1 parent cb0bdd0 commit 724ed52
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
17 changes: 12 additions & 5 deletions app/controllers/ApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import actions.LoginAction
import Operators.UserOperators
import helper.StringHelper
import java.util.UUID

import javax.inject.{Inject, Singleton}
import models.EventType.DeploymentDashboardUnauthorized
import models.{Area, UserGroup}
import models.{Area, Organisation, UserGroup}
import play.api.libs.json.Json
import play.api.mvc.InjectedController
import play.api.mvc._

import scala.concurrent.ExecutionContext
import serializers.ApiModel._
import services.{EventService, OrganisationService, UserGroupService, UserService}
Expand Down Expand Up @@ -47,14 +49,19 @@ case class ApiController @Inject() (
.stripEverythingButLettersAndNumbers(group.name)
.contains(StringHelper.stripEverythingButLettersAndNumbers(franceServiceInstance.commune))
)
byEmail.orElse(byName).orElse(byCommune)
byEmail.orElse(byName).orElse(byCommune).filter { userGroup =>
val areas: List[Area] = userGroup.areaIds.flatMap(Area.fromId)
areas.exists(_.inseeCode == franceServiceInstance.departementCode.code)
}
}

def franceServiceDeployment = loginAction { implicit request =>
def franceServiceDeployment: Action[AnyContent] = loginAction { implicit request =>
asAdmin { () =>
DeploymentDashboardUnauthorized -> "Accès non autorisé au dashboard de déploiement"
} { () =>
val userGroups = userGroupService.allGroups
val userGroups = userGroupService.allGroups.filter(
_.organisationSetOrDeducted.exists(_.id == Organisation.franceServicesId)
)
val matches: List[(FranceServiceInstance, Option[UserGroup], Area)] =
organisationService.franceServiceInfos.instances
.map(instance =>
Expand Down
4 changes: 3 additions & 1 deletion app/models/Organisation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ object Organisation {
def byId(id: Id): Option[Organisation] =
all.find(org => (org.id: Id) == (id: Id))

val franceServicesId = Organisation.Id("MFS")

val all = List(
Organisation("ANAH", "Agence nationale de l'habitat"),
Organisation("ANTS", "Agence nationale des titres sécurisés"),
Expand All @@ -67,7 +69,7 @@ object Organisation {
Organisation("La Poste", "La Poste"),
Organisation("Mairie", "Mairie"), //Ville
Organisation("MDPH", "Maison départementale des personnes handicapées"),
Organisation(Organisation.Id("MFS"), "FS", "France Services"),
Organisation(franceServicesId, "FS", "France Services"),
Organisation("Mission locale", "Mission locale"), //Ville
Organisation("MSA", "Mutualité sociale agricole"),
Organisation("MSAP", "Maison de services au public"), // Ville
Expand Down
4 changes: 2 additions & 2 deletions app/views/franceServiceDeploymentDashboard.scala.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@(currentUser: User)(implicit webJarsUtil: org.webjars.play.WebJarsUtil, flash: Flash, request: RequestHeader)

@main(currentUser, maxWidth = false)(s"Tableau de déploiement France Service") {
@main(currentUser, maxWidth = false)(s"Tableau de déploiement France Services") {
@webJarsUtil.locate("tabulator.min.css").css()
@webJarsUtil.locate("tabulator.min.js").script()
@webJarsUtil.locate("xlsx.full.min.js").script()
}{
<h5 class="title--addline">Tableau de déploiement France Service</h5>
<h5 class="title--addline">Tableau de déploiement France Services</h5>
<div id="aplus-admin-deployment-france-service-total" class="mdl-cell mdl-cell--12-col"></div>
<div id="aplus-admin-deployment-france-service-table" class="mdl-cell mdl-cell--12-col"></div>
<div class="mdl-cell mdl-cell--12-col">
Expand Down
4 changes: 2 additions & 2 deletions public/javascripts/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ if (window.document.getElementById(franceServiceDeploymentTableTagId)) {
var nrOfDeployed = 0;
var totalNr = response.length;
for (var i = 0; i < totalNr; i++) {
if (response[i].groupSize >= 2) {
if (response[i].groupSize >= 1) {
nrOfDeployed++;
}
}
var element = window.document.getElementById(franceServiceDeploymentTotalTagId);
element.textContent = "Nombre de déploiements (plus de 2 utilisateurs): " +
element.textContent = "Nombre de déploiements (plus de 1 utilisateur): " +
nrOfDeployed + " ; Nombre total: " + totalNr
return response; //return the response data to tabulator
},
Expand Down

0 comments on commit 724ed52

Please sign in to comment.