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:
@@ -69,7 +69,7 @@ func BuildCalendar(data CalendarData, opt CalendarOptions) []byte {
|
||||
w.Prop("REFRESH-INTERVAL;VALUE=DURATION", "PT6H")
|
||||
w.Prop("X-PUBLISHED-TTL", "PT6H")
|
||||
for _, s := range data.Sessions {
|
||||
if excluded[s.CourseID] {
|
||||
if s.CourseID == nil || excluded[*s.CourseID] {
|
||||
continue
|
||||
}
|
||||
writeSession(&w, s, opt.SiteURL)
|
||||
@@ -129,8 +129,8 @@ func writeSession(w *ICS, s models.ClassSession, siteURL string) {
|
||||
w.Prop("UID", uid("session", s.ID))
|
||||
stamp(w, s.UpdatedAt)
|
||||
w.Prop("SEQUENCE", "0")
|
||||
w.UTC("DTSTART", s.StartsAt.MustTime())
|
||||
w.UTC("DTEND", s.EndsAt.MustTime())
|
||||
w.UTC("DTSTART", s.StartsAt)
|
||||
w.UTC("DTEND", s.EndsAt)
|
||||
w.Text("SUMMARY", SessionSummary(s))
|
||||
switch {
|
||||
case s.IsOnline:
|
||||
@@ -152,7 +152,7 @@ func writeSession(w *ICS, s models.ClassSession, siteURL string) {
|
||||
lines = append(lines, "Przedmiot do wyboru")
|
||||
}
|
||||
if siteURL != "" {
|
||||
link := siteURL + "/przedmioty/" + strconv.FormatUint(uint64(s.CourseID), 10)
|
||||
link := siteURL + "/przedmioty/" + strconv.FormatUint(uint64(*s.CourseID), 10)
|
||||
lines = append(lines, link)
|
||||
w.Prop("URL", link)
|
||||
}
|
||||
@@ -180,12 +180,13 @@ func MeetingSummary(m models.Meeting) string {
|
||||
}
|
||||
|
||||
func writeMeeting(w *ICS, m models.Meeting) {
|
||||
start, err := m.StartsOn.Time()
|
||||
if err != nil {
|
||||
if m.StartsOn.IsZero() {
|
||||
return
|
||||
}
|
||||
end, err := m.EndsOn.Time()
|
||||
if err != nil || end.Before(start) {
|
||||
// Midnight UTC keeps the calendar date for w.Date.
|
||||
start := m.StartsOn.Time(nil)
|
||||
end := m.EndsOn.Time(nil)
|
||||
if m.EndsOn.IsZero() || end.Before(start) {
|
||||
end = start
|
||||
}
|
||||
w.Begin("VEVENT")
|
||||
@@ -204,8 +205,8 @@ func writeMeeting(w *ICS, m models.Meeting) {
|
||||
}
|
||||
|
||||
func writeDeadline(w *ICS, d models.Deadline) {
|
||||
due, err := d.DueAt.Time()
|
||||
if err != nil {
|
||||
due := d.DueAt
|
||||
if due.IsZero() {
|
||||
return
|
||||
}
|
||||
summary := "Termin: " + d.Title
|
||||
|
||||
Reference in New Issue
Block a user