From d4c6ba381ea8cd933e4e735cd3ffa5c12eac4a86 Mon Sep 17 00:00:00 2001 From: Rohan Moniz Date: Fri, 13 Oct 2023 17:30:18 -0400 Subject: [PATCH] add populate command --- .../management/commands/populate_audiences.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 backend/announcements/management/commands/populate_audiences.py diff --git a/backend/announcements/management/commands/populate_audiences.py b/backend/announcements/management/commands/populate_audiences.py new file mode 100644 index 0000000..820baf6 --- /dev/null +++ b/backend/announcements/management/commands/populate_audiences.py @@ -0,0 +1,18 @@ +import json +import random + +from django.contrib.auth.models import Group +from django.core.management import BaseCommand, call_command + +from announcements.models import Audience + + +with open("accounts/data/users.json") as f: + users = json.load(f)["users"] + + +class Command(BaseCommand): + + def handle(self, *args, **options): + for x in ["MOBILE", "OHQ", "CLUBS", "COURSE_PLAN", "COURSE_REVIEW", "COURSE_ALERT"]: + Audience.objects.get_or_create(name=x) \ No newline at end of file