2015-01-16 14:18:34 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
from django.core.management.commands.migrate import Command as _Command
|
|
|
|
|
2015-02-12 20:57:05 +01:00
|
|
|
from ...signals import post_permission_creation
|
2015-01-16 14:18:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Command(_Command):
|
|
|
|
"""
|
2015-02-12 20:57:05 +01:00
|
|
|
Migration command that does nearly the same as Django's migration command
|
|
|
|
but also calls the post_permission_creation signal.
|
2015-01-16 14:18:34 +01:00
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
2015-01-16 14:18:34 +01:00
|
|
|
def handle(self, *args, **options):
|
|
|
|
from django.conf import settings
|
2019-01-06 16:22:33 +01:00
|
|
|
|
2015-02-12 20:57:05 +01:00
|
|
|
# Creates the folder for a SQLite3 database if necessary.
|
2019-01-06 16:22:33 +01:00
|
|
|
if settings.DATABASES["default"]["ENGINE"] == "django.db.backends.sqlite3":
|
2015-01-16 14:18:34 +01:00
|
|
|
try:
|
|
|
|
os.makedirs(settings.OPENSLIDES_USER_DATA_PATH)
|
|
|
|
except (FileExistsError, AttributeError):
|
2015-02-12 20:57:05 +01:00
|
|
|
# If the folder already exists or the settings
|
|
|
|
# OPENSLIDES_USER_DATA_PATH is unknown, just do nothing.
|
2015-01-16 14:18:34 +01:00
|
|
|
pass
|
|
|
|
super().handle(*args, **options)
|
2015-02-12 20:57:05 +01:00
|
|
|
|
|
|
|
# Send this signal after sending post_migrate (inside super()) so that
|
|
|
|
# all Permission objects are created previously.
|
|
|
|
post_permission_creation.send(self)
|