Create system user after migration

Move the code to trigger on the post_migrate signal.
Avoid "database not ready" errors during tests and initialsetup.

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-06-28 13:59:00 -04:00
parent 8bd0d0166b
commit 9cb6c6599d
2 changed files with 13 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import unicode_literals
from django.apps import apps
from django.db.models.signals import post_migrate
from django.utils.translation import ugettext_lazy as _
from mayan.apps.common.apps import MayanAppConfig
@@ -11,6 +12,7 @@ from mayan.apps.common.menus import (
from mayan.apps.navigation.classes import SourceColumn
from .dependencies import * # NOQA
from .handlers import handler_create_system_user
from .html_widgets import (
ObjectLinkWidget, widget_event_actor_link, widget_event_type_link
)
@@ -19,7 +21,6 @@ from .links import (
link_events_list, link_notification_mark_read,
link_notification_mark_read_all, link_user_notifications_list,
)
from .utils import create_system_user
class EventsApp(MayanAppConfig):
@@ -103,4 +104,7 @@ class EventsApp(MayanAppConfig):
), position=50
)
create_system_user()
post_migrate.connect(
dispatch_uid='events_create_system_user',
receiver=handler_create_system_user,
)

View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
from .utils import create_system_user
def handler_create_system_user(sender, **kwargs):
create_system_user()