Add unsubscribe-all flag
This commit is contained in:
parent
54f7971b16
commit
08dc821eb0
1 changed files with 14 additions and 0 deletions
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"git.andreafazzi.eu/andrea/oef/client"
|
||||
"git.andreafazzi.eu/andrea/oef/orm"
|
||||
|
@ -21,6 +22,7 @@ func main() {
|
|||
username := flag.String("username", "admin", "Username")
|
||||
password := flag.String("password", "admin", "Password")
|
||||
subscribe := flag.Bool("subscribe", true, "Subscribe to the given contest")
|
||||
unsubscribeAll := flag.Bool("unsubscribe-all", false, "Unsubscribe all participants from all contests")
|
||||
|
||||
juniorContestId := flag.Int("jid", 0, "Contest ID for Junior category")
|
||||
seniorContestId := flag.Int("sid", 0, "Contest ID for Senior category")
|
||||
|
@ -40,6 +42,18 @@ func main() {
|
|||
|
||||
var updated bool
|
||||
|
||||
if *unsubscribeAll {
|
||||
for _, participant := range participants {
|
||||
participant.ContestIDs = make(orm.ContestIDs, 0)
|
||||
id, err := client.Update(participant)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Successfully updated participant ID %d", id)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if *subscribe {
|
||||
for _, participant := range participants {
|
||||
for _, contest := range participant.Contests {
|
||||
|
|
Loading…
Reference in a new issue