Skip to content

Commit

Permalink
Résultat Atelier Admin 1 (#481)
Browse files Browse the repository at this point in the history
* Correction texte dans le tableau de déploiement
* Changer le nom de Zohra
* Mise en cache 1h des stats
* Changement de zone pour l'expert
* Affiche la maison france service sur la demande
  • Loading branch information
jdauphant authored Feb 7, 2020
1 parent 856f09e commit 7dd79d6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
31 changes: 19 additions & 12 deletions app/controllers/ApplicationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import play.twirl.api.Html
import scala.concurrent.{ExecutionContext, Future}
import helper.StringHelper.CanonizeString
import serializers.AttachmentHelper
import scala.concurrent.duration._

/**
* This controller creates an `Action` to handle HTTP requests to the
Expand Down Expand Up @@ -158,19 +159,24 @@ case class ApplicationController @Inject() (
val groups = userGroupService.byIds(user.groupIds)
val contexts = groups
.filter(_.areaIds.contains[UUID](currentAreaId))
.flatMap({ userGroup: UserGroup =>
for {
areaInseeCode <- userGroup.areaIds.flatMap(Area.fromId).map(_.inseeCode).headOption
organisationId <- userGroup.organisation
organisation <- Organisation.byId(organisationId)
} yield {
s"($organisation - $areaInseeCode)"
.flatMap { userGroup: UserGroup =>
if (user.instructor) {
for {
areaInseeCode <- userGroup.areaIds.flatMap(Area.fromId).map(_.inseeCode).headOption
organisationId <- userGroup.organisation
organisation <- Organisation.byId(organisationId)
} yield {
s"(${organisation.name} - $areaInseeCode)"
}
} else {
List(s"(${userGroup.name})")
}
})
}
val capitalizedUserName = user.name.split(' ').map(_.capitalize).mkString(" ")
if (contexts.isEmpty)
s"${user.name} ( ${user.qualite} )"
s"${capitalizedUserName} ( ${user.qualite} )"
else
s"${user.name} ${contexts.mkString(",")}"
s"${capitalizedUserName} ${contexts.mkString(",")}"
}

private def createPostBis(simplified: Boolean) = loginAction { implicit request =>
Expand Down Expand Up @@ -398,7 +404,7 @@ case class ApplicationController @Inject() (
s"stats.user_${request.currentUser.id}"

cache
.getOrElseUpdate[Html](cacheKey)(Future(generateStats))
.getOrElseUpdate[Html](cacheKey, 1 hours)(Future(generateStats))
.map { html =>
eventService.log(StatsShowed, "Visualise les stats")
Ok(html)
Expand Down Expand Up @@ -597,7 +603,8 @@ case class ApplicationController @Inject() (
groupsWithUsersThatCanBeInvited,
renderedApplication,
answerForm,
openedTab
openedTab,
request.currentArea
)
)
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/models/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ object User {
User(
UUIDHelper.namedFrom("zohra"),
Hash.sha256(s"zohra"),
"Zohra LEBEL",
"LEBEL-SEDKI Zohra",
"Experte A+",
"zohra.lebel@beta.gouv.fr",
true,
Expand Down
2 changes: 1 addition & 1 deletion app/views/deploymentDashboard.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@webJarsUtil.locate("xlsx.full.min.js").script()
}{
<h5 class="title--addline">Nombre d'agents instructeurs par organisation</h5>
<i>Les agents sont comptés double s'ils sont dans plusieurs départements. Les organisations manquantes ne sont pas affichées. Certains agents ne sont pas détecté comme faisant partie d'un organisation (Vous devez corriger le groupe dans ce cas)</i>
<i>Les agents sont comptés double si ils sont dans plusieurs départements. Les organisations manquantes ne sont pas affichées. Certains agents ne sont pas détectés comme faisant partie d'un organisation (Vous devez corriger le groupe dans ce cas)</i>
<div class="mdl-cell mdl-cell--12-col mdl-grid mdl-grid--no-spacing">
@for(organisationSet <- data.head._2.map(_._1)) {
<div class="mdl-cell mdl-cell--2-col">
Expand Down
4 changes: 2 additions & 2 deletions app/views/showApplication.scala.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@(user: User)(groupsWithUsersThatCanBeInvited: List[(UserGroup,List[User])], application: Application, answerToAgentsForm: Form[_], openedTab: String, attachments: Iterable[String] = Nil)(implicit webJarsUtil: org.webjars.play.WebJarsUtil, flash: Flash, messagesProvider: MessagesProvider, request: RequestHeader)
@(user: User)(groupsWithUsersThatCanBeInvited: List[(UserGroup,List[User])], application: Application, answerToAgentsForm: Form[_], openedTab: String, currentArea: Area, attachments: Iterable[String] = Nil)(implicit webJarsUtil: org.webjars.play.WebJarsUtil, flash: Flash, messagesProvider: MessagesProvider, request: RequestHeader)
@import java.util.Locale

@main(user)(s"Demande de ${application.creatorUserName} - ${Area.fromId(application.area).get.name}") {
@main(user, if(user.expert) { Some(currentArea)} else { None })(s"Demande de ${application.creatorUserName} - ${Area.fromId(application.area).get.name}") {,
<style>
.mdl-list__item-primary-content {
font-weight: bold;
Expand Down

0 comments on commit 7dd79d6

Please sign in to comment.