ui: Générer /vie-etudiante depuis ui/vie-etudiante-organismes.json

Déplacer ui/organismes.json -> ui/vie-etudiante-organismes.json
Embed ui/vie-etudiante-organismes.json
This commit is contained in:
Victor Lacasse-Beaudoin 2025-03-05 16:56:23 -05:00
parent c84c998d44
commit 0f28252a6c
4 changed files with 61 additions and 195 deletions

View file

@ -2,6 +2,7 @@ package agecemorg
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"io" "io"
"log" "log"
@ -11,6 +12,7 @@ import (
"codeberg.org/vlbeaudoin/pave/v2" "codeberg.org/vlbeaudoin/pave/v2"
"codeberg.org/vlbeaudoin/voki/v3" "codeberg.org/vlbeaudoin/voki/v3"
"git.agecem.com/agecem/agecem-org/v3/ui"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7"
) )
@ -590,7 +592,24 @@ func HandleActualiteArticle(c echo.Context) error {
*/ */
func HandleVieEtudiante(c echo.Context) error { func HandleVieEtudiante(c echo.Context) error {
return c.Render(http.StatusOK, "vie-etudiante-html", nil) var data struct {
Data struct {
Organismes map[string][]struct {
Nom string
Local string
Poste string
Statut string
}
}
Error string
}
if err := json.Unmarshal([]byte(ui.OrganismesJSON()), &data.Data.Organismes); err != nil {
data.Error = err.Error()
log.Println("json error in vie-etudiante:", err)
}
return c.Render(http.StatusOK, "vie-etudiante-html", data)
} }
func HandleVieEtudianteOrganisme(c echo.Context) error { func HandleVieEtudianteOrganisme(c echo.Context) error {

View file

@ -19,6 +19,11 @@ import (
//go:embed *.html //go:embed *.html
var htmlFS embed.FS var htmlFS embed.FS
//go:embed vie-etudiante-organismes.json
var organismesJSON string
func OrganismesJSON() string { return organismesJSON }
type Renderer struct { type Renderer struct {
templates *template.Template templates *template.Template
} }

View file

@ -1,16 +1,4 @@
{ {
"Organismes thématiques": [
{ "Nom": "AME", "Local": "C-060", "Poste": "7919", "Statut": "Actif" },
{ "Nom": "BEAM", "Local": "F-024a", "Poste": "5930", "Statut": "Actif" },
{ "Nom": "Club Aventurier", "Local": "F-011b", "Poste": "2418", "Statut": "Actif" },
{ "Nom": "MAEL", "Local": "F-027b", "Poste": "6438", "Statut": "Actif" },
{ "Nom": "Montpetit Donjon", "Local": "C-067", "Poste": "2299", "Statut": "Actif" },
{ "Nom": "MotDit", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" },
{ "Nom": "OGRE", "Local": "F-011c", "Poste": "2248", "Statut": "Actif" },
{ "Nom": "ORGASME", "Local": "F-049", "Poste": "N/A", "Statut": "Actif" },
{ "Nom": "RECEM", "Local": "A-125s", "Poste": "N/A", "Statut": "Actif" },
{ "Nom": "Équipe Santé", "Local": "F-011", "Poste": "2361", "Statut": "Actif" }
],
"Associations de programme": [ "Associations de programme": [
{ "Nom": "ADEPT", "Local": "F-045", "Poste": "2286", "Statut": "Actif" }, { "Nom": "ADEPT", "Local": "F-045", "Poste": "2286", "Statut": "Actif" },
{ "Nom": "ASI", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" }, { "Nom": "ASI", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" },
@ -30,6 +18,17 @@
{ "Nom": "ESPACE", "Local": "F-011d", "Poste": "2418", "Statut": "Actif" }, { "Nom": "ESPACE", "Local": "F-011d", "Poste": "2418", "Statut": "Actif" },
{ "Nom": "EUMC-CEM", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" }, { "Nom": "EUMC-CEM", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" },
{ "Nom": "Friperie", "Local": "F-027a", "Poste": "2248", "Statut": "Actif" } { "Nom": "Friperie", "Local": "F-027a", "Poste": "2248", "Statut": "Actif" }
],
"Organismes thématiques": [
{ "Nom": "AME", "Local": "C-060", "Poste": "7919", "Statut": "Actif" },
{ "Nom": "BEAM", "Local": "F-024a", "Poste": "5930", "Statut": "Actif" },
{ "Nom": "Club Aventurier", "Local": "F-011b", "Poste": "2418", "Statut": "Actif" },
{ "Nom": "MAEL", "Local": "F-027b", "Poste": "6438", "Statut": "Actif" },
{ "Nom": "Montpetit Donjon", "Local": "C-067", "Poste": "2299", "Statut": "Actif" },
{ "Nom": "MotDit", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" },
{ "Nom": "OGRE", "Local": "F-011c", "Poste": "2248", "Statut": "Actif" },
{ "Nom": "ORGASME", "Local": "F-049", "Poste": "N/A", "Statut": "Actif" },
{ "Nom": "RECEM", "Local": "A-125s", "Poste": "N/A", "Statut": "Actif" },
{ "Nom": "Équipe Santé", "Local": "F-011", "Poste": "2361", "Statut": "Actif" }
] ]
} }

View file

@ -13,7 +13,12 @@
{{ template "header-html" }} {{ template "header-html" }}
<div class="wrapper vieEtudianteWrapper"> <div class="wrapper vieEtudianteWrapper">
<h1 class="heading1">Vie étudiante</h1> <h1 class="heading1">Vie étudiante</h1>
<h2 class="heading2">Organismes thématiques</h2>
{{if not .Data.Organismes}}
<h2>Liste des organismes étudiants non-disponible, merci de rééssayer plus tard.</h2>
{{else}}
{{range $categorie, $organismes := .Data.Organismes}}
<h2 class="heading2">{{$categorie}}</h2>
<table class="table"> <table class="table">
<tr class="tableRowHeading"> <tr class="tableRowHeading">
<td>Nom</td> <td>Nom</td>
@ -21,193 +26,31 @@
<td>Poste</td> <td>Poste</td>
<td>Statut</td> <td>Statut</td>
</tr> </tr>
<tr class="tableRow"> {{range $organismes}}
<td>AME</td> {{if eq .Statut "Inactif"}}
<td>C-060</td>
<td>7919</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>BEAM</td>
<td>F-024a</td>
<td>5930</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>Club Aventurier</td>
<td>F-011b</td>
<td>2418</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>Équipe Santé</td>
<td>F-011</td>
<td>2361</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>Montpetit Donjon</td>
<td>C-067</td>
<td>2299</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>MAEL</td>
<td>F-027b</td>
<td>6438</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>OGRE</td>
<td>F-011c</td>
<td>2248</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>RECEM</td>
<td>A-125s</td>
<td>N/A</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>ORGASME</td>
<td>F-049</td>
<td>N/A</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow inactive"> <tr class="tableRow inactive">
<td>SOI</td> <td>{{.Nom}}</td>
<td>N/A</td> <td>{{.Local}}</td>
<td>N/A</td> <td>{{.Poste}}</td>
<td class="organismeInactif">Inactif</td> <td class="organismeInactif">{{.Statut}}</td>
</tr> {{else}}
<tr class="tableRow inactive"> <tr class="tableRow">
<td>MotDit</td> <td>{{.Nom}}</td>
<td>N/A</td> <td>{{.Local}}</td>
<td>N/A</td> <td>{{.Poste}}</td>
<td class="organismeInactif">Inactif</td> <td class="organismeActif">{{.Statut}}</td>
{{end}}
</tr> </tr>
{{end}}
</table> </table>
<hr class="separator"> <hr class="separator">
<h2 class="heading2">Associations de programme</h2> {{end}}
<table class="table"> {{end}}
<tr class="tableRowHeading">
<td>Nom</td>
<td>Local</td>
<td>Poste</td>
<td>Statut</td>
</tr>
<tr class="tableRow">
<td>ADEPT</td>
<td>F-045</td>
<td>2286</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>ATIM</td>
<td>F-011b</td>
<td>N/A</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>LAC</td>
<td>A-125s</td>
<td>2873</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>PAPI</td>
<td>F-023</td>
<td>2795</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>TGE</td>
<td>C-063</td>
<td>2638</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow inactive">
<td>ASI</td>
<td>N/A</td>
<td>N/A</td>
<td class="organismeInactif">Inactif</td>
</tr>
<tr class="tableRow" inactive>
<td>ATEE</td>
<td>F-027d</td>
<td>N/A</td>
<td class="organismeActif">Actif</td>
</tr>
</table>
<hr class="separator">
<h2 class="heading2">Comités</h2>
<table class="table">
<tr class="tableRowHeading">
<td>Nom</td>
<td>Local</td>
<td>Poste</td>
<td>Statut</td>
</tr>
<tr class="tableRow">
<td>ASEG</td>
<td>B-06</td>
<td>N/A</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>CIC</td>
<td>F-027c</td>
<td>N/A</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>Comité Mob</td>
<td>N/A</td>
<td>N/A</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>ESPACE</td>
<td>F-011d</td>
<td>2418</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow">
<td>Friperie</td>
<td>F-027a</td>
<td>2248</td>
<td class="organismeActif">Actif</td>
</tr>
<tr class="tableRow inactive">
<td>CAP</td>
<td>N/A</td>
<td>N/A</td>
<td class="organismeInactif">Inactif</td>
</tr>
<tr class="tableRow inactive">
<td>CÉSI</td>
<td>N/A</td>
<td>N/A</td>
<td class="organismeInactif">Inactif</td>
</tr>
<tr class="tableRow inactive">
<td>CFEM</td>
<td>N/A</td>
<td>N/A</td>
<td class="organismeInactif">Inactif</td>
</tr>
<tr class="tableRow inactive">
<td>EUMC-CEM</td>
<td>N/A</td>
<td>N/A</td>
<td class="organismeInactif">Inactif</td>
</tr>
</table>
</div> </div>
<!-- {{ template "snackbar-html" }} --> <!-- {{ template "snackbar-html" }} -->
{{ template "footer-html" }} {{ template "footer-html" }}
</body> </body>
</html> </html>
{{ end }} {{ end }}