Browse Source

Draft for a clear contest script

Script clears calls, users, references and shadow calls from the
database to clean up after the last contest.
Sebastian Lohff 1 year ago
parent
commit
d38c6ada3f
1 changed files with 28 additions and 0 deletions
  1. 28
    0
      clear_contest.py

+ 28
- 0
clear_contest.py View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env python
2
+from __future__ import print_function
3
+
4
+import datetime
5
+
6
+# prepare environment
7
+import sys
8
+sys.path.append("..")
9
+import os
10
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cqtu.settings")
11
+import django
12
+django.setup()
13
+
14
+confirm = raw_input("Do are you sure you want to clear all contest data? Answer with uppercase YES: ")
15
+
16
+if confirm != "YES":
17
+	print("Aborting")
18
+	sys.exit(1)
19
+
20
+
21
+from contest.models import QSO, ShadowCall, Reference, User
22
+
23
+print("{0} QSOs deleted".format(*QSO.objects.all().delete()))
24
+print("{0} ShadowCalls deleted".format(*ShadowCall.objects.all().delete()))
25
+print("{0} References deleted".format(*Reference.objects.all().delete()))
26
+print("{0} Users deleted".format(*User.objects.filter(is_superuser=0).delete()))
27
+print()
28
+print("Good to go!")

Loading…
Cancel
Save