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

@@ -17,24 +17,6 @@ type temporalErrors map[string][]string
func (e temporalErrors) add(field, msg string) { e[field] = append(e[field], msg) }
func (e temporalErrors) dateTime(field string, v DateTime, required bool) {
switch {
case v == "" && required:
e.add(field, "The "+strings.ReplaceAll(field, "_", " ")+" field is required.")
case v != "" && !v.Valid():
e.add(field, "The "+strings.ReplaceAll(field, "_", " ")+" must be a date and time such as 2026-10-03 08:00.")
}
}
func (e temporalErrors) date(field string, v Date, required bool) {
switch {
case v == "" && required:
e.add(field, "The "+strings.ReplaceAll(field, "_", " ")+" field is required.")
case v != "" && !v.Valid():
e.add(field, "The "+strings.ReplaceAll(field, "_", " ")+" must be a date in the YYYY-MM-DD form.")
}
}
func (e temporalErrors) result() map[string][]string {
if len(e) == 0 {
return nil
@@ -42,9 +24,9 @@ func (e temporalErrors) result() map[string][]string {
return e
}
// TemporalValidator is implemented by models with Date or DateTime columns.
// The admin controllers call it before a save, because lagoon.Validate has
// no date rules.
// TemporalValidator is implemented by models whose dates must be in order.
// The admin controllers call it before a save, because lagoon.Validate
// cannot compare two fields.
type TemporalValidator interface {
TemporalErrors() map[string][]string
}