]> git.parisson.com Git - teleforma.git/commitdiff
add command to add department
authorGuillaume Pellerin <guillaume.pellerin@free.fr>
Tue, 5 Mar 2024 09:51:16 +0000 (10:51 +0100)
committerGuillaume Pellerin <guillaume.pellerin@free.fr>
Tue, 5 Mar 2024 09:51:16 +0000 (10:51 +0100)
teleforma/management/commands/teleforma-add-department.py [new file with mode: 0644]

diff --git a/teleforma/management/commands/teleforma-add-department.py b/teleforma/management/commands/teleforma-add-department.py
new file mode 100644 (file)
index 0000000..9f9cc1f
--- /dev/null
@@ -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()
+