Show grants on instance info page

This commit is contained in:
Tom Wiesing 2023-01-03 12:19:10 +01:00
parent 69b6579de7
commit dab7a5c4ae
No known key found for this signature in database
4 changed files with 69 additions and 1 deletions

View file

@ -176,8 +176,9 @@
</div> </div>
</div> </div>
<div class="pure-u-1-1"> <div class="pure-u-1-1">
<h2 id="wisski">Users</h2> <h2 id="wisski">(Drupal) Users</h2>
</div> </div>
<div class="pure-u-1"> <div class="pure-u-1">
@ -260,6 +261,47 @@
</div> </div>
</div> </div>
<div class="pure-u-1-1">
<h2 id="distillery">(Distillery) Users</h2>
</div>
<div class="pure-u-1">
<div class="padding">
<div class="overflow">
<table class="pure-table pure-table-bordered">
<thead>
<tr>
<th>
Distillery User
</th>
<th>
WissKI User
</th>
<th>
Admin
</th>
</tr>
</thead>
<tbody>
{{ range $index, $grant := .Info.Grants }}
<tr>
<td>
<code>{{ $grant.User }}</code>
</td>
<td>
<code>{{ $grant.DrupalUsername }}</code>
</td>
<td>
<code>{{ $grant.DrupalAdminRole }}</code>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</div>
</div>
<div class="pure-u-1-1"> <div class="pure-u-1-1">
<h2 id="wisski">WissKI Data</h2> <h2 id="wisski">WissKI Data</h2>
</div> </div>

View file

@ -37,6 +37,7 @@ type WissKI struct {
Prefixes []string // list of prefixes Prefixes []string // list of prefixes
Pathbuilders map[string]string // all the pathbuilders Pathbuilders map[string]string // all the pathbuilders
Users []User // all the known users Users []User // all the known users
Grants []models.Grant
} }
// Statistics holds statistics generated by the WissKI module // Statistics holds statistics generated by the WissKI module

View file

@ -0,0 +1,24 @@
package users
import (
"github.com/FAU-CDI/wisski-distillery/internal/status"
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
)
type UserPolicy struct {
ingredient.Base
}
var (
_ ingredient.WissKIFetcher = (*UserPolicy)(nil)
)
func (up *UserPolicy) Fetch(flags ingredient.FetcherFlags, target *status.WissKI) (err error) {
if flags.Quick {
return nil
}
// read the grants into the info struct
target.Grants, err = up.Malt.Policy.Instance(flags.Context, up.Slug)
return err
}

View file

@ -106,6 +106,7 @@ func (wisski *WissKI) allIngredients() []initFunc {
auto[*extras.Pathbuilder], auto[*extras.Pathbuilder],
auto[*extras.Stats], auto[*extras.Stats],
auto[*users.Users], auto[*users.Users],
auto[*users.UserPolicy],
// info // info
manual(func(info *info.Info) { manual(func(info *info.Info) {