From 79531231e6fbb483be691230e4d510bc909a8303 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Tue, 5 Mar 2024 10:51:16 +0100 Subject: [PATCH] add command to add department --- .../commands/teleforma-add-department.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 teleforma/management/commands/teleforma-add-department.py diff --git a/teleforma/management/commands/teleforma-add-department.py b/teleforma/management/commands/teleforma-add-department.py new file mode 100644 index 00000000..9f9cc1f2 --- /dev/null +++ b/teleforma/management/commands/teleforma-add-department.py @@ -0,0 +1,29 @@ +from optparse import make_option +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError +from django.contrib.auth.models import User +from django.template.defaultfilters import slugify +from teleforma.models import * +from teleforma.views import * +import logging +import codecs + + +class Command(BaseCommand): + help = "create a new department with organization, name and domain" + admin_email = 'webmaster@parisson.com' + args = 'organization_name name domain' + + def handle(self, *args, **options): + organization_name = args[0] + name = args[1] + domain = arg[2] + + organization = Organization.objects.get(name=organization_name) + department = Department( + organization=organization, + name=name, + domain=domain + ) + department.save() + -- 2.39.5