#17 Update setup
* adds calling of update_codelist.py to setup.py * removes unused data in setup_data.py
This commit is contained in:
parent
f50dccb30b
commit
30f36060f3
@ -14,13 +14,15 @@ from codelist.settings import CODELIST_INTERVENTION_HANDLER_ID, CODELIST_CONSERV
|
|||||||
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, CODELIST_COMPENSATION_HANDLER_ID, \
|
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, CODELIST_COMPENSATION_HANDLER_ID, \
|
||||||
CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_ACTION_CLASS_ID, CODELIST_COMPENSATION_ADDITIONAL_TYPE_ID, \
|
CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_ACTION_CLASS_ID, CODELIST_COMPENSATION_ADDITIONAL_TYPE_ID, \
|
||||||
CODELIST_COMPENSATION_FUNDING_ID, CODELIST_BASE_URL, CODELIST_PROCESS_TYPE_ID
|
CODELIST_COMPENSATION_FUNDING_ID, CODELIST_BASE_URL, CODELIST_PROCESS_TYPE_ID
|
||||||
|
from konova.management.commands.setup import BaseKonovaCommand
|
||||||
|
|
||||||
bool_map = {
|
bool_map = {
|
||||||
"true": True,
|
"true": True,
|
||||||
"false": False,
|
"false": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
class Command(BaseCommand):
|
|
||||||
|
class Command(BaseKonovaCommand):
|
||||||
help = "Performs test on collisions using the identifier generation"
|
help = "Performs test on collisions using the identifier generation"
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
@ -102,32 +104,3 @@ class Command(BaseCommand):
|
|||||||
code_list=code_list,
|
code_list=code_list,
|
||||||
parent=code
|
parent=code
|
||||||
)
|
)
|
||||||
|
|
||||||
def _break_line(self):
|
|
||||||
""" Simply prints a line break
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
"""
|
|
||||||
self.stdout.write("\n")
|
|
||||||
|
|
||||||
def _write_warning(self, txt: str):
|
|
||||||
self.stdout.write(
|
|
||||||
self.style.WARNING(
|
|
||||||
txt
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def _write_success(self, txt: str):
|
|
||||||
self.stdout.write(
|
|
||||||
self.style.SUCCESS(
|
|
||||||
txt
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def _write_error(self, txt: str):
|
|
||||||
self.stdout.write(
|
|
||||||
self.style.ERROR(
|
|
||||||
txt
|
|
||||||
)
|
|
||||||
)
|
|
@ -8,7 +8,7 @@ Created on: 15.12.20
|
|||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
|
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
from django.core.management import BaseCommand
|
from django.core.management import BaseCommand, call_command
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
|
||||||
from konova.management.commands.setup_data import GROUPS_DATA, USER_NOTIFICATIONS_NAMES
|
from konova.management.commands.setup_data import GROUPS_DATA, USER_NOTIFICATIONS_NAMES
|
||||||
@ -18,7 +18,45 @@ from user.models import UserNotification
|
|||||||
CREATED_TEMPLATE = "{} created"
|
CREATED_TEMPLATE = "{} created"
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class BaseKonovaCommand(BaseCommand):
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
# Needs to be implemented in inheriting classes
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def _break_line(self):
|
||||||
|
""" Simply prints a line break
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
self.stdout.write("\n")
|
||||||
|
|
||||||
|
def _write_warning(self, txt: str):
|
||||||
|
self.stdout.write(
|
||||||
|
self.style.WARNING(
|
||||||
|
txt
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def _write_success(self, txt: str):
|
||||||
|
self.stdout.write(
|
||||||
|
self.style.SUCCESS(
|
||||||
|
txt
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def _write_error(self, txt: str):
|
||||||
|
self.stdout.write(
|
||||||
|
self.style.ERROR(
|
||||||
|
txt
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseKonovaCommand):
|
||||||
help = "Initializes database with basic data"
|
help = "Initializes database with basic data"
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
@ -27,6 +65,7 @@ class Command(BaseCommand):
|
|||||||
self._init_superuser()
|
self._init_superuser()
|
||||||
self._init_default_groups()
|
self._init_default_groups()
|
||||||
self._init_user_notifications()
|
self._init_user_notifications()
|
||||||
|
self._init_codelists()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self._break_line()
|
self._break_line()
|
||||||
exit(-1)
|
exit(-1)
|
||||||
@ -97,33 +136,11 @@ class Command(BaseCommand):
|
|||||||
self._break_line()
|
self._break_line()
|
||||||
|
|
||||||
def _init_codelists(self):
|
def _init_codelists(self):
|
||||||
pass
|
""" Calls the 'update_codelist' command found in codelist app
|
||||||
|
|
||||||
def _break_line(self):
|
|
||||||
""" Simply prints a line break
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.stdout.write("\n")
|
return call_command(
|
||||||
|
'update_codelist'
|
||||||
def _write_warning(self, txt: str):
|
|
||||||
self.stdout.write(
|
|
||||||
self.style.WARNING(
|
|
||||||
txt
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def _write_success(self, txt: str):
|
|
||||||
self.stdout.write(
|
|
||||||
self.style.SUCCESS(
|
|
||||||
txt
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def _write_error(self, txt: str):
|
|
||||||
self.stdout.write(
|
|
||||||
self.style.ERROR(
|
|
||||||
txt
|
|
||||||
)
|
|
||||||
)
|
)
|
@ -9,21 +9,6 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
|
|
||||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||||
|
|
||||||
TEST_ORGANISATION_DATA = [
|
|
||||||
{
|
|
||||||
"name": "Test_Official_1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_Official_2",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_NGO_1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_Company_1",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
GROUPS_DATA = [
|
GROUPS_DATA = [
|
||||||
{
|
{
|
||||||
"name": DEFAULT_GROUP,
|
"name": DEFAULT_GROUP,
|
||||||
|
Loading…
Reference in New Issue
Block a user