admin: Able to reset issues, QA and events

This commit is contained in:
nemunaire 2022-06-07 12:37:35 +02:00
parent 9a2fd85d57
commit ba096c0af1
3 changed files with 23 additions and 4 deletions

View File

@ -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":

View File

@ -367,6 +367,7 @@
<button ng-click="reset('challenges')" class="btn btn-secondary mt-2 mb-1" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Effacer les challenges et les thèmes</button>
<button ng-click="reset('teams');" class="btn btn-secondary mt-1 mb-1" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Effacer les équipes</button>
<button ng-click="reset('game');" class="btn btn-secondary mt-1 mb-2" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Effacer la partie (tentatives, indices, ...)</button>
<button ng-click="reset('annexes');" class="btn btn-secondary mt-1 mb-2" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Effacer les annexes (events, issues, QA)</button>
</div>
</div>

View File

@ -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",