No default students

This commit is contained in:
Ian Gulliver
2020-09-14 23:25:08 +00:00
parent fb96bfe27b
commit 8c9035dc30
3 changed files with 23 additions and 14 deletions

View File

@@ -40,7 +40,7 @@ func (c Class) tagsMatch(t time.Time) bool {
return true
}
func (c Class) buildEvent(t time.Time) *calendar.Event {
func (c Class) buildEvent(t time.Time) (*calendar.Event, error) {
dateStr := t.Format("2006-01-02")
ev := &calendar.Event{
@@ -56,12 +56,11 @@ func (c Class) buildEvent(t time.Time) *calendar.Event {
Attendees: []*calendar.EventAttendee{},
}
attendees := c.Students
if len(attendees) == 0 {
attendees = allStudents
if len(c.Students) == 0 {
return nil, fmt.Errorf("class with no students: %s", c.Summary)
}
for _, student := range attendees {
for _, student := range c.Students {
ev.Attendees = append(
ev.Attendees,
&calendar.EventAttendee{
@@ -74,5 +73,5 @@ func (c Class) buildEvent(t time.Time) *calendar.Event {
ev.Description = fmt.Sprintf(`Zoom: %s`, c.Zoom)
}
return ev
return ev, nil
}