Refactoring to konova
This commit is contained in:
@@ -11,8 +11,7 @@ from django.contrib.auth.models import User
|
||||
from django.core.management import BaseCommand
|
||||
from django.db import transaction
|
||||
|
||||
from konova.management.commands.setup_test_data import TEST_ORGANISATION_DATA, TEST_ROLE_GROUPS_DATA
|
||||
from konova.models import RoleType, RoleGroup
|
||||
from konova.management.commands.setup_test_data import TEST_ORGANISATION_DATA
|
||||
from organisation.models import Organisation
|
||||
|
||||
CREATED_TEMPLATE = "{} created"
|
||||
@@ -26,7 +25,6 @@ class Command(BaseCommand):
|
||||
with transaction.atomic():
|
||||
self.__init_superuser()
|
||||
self.__init_test_organisation()
|
||||
self.__init_role_groups()
|
||||
except KeyboardInterrupt:
|
||||
self.__break_line()
|
||||
exit(-1)
|
||||
@@ -96,30 +94,6 @@ class Command(BaseCommand):
|
||||
)
|
||||
self.__break_line()
|
||||
|
||||
def __init_role_groups(self):
|
||||
""" Creates test role groups from predefined data
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.stdout.write(
|
||||
self.style.WARNING(
|
||||
"--- Role Groups ---"
|
||||
)
|
||||
)
|
||||
for group_data in TEST_ROLE_GROUPS_DATA:
|
||||
group_data["organisation"] = Organisation.objects.get(name=group_data["organisation"])
|
||||
group_data["role"] = RoleType.objects.get(type=group_data["role"])
|
||||
group = RoleGroup.objects.get_or_create(
|
||||
**group_data
|
||||
)[0]
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
CREATED_TEMPLATE.format(group.name)
|
||||
)
|
||||
)
|
||||
self.__break_line()
|
||||
|
||||
def __break_line(self):
|
||||
""" Simply prints a line break
|
||||
|
||||
|
||||
Reference in New Issue
Block a user