Adopt SummerCMS v0.1.1 admin features

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).
This commit is contained in:
Jakub Zych
2026-10-03 06:03:34 +02:00
parent ac2e2ddd7b
commit 71b848a376
39 changed files with 475 additions and 373 deletions

View File

@@ -11,12 +11,12 @@ import (
// ClassSession is one block of classes (zajęcia) of a course.
type ClassSession struct {
ID uint `gorm:"column:id;primaryKey"`
CourseID uint `gorm:"column:course_id"`
CourseID *uint `gorm:"column:course_id"`
Course *Course `gorm:"foreignKey:CourseID"`
MeetingID *uint `gorm:"column:meeting_id"`
Meeting *Meeting `gorm:"foreignKey:MeetingID"`
StartsAt DateTime `gorm:"column:starts_at"`
EndsAt DateTime `gorm:"column:ends_at"`
StartsAt time.Time `gorm:"column:starts_at"`
EndsAt time.Time `gorm:"column:ends_at"`
Room *string `gorm:"column:room"`
Kind *string `gorm:"column:kind"`
Notes *string `gorm:"column:notes"`
@@ -45,12 +45,11 @@ func (ClassSession) Rules() map[string]string {
}
}
// TemporalErrors checks the timestamps, which lagoon.Validate cannot.
// TemporalErrors checks that the session ends after it starts, which
// lagoon.Validate cannot. The required rules cover missing times.
func (s *ClassSession) TemporalErrors() map[string][]string {
e := temporalErrors{}
e.dateTime("starts_at", s.StartsAt, true)
e.dateTime("ends_at", s.EndsAt, true)
if len(e) == 0 && !s.EndsAt.MustTime().After(s.StartsAt.MustTime()) {
if !s.StartsAt.IsZero() && !s.EndsAt.IsZero() && !s.EndsAt.After(s.StartsAt) {
e.add("ends_at", "The ends at must be a date after starts at.")
}
return e.result()