feat: Organisations admin screen with the avatar and the members manager
- controller golem15.user.organisations behind golem15.users.access_users - list and form (name, slug preset from the name, description, avatar) - members relation manager: link sets and unlink clears users.organisation_id - deleting an organisation releases its members first - Organisation gains Fillable, Rules, MorphName, AttachRelations, BeforeValidate and the Members relation; models.Slugify - navigation side item organisations - TestAdminOrganisations, TestAdminOrganisationMembers, TestSlugify
This commit is contained in:
26
models/slug.go
Normal file
26
models/slug.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package models
|
||||
|
||||
import "strings"
|
||||
|
||||
// Slugify turns text into a slug by the rule the admin form's slug preset
|
||||
// uses: lower-case ASCII letters and digits are kept, every run of other
|
||||
// characters becomes one hyphen, and there is no hyphen at either end.
|
||||
// Letters outside ASCII are not transliterated; they count as other
|
||||
// characters. A text without a letter or digit gives the empty string.
|
||||
func Slugify(text string) string {
|
||||
var b strings.Builder
|
||||
b.Grow(len(text))
|
||||
gap := false
|
||||
for _, r := range strings.ToLower(text) {
|
||||
if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') {
|
||||
if gap && b.Len() > 0 {
|
||||
b.WriteByte('-')
|
||||
}
|
||||
gap = false
|
||||
b.WriteRune(r)
|
||||
continue
|
||||
}
|
||||
gap = true
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
Reference in New Issue
Block a user