From ba096c0af10e75d3522b7d2f723b638c422349d1 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 7 Jun 2022 12:37:35 +0200 Subject: [PATCH] admin: Able to reset issues, QA and events --- admin/api/settings.go | 2 ++ admin/static/views/settings.html | 1 + libfic/reset.go | 24 ++++++++++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/admin/api/settings.go b/admin/api/settings.go index ae561157..7bb907ee 100644 --- a/admin/api/settings.go +++ b/admin/api/settings.go @@ -373,6 +373,8 @@ func reset(c *gin.Context) { err = fic.ResetExercices() case "game": err = fic.ResetGame() + case "annexes": + err = fic.ResetAnnexes() case "settings": err = ResetSettings() case "challengeInfo": diff --git a/admin/static/views/settings.html b/admin/static/views/settings.html index f288ee1e..060a8ca3 100644 --- a/admin/static/views/settings.html +++ b/admin/static/views/settings.html @@ -367,6 +367,7 @@ + diff --git a/libfic/reset.go b/libfic/reset.go index 0b7b2d6f..74e3f996 100644 --- a/libfic/reset.go +++ b/libfic/reset.go @@ -5,7 +5,7 @@ import ( ) // truncateTable performs an insecure wipe on the given tables. -func truncateTable(tables ...string) (error) { +func truncateTable(tables ...string) error { if tx, err := db.BeginTx(context.TODO(), nil); err != nil { return err } else { @@ -27,8 +27,20 @@ func truncateTable(tables ...string) (error) { return nil } +// ResetAnnexes resets all tables containing annexe info like events, claims and qa. +func ResetAnnexes() error { + return truncateTable( + "claim_descriptions", + "claims", + "events", + "qa_comments", + "teams_qa_todo", + "teams_qa_view", + ) +} + // ResetGame resets all tables containing team attempts and solves. -func ResetGame() (error) { +func ResetGame() error { return truncateTable( "team_wchoices", "team_hints", @@ -40,7 +52,7 @@ func ResetGame() (error) { } // ResetExercices wipes out all challenges (both attempts and statements). -func ResetExercices() (error) { +func ResetExercices() error { return truncateTable( "team_wchoices", "team_hints", @@ -55,6 +67,10 @@ func ResetExercices() (error) { "exercice_hints_okey_deps", "exercice_hints_omcq_deps", "flag_choices", + "exercice_flag_deps", + "exercice_flag_labels_omcq_deps", + "exercice_flag_labels_deps", + "exercice_flag_labels", "exercice_flags", "exercice_solved", "exercice_tries", @@ -69,7 +85,7 @@ func ResetExercices() (error) { } // ResetTeams wipes out all teams, incluings members and attempts. -func ResetTeams() (error) { +func ResetTeams() error { return truncateTable( "team_wchoices", "team_hints",