Files
sm-bm-plugin/models/deadline.go
Jakub Zych 1046237771 feat: add the study data models and schema migrations
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.
2026-10-02 14:26:08 +02:00

57 lines
1.7 KiB
Go

// Code generated by summer make. DO NOT EDIT.
package models
import (
"time"
"gorm.io/gorm"
)
// DeadlineKinds lists the allowed Deadline.Kind values.
var DeadlineKinds = []string{"zaliczenie", "egzamin", "praca", "organizacyjne", "inne"}
// Deadline is one entry of the terminarz: an exam, a submission or an
// administrative date, optionally tied to a course.
type Deadline struct {
ID uint `gorm:"column:id;primaryKey"`
Title string `gorm:"column:title"`
DueAt DateTime `gorm:"column:due_at"`
CourseID *uint `gorm:"column:course_id"`
Course *Course `gorm:"foreignKey:CourseID"`
Kind string `gorm:"column:kind"`
Description *string `gorm:"column:description"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
// TableName is the plugin table.
func (Deadline) TableName() string { return "jz_bm_deadlines" }
// Fillable lists the columns mass assignment may set.
func (Deadline) Fillable() []string {
return []string{"title", "due_at", "course_id", "kind", "description"}
}
// Rules are checked by the admin API on every save.
func (Deadline) Rules() map[string]string {
return map[string]string{
"title": "required|max:255",
"due_at": "required",
"kind": "required|in:zaliczenie,egzamin,praca,organizacyjne,inne",
}
}
// TemporalErrors checks the due time, which lagoon.Validate cannot.
func (d *Deadline) TemporalErrors() map[string][]string {
e := temporalErrors{}
e.dateTime("due_at", d.DueAt, true)
return e.result()
}
// BeforeSave stores NULL for empty optional text.
func (d *Deadline) BeforeSave(*gorm.DB) error {
blank(&d.Description)
return nil
}