Seven admin controllers in a "Studia BM" navigation group, guarded by jz.bm.access_courses, jz.bm.access_schedule and jz.bm.access_materials, with Polish and English labels. Date and time fields are checked by the models before a save and answered as 422 on the field.
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
// Code generated by summer make. DO NOT EDIT.
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"git.golem15.com/golem15/summercms/modules/cabana"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
"git.golem15.com/jakub/sm-bm-plugin/models"
|
|
)
|
|
|
|
var (
|
|
_ pact.AdminController = materialsAdmin{}
|
|
_ pact.AdminRecordSource = materialsAdmin{}
|
|
_ pact.AdminPermissioned = materialsAdmin{}
|
|
)
|
|
|
|
// materialsAdmin is the admin controller for materials.
|
|
type materialsAdmin struct{ temporalHooks }
|
|
|
|
func (materialsAdmin) ID() string { return "jz.bm.materials" }
|
|
func (materialsAdmin) ModelName() string { return "Material" }
|
|
func (materialsAdmin) ConfigDir() string { return "controllers/materials" }
|
|
|
|
// NewRecord returns the model the generic admin handlers query and fill.
|
|
func (materialsAdmin) NewRecord() any { return &models.Material{} }
|
|
|
|
// RequiredPermissions is checked before any schema or record is served.
|
|
func (materialsAdmin) RequiredPermissions() []string {
|
|
return []string{PermMaterials}
|
|
}
|
|
|
|
// AdminFieldRelations binds the course picker and the tags.
|
|
//
|
|
// TODO: requires SummerCMS change. Materials carry their files as
|
|
// system_files attachments (field "files"), but cabana has no file upload
|
|
// form widget, so files are attached outside the admin form for now.
|
|
func (materialsAdmin) AdminFieldRelations() []cabana.FieldRelationContract {
|
|
return []cabana.FieldRelationContract{
|
|
courseRelation("course_id"),
|
|
{
|
|
Field: "tags",
|
|
Kind: "belongsToMany",
|
|
NewRelated: func() any { return &models.Tag{} },
|
|
NewPivot: func() any { return &models.MaterialTag{} },
|
|
ParentForeignKey: "material_id",
|
|
RelatedForeignKey: "tag_id",
|
|
LabelColumn: "name",
|
|
},
|
|
}
|
|
}
|
|
|
|
// MaterialsController returns the jz.bm.materials admin controller.
|
|
func MaterialsController() pact.AdminController { return materialsAdmin{} }
|