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

@@ -4,6 +4,7 @@ import (
"context"
"errors"
"testing"
"time"
"git.golem15.com/golem15/summercms/modules/cabana"
"git.golem15.com/jakub/sm-bm-plugin/models"
@@ -11,7 +12,8 @@ import (
func TestTemporalHooksAnswerOnTheField(t *testing.T) {
var hooks temporalHooks
bad := &models.ClassSession{StartsAt: "2026-10-03 08:00", EndsAt: "wtorek"}
at := func(h, m int) time.Time { return time.Date(2026, 10, 3, h, m, 0, 0, models.Location) }
bad := &models.ClassSession{StartsAt: at(8, 0), EndsAt: at(7, 0)}
for name, fn := range map[string]func(context.Context, any) error{
"create": hooks.FormBeforeCreate,
"update": hooks.FormBeforeUpdate,
@@ -25,7 +27,7 @@ func TestTemporalHooksAnswerOnTheField(t *testing.T) {
t.Errorf("%s: details %v name no ends_at", name, ve.Details)
}
}
good := &models.ClassSession{StartsAt: "2026-10-03 08:00", EndsAt: "2026-10-03 09:30"}
good := &models.ClassSession{StartsAt: at(8, 0), EndsAt: at(9, 30)}
if err := hooks.FormBeforeCreate(context.Background(), good); err != nil {
t.Errorf("valid session: %v", err)
}