Courses, meetings, class sessions, deadlines, readings with per-user progress, materials with tags and file attachments. Timestamps are stored in UTC and held as Europe/Warsaw text so the admin text inputs can write them.
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
// Code generated by summer make. DO NOT EDIT.
|
|
|
|
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Meeting is one zjazd: a weekend of classes of the part-time programme.
|
|
type Meeting struct {
|
|
ID uint `gorm:"column:id;primaryKey"`
|
|
Number int `gorm:"column:number"`
|
|
StartsOn Date `gorm:"column:starts_on"`
|
|
EndsOn Date `gorm:"column:ends_on"`
|
|
Notes *string `gorm:"column:notes"`
|
|
CreatedAt time.Time `gorm:"column:created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at"`
|
|
}
|
|
|
|
// TableName is the plugin table.
|
|
func (Meeting) TableName() string { return "jz_bm_meetings" }
|
|
|
|
// Fillable lists the columns mass assignment may set.
|
|
func (Meeting) Fillable() []string { return []string{"number", "starts_on", "ends_on", "notes"} }
|
|
|
|
// Rules are checked by the admin API on every save.
|
|
func (Meeting) Rules() map[string]string {
|
|
return map[string]string{
|
|
"number": "required|integer|min:1|unique:jz_bm_meetings",
|
|
"starts_on": "required",
|
|
"ends_on": "required",
|
|
}
|
|
}
|
|
|
|
// TemporalErrors checks the dates, which lagoon.Validate cannot.
|
|
func (m *Meeting) TemporalErrors() map[string][]string {
|
|
e := temporalErrors{}
|
|
e.date("starts_on", m.StartsOn, true)
|
|
e.date("ends_on", m.EndsOn, true)
|
|
if len(e) == 0 && m.EndsOn < m.StartsOn {
|
|
e.add("ends_on", "The ends on must be a date after or equal to starts on.")
|
|
}
|
|
return e.result()
|
|
}
|
|
|
|
// BeforeSave stores NULL for empty optional text.
|
|
func (m *Meeting) BeforeSave(*gorm.DB) error {
|
|
blank(&m.Notes)
|
|
return nil
|
|
}
|