OpenSlides/openslides/core/management/commands/migrate.py
Norman Jäckel 3a19218bd5 Refactored parts of users app.
Refactored user creation and update via REST API. Used new serializer.
Cleaned up management commands, signals and imports. Moved code from 'api.py' to 'models.py'.
Changed usage of group 'Registered'. Now the users don't have to be members to gain its permissions. Used customized auth backend for this.
Added and changed some tests.
2015-02-14 02:29:53 +01:00

28 lines
1.0 KiB
Python

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