simplify initial_datas

This commit is contained in:
Cayo Puigdefabregas 2024-02-23 09:27:18 +01:00
parent f7ac9a0a3a
commit ddcd748b00
1 changed files with 1 additions and 11 deletions

View File

@ -22,8 +22,6 @@ class Command(BaseCommand):
def handle(self, *args, **kwargs): def handle(self, *args, **kwargs):
ADMIN_EMAIL = config('ADMIN_EMAIL', 'admin@example.org') ADMIN_EMAIL = config('ADMIN_EMAIL', 'admin@example.org')
ADMIN_PASSWORD = config('ADMIN_PASSWORD', '1234') ADMIN_PASSWORD = config('ADMIN_PASSWORD', '1234')
KEY_DIDS = config('KEY_DIDS')
cache.set("KEY_DIDS", KEY_DIDS, None)
self.create_admin_users(ADMIN_EMAIL, ADMIN_PASSWORD) self.create_admin_users(ADMIN_EMAIL, ADMIN_PASSWORD)
if settings.CREATE_TEST_USERS: if settings.CREATE_TEST_USERS:
@ -37,6 +35,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())
if settings.SYNC_ORG_DEV == 'y': if settings.SYNC_ORG_DEV == 'y':
self.sync_credentials_organizations("pangea.org", "somconnexio.coop") self.sync_credentials_organizations("pangea.org", "somconnexio.coop")
self.sync_credentials_organizations("local 8000", "local 9000") self.sync_credentials_organizations("local 8000", "local 9000")
@ -44,17 +43,13 @@ class Command(BaseCommand):
def create_admin_users(self, email, password): def create_admin_users(self, email, password):
su = User.objects.create_superuser(email=email, password=password) su = User.objects.create_superuser(email=email, password=password)
su.set_encrypted_sensitive_data()
su.save() su.save()
self.create_defaults_dids(su)
def create_users(self, email, password): def create_users(self, email, password):
u = User.objects.create(email=email, password=password) u = User.objects.create(email=email, password=password)
u.set_password(password) u.set_password(password)
u.set_encrypted_sensitive_data()
u.save() u.save()
self.create_defaults_dids(u)
def create_organizations(self, name, url): def create_organizations(self, name, url):
@ -70,11 +65,6 @@ class Command(BaseCommand):
org1.save() org1.save()
org2.save() org2.save()
def create_defaults_dids(self, u):
did = DID(label="Default", user=u, type=DID.Types.WEB)
did.set_did()
did.save()
def create_schemas(self): def create_schemas(self):
schemas_files = os.listdir(settings.SCHEMAS_DIR) schemas_files = os.listdir(settings.SCHEMAS_DIR)
for x in schemas_files: for x in schemas_files: