From 75214679759481305e4e5ba36eff445974fec597 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 24 Oct 2017 21:28:22 +0200 Subject: [PATCH] split documentsort into it's own manage.py command, does not get applied during install otherwise --- pandora/app/management/commands/init_db.py | 1 + .../management/commands/sync_documentsort.py | 27 +++++++++++++++++++ .../item/management/commands/sync_itemsort.py | 3 --- update.py | 1 + 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 pandora/document/management/commands/sync_documentsort.py diff --git a/pandora/app/management/commands/init_db.py b/pandora/app/management/commands/init_db.py index 029fc1f9..31519145 100644 --- a/pandora/app/management/commands/init_db.py +++ b/pandora/app/management/commands/init_db.py @@ -29,6 +29,7 @@ class Command(BaseCommand): [manage_py, 'migrate', '--noinput'], [manage_py, 'sqlfindindex'], [manage_py, 'sync_itemsort'], + [manage_py, 'sync_documentsort'], [manage_py, 'update_static'], [manage_py, 'compile_pyc', '-p', os.path.dirname(manage_py)], ]: diff --git a/pandora/document/management/commands/sync_documentsort.py b/pandora/document/management/commands/sync_documentsort.py new file mode 100644 index 00000000..43fc22b3 --- /dev/null +++ b/pandora/document/management/commands/sync_documentsort.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# vi:si:et:sw=4:sts=4:ts=4 +from __future__ import print_function + +from django.core.management.base import BaseCommand +from django.db import connection, transaction +from django.db.models import fields +from django.conf import settings + +settings.RELOAD_CONFIG = False +import app.monkey_patch + + +class Command(BaseCommand): + """ + sync document sort table with current settings in site.json + """ + help = 'alter table to match documentKeys in site.json.' + args = '' + + def add_arguments(self, parser): + parser.add_argument('--debug', action='store_true', dest='debug', + default=False, help='print sql commans') + + def handle(self, **options): + import document.sync_sort + document.sync_sort.update_tables(options['debug']) diff --git a/pandora/item/management/commands/sync_itemsort.py b/pandora/item/management/commands/sync_itemsort.py index 2f7b7a2e..23b12520 100644 --- a/pandora/item/management/commands/sync_itemsort.py +++ b/pandora/item/management/commands/sync_itemsort.py @@ -116,6 +116,3 @@ class Command(BaseCommand): if options['debug']: print(i) i.update_sort() - # and udpate doucments - import document.sync_sort - document.sync_sort.update_tables(options['debug']) diff --git a/update.py b/update.py index 5cb286a5..0ddd4239 100755 --- a/update.py +++ b/update.py @@ -107,6 +107,7 @@ if __name__ == "__main__": run('./manage.py', 'migrate', '--noinput') run('./manage.py', 'sqlfindindex') run('./manage.py', 'sync_itemsort') + run('./manage.py', 'sync_documentsort') reload_notice(base) elif len(sys.argv) == 2 and sys.argv[1] == 'static': os.chdir(join(base, 'pandora'))