sync command
This commit is contained in:
parent
c65a8639c1
commit
17faf5fff4
|
@ -6,6 +6,7 @@ from django.core.management.base import BaseCommand, CommandError
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from decouple import config
|
from decouple import config
|
||||||
from oidc4vp.models import Organization
|
from oidc4vp.models import Organization
|
||||||
|
from promotion.models import Promotion
|
||||||
|
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
@ -29,6 +30,7 @@ class Command(BaseCommand):
|
||||||
f = csv.reader(csvfile, delimiter=';', quotechar='"')
|
f = csv.reader(csvfile, delimiter=';', quotechar='"')
|
||||||
for r in f:
|
for r in f:
|
||||||
self.create_organizations(r[0].strip(), r[1].strip())
|
self.create_organizations(r[0].strip(), r[1].strip())
|
||||||
|
self.sync_credentials_organizations()
|
||||||
|
|
||||||
def create_admin_users(self, email, password):
|
def create_admin_users(self, email, password):
|
||||||
User.objects.create_superuser(email=email, password=password)
|
User.objects.create_superuser(email=email, password=password)
|
||||||
|
@ -42,3 +44,11 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def create_organizations(self, name, url):
|
def create_organizations(self, name, url):
|
||||||
Organization.objects.create(name=name, response_uri=url)
|
Organization.objects.create(name=name, response_uri=url)
|
||||||
|
|
||||||
|
def sync_credentials_organizations(self):
|
||||||
|
org1 = Organization.objects.get(name="test1")
|
||||||
|
org2 = Organization.objects.get(name="test2")
|
||||||
|
org2.my_client_id = org1.client_id
|
||||||
|
org2.my_client_secret = org1.client_secret
|
||||||
|
org1.my_client_id = org2.client_id
|
||||||
|
org1.my_client_secret = org2.client_secret
|
||||||
|
|
Loading…
Reference in New Issue