Пример #1
0
func FieldNorm(field string) string {
	fparts := strings.Split(field, ".")

	for i := range fparts {
		fparts[i] = slug.SlugAscii(fparts[i])
	}

	return strings.Join(fparts, ".")
}
Пример #2
0
// Group adds a model group to the admin front page.
// Use this to organize your models.
func (a *Admin) Group(name string) (*modelGroup, error) {
	if a.models == nil {
		return nil, errors.New("Must call .Serve() before adding groups and registering models")
	}

	group := &modelGroup{
		admin:  a,
		Name:   name,
		slug:   slug.SlugAscii(name),
		Models: []*model{},
	}

	a.modelGroups = append(a.modelGroups, group)

	return group, nil
}