summaryrefslogtreecommitdiff
path: root/ishtar_common/management
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/management')
-rw-r--r--ishtar_common/management/commands/regenerate_search_vector_cached_label.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/ishtar_common/management/commands/regenerate_search_vector_cached_label.py b/ishtar_common/management/commands/regenerate_search_vector_cached_label.py
index 59e37d75b..404811acf 100644
--- a/ishtar_common/management/commands/regenerate_search_vector_cached_label.py
+++ b/ishtar_common/management/commands/regenerate_search_vector_cached_label.py
@@ -24,16 +24,32 @@ from django.core.management.base import BaseCommand
from django.apps import apps
+APPS = ['ishtar_common', 'archaeological_operations',
+ 'archaeological_context_records', 'archaeological_finds',
+ 'archaeological_warehouse']
+
+
class Command(BaseCommand):
args = ''
help = 'Regenerate cached labels and search vectors'
+ def add_arguments(self, parser):
+ parser.add_argument('app_name', nargs='?', default=None,
+ choices=APPS)
+ parser.add_argument('model_name', nargs='?', default=None)
+
def handle(self, *args, **options):
- for app in ['ishtar_common', 'archaeological_operations',
- 'archaeological_context_records',
- 'archaeological_finds', 'archaeological_warehouse']:
+ limit = options['app_name']
+ model_name = options['model_name']
+ if model_name:
+ model_name = model_name.lower()
+ for app in APPS:
+ if limit and app != limit:
+ continue
print(u"* app: {}".format(app))
for model in apps.get_app_config(app).get_models():
+ if model_name and model.__name__.lower() != model_name:
+ continue
if model.__name__.startswith('Historical'):
continue
if not bool(