lista_utenti: add rappresentanti to the user tags.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
["berni", "budacuferrari", "delucreziis", "butori", "cecchi", "diprisa", "gambicchia", "lamanna", "morganti", "numero", "piazza", "pignatelli", "pratali", "talluri", "tanzini"]
|
||||
+8
-3
@@ -1,4 +1,4 @@
|
||||
{{template "base" .}}
|
||||
{{template "base" .}}
|
||||
{{define "title"}}Utenti • PHC{{end}}
|
||||
{{define "body"}}
|
||||
<script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||
@@ -37,8 +37,8 @@
|
||||
<template x-for="entry in searchResults" :key="entry.item.uid">
|
||||
<div class="user-item card">
|
||||
<a class="full-name" :href="'{{ $.Config.UserPagesBaseUrl }}' + entry.item.uid" x-text="
|
||||
sortMode === 'surname' ?
|
||||
entry.item.cognome + ' ' + entry.item.nome :
|
||||
sortMode === 'surname' ?
|
||||
entry.item.cognome + ' ' + entry.item.nome :
|
||||
entry.item.nome + ' ' + entry.item.cognome
|
||||
"></a>
|
||||
<template x-if="entry.item.tags?.includes('macchinista')">
|
||||
@@ -46,6 +46,11 @@
|
||||
<i class="fas fa-wrench"></i>
|
||||
</div>
|
||||
</template>
|
||||
<template x-if="entry.item.tags?.includes('rappresentante')">
|
||||
<div class="icon" title="Rappresentante">
|
||||
<i class="fas fa-landmark"></i>
|
||||
</div>
|
||||
</template>
|
||||
<!-- <template x-if="entry.score">
|
||||
<span x-text="entry.score"></span>
|
||||
</template> -->
|
||||
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
type jsonListaUtenti struct {
|
||||
Path string
|
||||
|
||||
Macchinisti util.Set[string]
|
||||
Macchinisti util.Set[string]
|
||||
Rappresentanti util.Set[string]
|
||||
}
|
||||
|
||||
func newJsonListaUtenti(path string) (Service, error) {
|
||||
@@ -20,8 +21,12 @@ func newJsonListaUtenti(path string) (Service, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rappresentanti, err := loadRappresentanti()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &jsonListaUtenti{path, macchinisti}, nil
|
||||
return &jsonListaUtenti{path, macchinisti, rappresentanti}, nil
|
||||
}
|
||||
|
||||
func (j *jsonListaUtenti) GetUtenti() ([]*model.ListUser, error) {
|
||||
@@ -37,6 +42,7 @@ func (j *jsonListaUtenti) GetUtenti() ([]*model.ListUser, error) {
|
||||
}
|
||||
|
||||
mergeMacchinisti(users, j.Macchinisti)
|
||||
mergeRappresentanti(users, j.Rappresentanti)
|
||||
|
||||
log.Printf("Caricata lista di %d utenti", len(users))
|
||||
|
||||
|
||||
@@ -44,3 +44,26 @@ func mergeMacchinisti(users []*model.ListUser, macchinisti util.Set[string]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func loadRappresentanti() (util.Set[string], error) {
|
||||
f, err := os.Open("_content/rappresentanti.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rappresentanti := []string{}
|
||||
|
||||
if err := json.NewDecoder(f).Decode(&rappresentanti); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return util.NewSet(rappresentanti...), nil
|
||||
}
|
||||
|
||||
func mergeRappresentanti(users []*model.ListUser, rappresentanti util.Set[string]) {
|
||||
for _, user := range users {
|
||||
if _, found := rappresentanti[user.Uid]; found {
|
||||
user.Tags = append(user.Tags, "rappresentante")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user