Make some values non deletable

This commit is contained in:
Alex Auvolat 2020-02-10 09:54:33 +01:00
parent b194b5f7eb
commit 61a76f624d
2 changed files with 16 additions and 5 deletions

View File

@ -164,6 +164,7 @@ type PropValues struct {
Name string
Values []string
Editable bool
Deletable bool
}
func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
@ -342,10 +343,18 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
break
}
}
deletable := true
for _, restricted := range []string{ "displayname", "objectclass", "structuralobjectclass" } {
if strings.EqualFold(attr.Name, restricted) {
deletable = false
break
}
}
props[name_lower] = &PropValues{
Name: attr.Name,
Values: attr.Values,
Editable: editable,
Deletable: deletable,
}
}
}

View File

@ -76,11 +76,13 @@
</div>
<div class="col-md-1">
<form method="POST" onsubmit="return confirm('Supprimer cet attribut ?');">
<input type="hidden" name="action" value="delete" />
<input type="hidden" name="attr" value="{{$key}}" />
<input type="submit" value="Suppr." class="form-control btn btn-danger btn-sm" />
</form>
{{if $value.Deletable}}
<form method="POST" onsubmit="return confirm('Supprimer cet attribut ?');">
<input type="hidden" name="action" value="delete" />
<input type="hidden" name="attr" value="{{$key}}" />
<input type="submit" value="Suppr." class="form-control btn btn-danger btn-sm" />
</form>
{{end}}
</div>
</div>
{{end}}