// Code generated by summer make. DO NOT EDIT. package controllers import ( usermodels "git.golem15.com/golem15/sm-user-plugin/models" "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 and meeting pickers, the tags, the // author picker and the users a private material is shared with. The // author column is author_user_id, not user_id, which the backend refuses // to fill from a body. The files field is bound by // models.Material.AttachRelations. func (materialsAdmin) AdminFieldRelations() []cabana.FieldRelationContract { return []cabana.FieldRelationContract{ courseRelation("course_id"), meetingRelation(), { Field: "tags", Kind: "belongsToMany", NewRelated: func() any { return &models.Tag{} }, NewPivot: func() any { return &models.MaterialTag{} }, ParentForeignKey: "material_id", RelatedForeignKey: "tag_id", LabelColumn: "name", }, { Field: "author", Kind: "belongsTo", NewRelated: func() any { return &usermodels.User{} }, ForeignKey: "author_user_id", LabelColumn: "email", }, { Field: "shared_with", Kind: "belongsToMany", NewRelated: func() any { return &usermodels.User{} }, NewPivot: func() any { return &models.MaterialShare{} }, ParentForeignKey: "material_id", RelatedForeignKey: "user_id", LabelColumn: "email", }, } } // MaterialsController returns the jz.bm.materials admin controller. func MaterialsController() pact.AdminController { return materialsAdmin{} }