aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/core/management/commands/populate_db.py
diff options
context:
space:
mode:
authorMR Lemon <matt@matthewlemon>2020-05-13 16:08:00 +0100
committerMR Lemon <matt@matthewlemon>2020-05-13 16:08:00 +0100
commite3b629fe001c75caca0f430ee5137305e4386af7 (patch)
treed4da5323b9c5281a4bfdb9ed83f7a51ffd6135fc /ctrack/core/management/commands/populate_db.py
parent84f2eccea7759dc694c83b770b0066a11cae7ecd (diff)
refactored populate script into a new core app - better positioned for use in tests
Diffstat (limited to 'ctrack/core/management/commands/populate_db.py')
-rw-r--r--ctrack/core/management/commands/populate_db.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/ctrack/core/management/commands/populate_db.py b/ctrack/core/management/commands/populate_db.py
new file mode 100644
index 0000000..5b8f541
--- /dev/null
+++ b/ctrack/core/management/commands/populate_db.py
@@ -0,0 +1,24 @@
+
+from django.core.management import BaseCommand
+from django.core.management import CommandParser
+from ctrack.core.utils import populate_db
+
+
+class Command(BaseCommand):
+ help = """
+ Creates a large test fixture.
+ """
+
+ def add_arguments(self, parser: CommandParser) -> None:
+ parser.add_argument("number", nargs=1, type=int)
+
+ def handle(self, *args, **options):
+ number = options["number"][0]
+ populate_db(number)
+
+ # TODO - adapt this so that it records more than just Persons created
+ self.stdout.write(
+ self.style.SUCCESS(
+ f"Created {number} Person object[s]! Go forth and multiply."
+ )
+ )