aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations/management
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-02-17 22:05:14 +0000
committerMatthew Lemon <matt@matthewlemon.com>2020-02-17 22:05:14 +0000
commitbc583a851b05e41dc59a18bd2fd9e777205485d3 (patch)
tree559e1fc17a905cf2fb6528687b4bfcea4280a9b2 /ctrack/organisations/management
parentfae87b201cbecc6a74cc0c17800053d33cab0de4 (diff)
part way through creating fixture factories
Diffstat (limited to 'ctrack/organisations/management')
-rw-r--r--ctrack/organisations/management/commands/generate_people.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/ctrack/organisations/management/commands/generate_people.py b/ctrack/organisations/management/commands/generate_people.py
new file mode 100644
index 0000000..d3fd45e
--- /dev/null
+++ b/ctrack/organisations/management/commands/generate_people.py
@@ -0,0 +1,65 @@
+import factory
+
+from django.core.management.base import BaseCommand, CommandError
+
+from factory import DjangoModelFactory, Faker, post_generation, SubFactory
+
+from ctrack.organisation.models import Person, Organisation
+
+
+class OrganisationFactory(DjangoModelFactory):
+ pass
+
+
+class PersonFactory(DjangoModelFactory):
+
+ class Meta:
+ model = Person
+
+ primary_nis_contact = True
+ voluntary_point_of_contact = True
+ has_egress = False
+ title = Faker("prefix")
+ job_title = Faker("job")
+ first_name = Faker("first_name")
+ last_name = Faker("last_name")
+ organisation = SubFactory(OrganisationFactory)
+ role =
+ email =
+ secondary_email =
+ mobile =
+ landline =
+ date_updated =
+ updated_by =
+ clearance =
+ clearance_sponsor =
+ clearance_start_date =
+ clearance_last_checked =
+ clearance_expiry =
+ active =
+ date_ended =
+ predecessor =
+ comments =
+
+
+class Command(BaseCommand):
+ help = """
+ Creates a bunch of people and organisations for them to work in.
+
+ python manage.py generate_people
+ """
+
+# def add_arguments(self, parser):
+# parser.add_argument("year", nargs="+", type=int)
+#
+# def handle(self, *args, **options):
+# for opt in options["year"]:
+# FinancialQuarter.objects.create(quarter=1, year=opt)
+# FinancialQuarter.objects.create(quarter=2, year=opt)
+# FinancialQuarter.objects.create(quarter=3, year=opt)
+# FinancialQuarter.objects.create(quarter=4, year=opt)
+# self.stdout.write(
+# self.style.SUCCESS(
+# f"Created FinancialQuarter objects for the years: {opt}"
+# )
+# )