diff options
author | MR Lemon <matt@matthewlemon> | 2020-05-13 16:08:00 +0100 |
---|---|---|
committer | MR Lemon <matt@matthewlemon> | 2020-05-13 16:08:00 +0100 |
commit | e3b629fe001c75caca0f430ee5137305e4386af7 (patch) | |
tree | d4da5323b9c5281a4bfdb9ed83f7a51ffd6135fc /ctrack/core/management | |
parent | 84f2eccea7759dc694c83b770b0066a11cae7ecd (diff) |
refactored populate script into a new core app - better positioned for use in tests
Diffstat (limited to 'ctrack/core/management')
-rw-r--r-- | ctrack/core/management/__init__.py | 0 | ||||
-rw-r--r-- | ctrack/core/management/commands/__init__.py | 0 | ||||
-rw-r--r-- | ctrack/core/management/commands/populate_db.py | 24 |
3 files changed, 24 insertions, 0 deletions
diff --git a/ctrack/core/management/__init__.py b/ctrack/core/management/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ctrack/core/management/__init__.py diff --git a/ctrack/core/management/commands/__init__.py b/ctrack/core/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ctrack/core/management/commands/__init__.py 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." + ) + ) |