admin: Able to reset issues, QA and events
This commit is contained in:
parent
9a2fd85d57
commit
ba096c0af1
@ -373,6 +373,8 @@ func reset(c *gin.Context) {
|
|||||||
err = fic.ResetExercices()
|
err = fic.ResetExercices()
|
||||||
case "game":
|
case "game":
|
||||||
err = fic.ResetGame()
|
err = fic.ResetGame()
|
||||||
|
case "annexes":
|
||||||
|
err = fic.ResetAnnexes()
|
||||||
case "settings":
|
case "settings":
|
||||||
err = ResetSettings()
|
err = ResetSettings()
|
||||||
case "challengeInfo":
|
case "challengeInfo":
|
||||||
|
@ -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('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('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('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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// truncateTable performs an insecure wipe on the given tables.
|
// 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 {
|
if tx, err := db.BeginTx(context.TODO(), nil); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
@ -27,8 +27,20 @@ func truncateTable(tables ...string) (error) {
|
|||||||
return nil
|
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.
|
// ResetGame resets all tables containing team attempts and solves.
|
||||||
func ResetGame() (error) {
|
func ResetGame() error {
|
||||||
return truncateTable(
|
return truncateTable(
|
||||||
"team_wchoices",
|
"team_wchoices",
|
||||||
"team_hints",
|
"team_hints",
|
||||||
@ -40,7 +52,7 @@ func ResetGame() (error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ResetExercices wipes out all challenges (both attempts and statements).
|
// ResetExercices wipes out all challenges (both attempts and statements).
|
||||||
func ResetExercices() (error) {
|
func ResetExercices() error {
|
||||||
return truncateTable(
|
return truncateTable(
|
||||||
"team_wchoices",
|
"team_wchoices",
|
||||||
"team_hints",
|
"team_hints",
|
||||||
@ -55,6 +67,10 @@ func ResetExercices() (error) {
|
|||||||
"exercice_hints_okey_deps",
|
"exercice_hints_okey_deps",
|
||||||
"exercice_hints_omcq_deps",
|
"exercice_hints_omcq_deps",
|
||||||
"flag_choices",
|
"flag_choices",
|
||||||
|
"exercice_flag_deps",
|
||||||
|
"exercice_flag_labels_omcq_deps",
|
||||||
|
"exercice_flag_labels_deps",
|
||||||
|
"exercice_flag_labels",
|
||||||
"exercice_flags",
|
"exercice_flags",
|
||||||
"exercice_solved",
|
"exercice_solved",
|
||||||
"exercice_tries",
|
"exercice_tries",
|
||||||
@ -69,7 +85,7 @@ func ResetExercices() (error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ResetTeams wipes out all teams, incluings members and attempts.
|
// ResetTeams wipes out all teams, incluings members and attempts.
|
||||||
func ResetTeams() (error) {
|
func ResetTeams() error {
|
||||||
return truncateTable(
|
return truncateTable(
|
||||||
"team_wchoices",
|
"team_wchoices",
|
||||||
"team_hints",
|
"team_hints",
|
||||||
|
Loading…
Reference in New Issue
Block a user