Add management command to perform steps required after an upgrade.

This commit is contained in:
Roberto Rosario
2015-07-18 02:24:10 -04:00
parent afe6644321
commit a5cf80cd86
5 changed files with 29 additions and 3 deletions

View File

@@ -69,7 +69,8 @@ What's new in Mayan EDMS v2.0
* Normalization of 'title' and 'name' fields to 'label'
* Split tests files.
* Document image and intermediate file caching now has it's own storage backend.
* RGB tags
* ``performupgrade`` management command.
Upgrading from a previous version
=================================
@@ -102,8 +103,7 @@ Common steps
Migrate existing database schema with::
$ mayan-edms.py purge_permissions
$ mayan-edms.py migrate
$ mayan-edms.py performupgrade
During the migration several messages of stale content types can occur:

View File

@@ -0,0 +1,14 @@
from __future__ import unicode_literals
from django.core import management
from ...signals import perform_upgrade
class Command(management.BaseCommand):
help = 'Performs the required steps after a version upgrade.'
def handle(self, *args, **options):
management.call_command('migrate', interactive=False)
management.call_command('purgeperiodictasks', interactive=False)
perform_upgrade.send(sender=self)

View File

@@ -3,3 +3,4 @@ from __future__ import unicode_literals
from django.dispatch import Signal
post_initial_setup = Signal(use_caching=True)
perform_upgrade = Signal(use_caching=True)

View File

@@ -5,8 +5,10 @@ from django.utils.translation import ugettext_lazy as _
from common import (
MayanAppConfig, menu_multi_item, menu_object, menu_secondary, menu_setup
)
from common.signals import perform_upgrade
from rest_api.classes import APIEndPoint
from .handlers import purge_permissions
from .models import Role
from .links import (
link_permission_grant, link_permission_revoke, link_role_create,
@@ -28,3 +30,5 @@ class PermissionsApp(MayanAppConfig):
menu_multi_item.bind_links(links=[link_permission_grant, link_permission_revoke], sources=['permissions:role_permissions'])
menu_secondary.bind_links(links=[link_role_list, link_role_create], sources=[Role, 'permissions:role_create', 'permissions:role_list'])
menu_setup.bind_links(links=[link_role_list])
perform_upgrade.connect(purge_permissions, dispatch_uid='purge_permissions')

View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
from django.core import management
def purge_permissions(**kwargs):
management.call_command('purgepermissions')