Skip to content

Commit

Permalink
HA-148 - Fixed create_preregister_users command
Browse files Browse the repository at this point in the history
  • Loading branch information
jbc25 committed Jun 3, 2024
1 parent 1657ad9 commit 2d3b2f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api/client/environments/PROD.bru
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
vars {
URL: https://app.mercadosocial.net
URL: https://appmes.triskelapps.com
username: [email protected]
}
vars:secret [
Expand Down
29 changes: 18 additions & 11 deletions market/management/commands/create_preregister_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import time

from django.core.management.base import BaseCommand
from django.db.models import Q

from authentication.models import User
from authentication.models.preregister import PreRegisteredUser
from core.models import Node
from market.models import Account, Consumer
from market.models import Account, Consumer, Provider


def create_preregister(account):
Expand All @@ -28,9 +29,22 @@ def handle(self, *args, **options):

node = Node.objects.get(pk=node_id)

accounts = Account.objects.filter(node=node)
print(intercoop)
print(type(intercoop))

accounts = None
if intercoop is None:
accounts = Account.objects.filter(node=node)
elif intercoop is True:
accounts = Consumer.objects.filter(node=node, is_intercoop=True)
elif intercoop is False:
providers = Provider.objects.filter(node=node)
consumers_no_intercoop = Consumer.objects.filter(node=node, is_intercoop=False)
accounts = list(providers) + list(consumers_no_intercoop)

print(f'Generating users and preregisters. Total {len(accounts)}')
print(accounts)

current = 0

existing_emails = []
Expand All @@ -46,15 +60,8 @@ def handle(self, *args, **options):
existing_emails.append(account.email)
continue

if intercoop is None:
print(f"Creating user and preregister: {account.email}")
create_preregister(account)
elif intercoop is True and account.is_intercoop:
print(f"Creating Intercoop user and preregister: {account.email}")
create_preregister(account)
elif intercoop is False and not account.is_intercoop:
print(f"Creating not Intercoop user and preregister: {account.email}")
create_preregister(account)
print(f"Creating user and preregister: {account.email}")
create_preregister(account)

print("\nExisting emails:")
print("\n".join(existing_emails))

0 comments on commit 2d3b2f1

Please sign in to comment.