feat: manage a user's groups from the user form, privileged groups locked
- groups relation field on the user form, the only writer of users_groups - UsersGroup pivot model - AdminRelationLocks: adding or removing a group whose code is in golem15.user.privileged_groups needs golem15.users.manage_privileged_groups, on create and on update; refused saves answer 403 and write nothing - TestAdminUserGroupsField and TestAdminPrivilegedGroups
This commit is contained in:
@@ -35,6 +35,12 @@ fields:
|
||||
span: right
|
||||
tab: golem15.user::lang.user.account
|
||||
context: [create, update]
|
||||
groups:
|
||||
label: golem15.user::lang.user.groups
|
||||
type: relation
|
||||
span: full
|
||||
emptyOption: golem15.user::lang.user.empty_groups
|
||||
tab: golem15.user::lang.user.account
|
||||
organisation:
|
||||
label: golem15.user::lang.organisation.label
|
||||
type: relation
|
||||
|
||||
17
models/users_group.go
Normal file
17
models/users_group.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package models
|
||||
|
||||
// UsersGroup is one row of users_groups, the pivot behind User.Groups: the
|
||||
// user is a member of the group. The table has exactly these two columns and
|
||||
// a composite primary key over them. The admin user form's groups field is
|
||||
// its only writer, apart from the cleanup of a permanently deleted user or
|
||||
// group.
|
||||
type UsersGroup struct {
|
||||
UserID uint `gorm:"column:user_id;primaryKey"`
|
||||
UserGroupID uint `gorm:"column:user_group_id;primaryKey"`
|
||||
}
|
||||
|
||||
func (UsersGroup) TableName() string { return "users_groups" }
|
||||
|
||||
func init() {
|
||||
Register(UsersGroup{})
|
||||
}
|
||||
Reference in New Issue
Block a user