Merge branch 'master' into production
This commit is contained in:
commit
b160e3e63e
5 changed files with 82 additions and 3 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.9.9-88-g746f075-production
|
||||
0.9.9-93-gd373f71-master
|
||||
|
|
5
scripts/export_credentials/.gitignore
vendored
Normal file
5
scripts/export_credentials/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
test_credentials
|
||||
*.csv
|
||||
*.xlsx
|
||||
export_credentials
|
||||
|
55
scripts/export_credentials/main.go
Normal file
55
scripts/export_credentials/main.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"git.andreafazzi.eu/andrea/oef/client"
|
||||
"git.andreafazzi.eu/andrea/oef/orm"
|
||||
"github.com/gocarina/gocsv"
|
||||
)
|
||||
|
||||
type Credential struct {
|
||||
ID uint
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
func main() {
|
||||
username := flag.String("username", "admin", "Username")
|
||||
password := flag.String("password", "admin", "Password")
|
||||
output := flag.String("output", "rank.csv", "Output filename")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
client, err := client.Dial(flag.Arg(0), *username, *password)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
users := make([]*orm.User, 0)
|
||||
credentials := make([]*Credential, 0)
|
||||
|
||||
log.Println("Get all users...")
|
||||
|
||||
err = client.ReadAll(&users)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
if user.Role == "participant" {
|
||||
credentials = append(credentials, &Credential{user.ID, user.Username, user.Password})
|
||||
}
|
||||
}
|
||||
|
||||
f, err := os.Create(*output)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
gocsv.MarshalFile(credentials, f)
|
||||
|
||||
}
|
|
@ -78,6 +78,7 @@ func main() {
|
|||
password := flag.String("password", "admin", "Password")
|
||||
output := flag.String("output", "rank.csv", "Output filename")
|
||||
contestId := flag.Int("id", 0, "Contest ID")
|
||||
all := flag.Bool("all", false, "Rank all participants")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -119,7 +120,7 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
if r.Score > 0 && r.Duration > 0 {
|
||||
if r.Score > 0 && r.Duration > 0 && !*all {
|
||||
school, err := findSchool(schools, r.Participant.SchoolID)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -136,6 +137,24 @@ func main() {
|
|||
Duration: uint(r.Duration / time.Second),
|
||||
},
|
||||
)
|
||||
} else {
|
||||
school, err := findSchool(schools, r.Participant.SchoolID)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
csvResponses = append(
|
||||
csvResponses,
|
||||
&Response{
|
||||
Firstname: r.Participant.Firstname,
|
||||
Lastname: r.Participant.Lastname,
|
||||
FiscalCode: r.Participant.FiscalCode,
|
||||
School: school.String(),
|
||||
Region: school.Region.String(),
|
||||
Score: r.Score,
|
||||
Duration: uint(r.Duration / time.Second),
|
||||
},
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
{{- if $isSchool}}{{$homeURL = "#"}}{{end -}}
|
||||
<a class="navbar-brand" {{if $isAdmin}}href="{{$homeURL}}"{{end}}>
|
||||
<span class="fa fa-landmark"></span>
|
||||
OEF 2021
|
||||
OIEF 2021
|
||||
</a>
|
||||
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
|
|
Loading…
Reference in a new issue