Datepickers on native time.Time / lagoon.Date fields, file uploads on materials, readings and class sessions managed from the course form (course_id made nullable).
51 lines
1.7 KiB
Go
51 lines
1.7 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. The files field
|
|
// is bound by models.Material.AttachRelations.
|
|
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{} }
|