Export user credential by contest ID
This commit is contained in:
parent
9bb73c6059
commit
314603db64
3 changed files with 30 additions and 9 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,5 @@
|
|||
*~
|
||||
oef
|
||||
**/*.xlsx
|
||||
**/*.ods
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ func main() {
|
|||
username := flag.String("username", "admin", "Username")
|
||||
password := flag.String("password", "admin", "Password")
|
||||
output := flag.String("output", "credentials.csv", "Output filename")
|
||||
cid := flag.Uint("cid", 0, "Export credentials of participants subscribed to the given contest")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -38,9 +39,26 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
if user.Role == "participant" {
|
||||
credentials = append(credentials, &Credential{user.ID, user.Username, user.Password})
|
||||
if *cid != 0 {
|
||||
log.Printf("Get participants subscribed to contest ID %v", *cid)
|
||||
contest := new(orm.Contest)
|
||||
contest.ID = *cid
|
||||
_, err := client.Read(contest)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, participant := range contest.Participants {
|
||||
for _, user := range users {
|
||||
if user.ID == participant.UserID {
|
||||
credentials = append(credentials, &Credential{user.ID, user.Username, user.Password})
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, user := range users {
|
||||
if user.Role == "participant" {
|
||||
credentials = append(credentials, &Credential{user.ID, user.Username, user.Password})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
contests:
|
||||
- id: 22
|
||||
- id: 30
|
||||
category: Junior
|
||||
regions: [Basilicata,Calabria,Lombardia,Piemonte,Valle d'Aosta,Veneto]
|
||||
- id: 23
|
||||
- id: 31
|
||||
category: Senior
|
||||
regions: [Basilicata,Calabria,Lombardia,Piemonte,Valle d'Aosta,Veneto]
|
||||
- id: 26
|
||||
- id: 32
|
||||
category: Junior
|
||||
regions: [Campania,Emilia-Romagna,Friuli-Venezia Giulia,Liguria,Sardegna,Toscana,Trentino-Alto Adige]
|
||||
- id: 27
|
||||
- id: 33
|
||||
category: Senior
|
||||
regions: [Campania,Emilia-Romagna,Friuli-Venezia Giulia,Liguria,Sardegna,Toscana,Trentino-Alto Adige]
|
||||
- id: 28
|
||||
- id: 34
|
||||
category: Junior
|
||||
regions: [Abruzzo,Lazio,Marche,Molise,Puglia,Sicilia,Umbria]
|
||||
- id: 25
|
||||
- id: 35
|
||||
category: Senior
|
||||
regions: [Abruzzo,Lazio,Marche,Molise,Puglia,Sicilia,Umbria]
|
||||
|
|
Loading…
Reference in a new issue