Merge pull request 'Générer table des organismes à partir d'un fichier json' (#231) from vlbeaudoin/templating-embedded-yaml-organismes into main
Reviewed-on: #231
This commit is contained in:
commit
6423a1fc34
4 changed files with 83 additions and 182 deletions
|
@ -2,6 +2,7 @@ package agecemorg
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
|
@ -11,6 +12,7 @@ import (
|
|||
|
||||
"codeberg.org/vlbeaudoin/pave/v2"
|
||||
"codeberg.org/vlbeaudoin/voki/v3"
|
||||
"git.agecem.com/agecem/agecem-org/v3/ui"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/minio/minio-go/v7"
|
||||
)
|
||||
|
@ -590,7 +592,24 @@ func HandleActualiteArticle(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 {
|
||||
|
|
5
ui/ui.go
5
ui/ui.go
|
@ -19,6 +19,11 @@ import (
|
|||
//go:embed *.html
|
||||
var htmlFS embed.FS
|
||||
|
||||
//go:embed vie-etudiante-organismes.json
|
||||
var organismesJSON string
|
||||
|
||||
func OrganismesJSON() string { return organismesJSON }
|
||||
|
||||
type Renderer struct {
|
||||
templates *template.Template
|
||||
}
|
||||
|
|
34
ui/vie-etudiante-organismes.json
Normal file
34
ui/vie-etudiante-organismes.json
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"Associations de programme": [
|
||||
{ "Nom": "ADEPT", "Local": "F-045", "Poste": "2286", "Statut": "Actif" },
|
||||
{ "Nom": "ASI", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" },
|
||||
{ "Nom": "ATEE", "Local": "F-027d", "Poste": "N/A", "Statut": "Actif" },
|
||||
{ "Nom": "ATIM", "Local": "F-011b", "Poste": "N/A", "Statut": "Actif" },
|
||||
{ "Nom": "LAC", "Local": "A-125s", "Poste": "2873", "Statut": "Actif" },
|
||||
{ "Nom": "PAPI", "Local": "F-023", "Poste": "2795", "Statut": "Actif" },
|
||||
{ "Nom": "TGE", "Local": "C-063", "Poste": "2638", "Statut": "Actif" }
|
||||
],
|
||||
"Comités": [
|
||||
{ "Nom": "ASEG", "Local": "B-06", "Poste": "N/A", "Statut": "Actif" },
|
||||
{ "Nom": "CAP", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" },
|
||||
{ "Nom": "CFEM", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" },
|
||||
{ "Nom": "CIC", "Local": "F-027c", "Poste": "N/A", "Statut": "Actif" },
|
||||
{ "Nom": "Comité Mob", "Local": "N/A", "Poste": "N/A", "Statut": "Actif" },
|
||||
{ "Nom": "CÉSI", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" },
|
||||
{ "Nom": "ESPACE", "Local": "F-011d", "Poste": "2418", "Statut": "Actif" },
|
||||
{ "Nom": "EUMC-CEM", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" },
|
||||
{ "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" }
|
||||
]
|
||||
}
|
|
@ -13,7 +13,12 @@
|
|||
{{ template "header-html" }}
|
||||
<div class="wrapper vieEtudianteWrapper">
|
||||
<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">
|
||||
<tr class="tableRowHeading">
|
||||
<td>Nom</td>
|
||||
|
@ -21,193 +26,31 @@
|
|||
<td>Poste</td>
|
||||
<td>Statut</td>
|
||||
</tr>
|
||||
<tr class="tableRow">
|
||||
<td>AME</td>
|
||||
<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>
|
||||
{{range $organismes}}
|
||||
{{if eq .Statut "Inactif"}}
|
||||
<tr class="tableRow inactive">
|
||||
<td>SOI</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td class="organismeInactif">Inactif</td>
|
||||
</tr>
|
||||
<tr class="tableRow inactive">
|
||||
<td>MotDit</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td class="organismeInactif">Inactif</td>
|
||||
<td>{{.Nom}}</td>
|
||||
<td>{{.Local}}</td>
|
||||
<td>{{.Poste}}</td>
|
||||
<td class="organismeInactif">{{.Statut}}</td>
|
||||
{{else}}
|
||||
<tr class="tableRow">
|
||||
<td>{{.Nom}}</td>
|
||||
<td>{{.Local}}</td>
|
||||
<td>{{.Poste}}</td>
|
||||
<td class="organismeActif">{{.Statut}}</td>
|
||||
{{end}}
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
<hr class="separator">
|
||||
<h2 class="heading2">Associations de programme</h2>
|
||||
<table class="table">
|
||||
<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>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
</div>
|
||||
<!-- {{ template "snackbar-html" }} -->
|
||||
{{ template "footer-html" }}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Add table
Reference in a new issue