Per-user checklists with items that may link a course, reading, deadline, material or own presentation deck. An item with a reading shares the reading's read mark. Student API routes with token twins, MCP tools, migrations, tests and README.
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Checklist is a user's own list of things to do, usually the preparation
|
|
// for one zjazd. Only its owner (a golem15.user users row) sees it.
|
|
type Checklist struct {
|
|
ID uint `gorm:"column:id;primaryKey"`
|
|
UserID uint `gorm:"column:user_id"`
|
|
MeetingID *uint `gorm:"column:meeting_id"`
|
|
Meeting *Meeting `gorm:"foreignKey:MeetingID"`
|
|
Title string `gorm:"column:title"`
|
|
Description *string `gorm:"column:description"`
|
|
SortOrder int `gorm:"column:sort_order"`
|
|
CreatedAt time.Time `gorm:"column:created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at"`
|
|
}
|
|
|
|
// TableName is the plugin table.
|
|
func (Checklist) TableName() string { return "jz_bm_checklists" }
|
|
|
|
// Fillable lists the columns the student API may set; user_id comes from
|
|
// the caller.
|
|
func (Checklist) Fillable() []string {
|
|
return []string{"meeting_id", "title", "description", "sort_order"}
|
|
}
|
|
|
|
// Rules are checked by the student API on every save.
|
|
func (Checklist) Rules() map[string]string {
|
|
return map[string]string{
|
|
"title": "required|max:255",
|
|
"description": "nullable|max:10000",
|
|
"sort_order": "nullable|integer",
|
|
}
|
|
}
|
|
|
|
// BeforeSave stores NULL for empty optional text.
|
|
func (c *Checklist) BeforeSave(*gorm.DB) error {
|
|
blank(&c.Description)
|
|
return nil
|
|
}
|