Merge branch 'master' of ssh://git.andreafazzi.eu:10022/andrea/oef

This commit is contained in:
Andrea Fazzi 2022-03-16 08:59:00 +01:00
commit d27d48a204
3 changed files with 10 additions and 6 deletions

View file

@ -111,11 +111,11 @@ func (model *Participant) exists(db *Database) (*User, error) {
if err := db._db.First(&user, &User{Username: model.username()}).Error; err != nil && err != gorm.ErrRecordNotFound {
return nil, err
} else if err == gorm.ErrRecordNotFound {
log.Printf("User %s doesn't exist", user)
log.Printf("User %s doesn't exist", user.Username)
return nil, nil
}
log.Printf("User %s exists", user)
log.Printf("User %s exists", user.Username)
return &user, nil
}
@ -219,7 +219,7 @@ func (model *Participant) Create(db *Database, args map[string]string, w http.Re
if err := db._db.First(&school, participant.SchoolID).Error; err != nil {
return nil, err
}
log.Printf("Check if a participant of the same category exists for school %s", school)
log.Printf("Check if a participant of the same category exists for school %s", school.Name)
hasCategory, err := school.HasCategory(db, participant)
if err != nil {
return nil, err
@ -321,6 +321,7 @@ func (model *Participant) ReadAll(db *Database, args map[string]string, w http.R
}
if err := db._db.
Preload("Category").
Preload("School.Region").
Preload("School").
Preload("Contests").
Order("lastname").
@ -331,6 +332,7 @@ func (model *Participant) ReadAll(db *Database, args map[string]string, w http.R
if err := db._db.
Preload("Category").
Preload("School").
Preload("School.Region").
Preload("Contests").
Preload("Responses").
Order("created_at").Find(&participants).Error; err != nil {

View file

@ -69,8 +69,8 @@ type School struct {
SelectedRegion map[uint]string `gorm:"-"`
AllRegions []*Region `gorm:"-"`
CaptchaID string `gorm:"-",schema:"-"`
CaptchaSolution string `gorm:"-",schema:"-"`
CaptchaID string `gorm:"-" schema:"-"`
CaptchaSolution string `gorm:"-" schema:"-"`
mailSender *mail.MailSender
}

View file

@ -1,2 +1,4 @@
*.csv
*.xlsx
*.xlsx
export_participants