diff --git a/taiga/timeline/management/commands/clear_unnecessary_new_membership_entries.py b/taiga/timeline/management/commands/clear_unnecessary_new_membership_entries.py index f9b65dcf..7790b753 100644 --- a/taiga/timeline/management/commands/clear_unnecessary_new_membership_entries.py +++ b/taiga/timeline/management/commands/clear_unnecessary_new_membership_entries.py @@ -15,18 +15,16 @@ # along with this program. If not, see . from django.conf import settings from django.core.management.base import BaseCommand +from django.test.utils import override_settings from taiga.timeline.models import Timeline from taiga.projects.models import Project class Command(BaseCommand): help = 'Regenerate unnecessary new memberships entry lines' - def handle(self, *args, **options): - debug_enabled = settings.DEBUG - if debug_enabled: - print("Please, execute this script only with DEBUG mode disabled (DEBUG=False)") - return + @override_settings(DEBUG=False) + def handle(self, *args, **options): removing_timeline_ids = [] for t in Timeline.objects.filter(event_type="projects.membership.create").order_by("created"): print(t.created) diff --git a/taiga/timeline/management/commands/rebuild_timeline.py b/taiga/timeline/management/commands/rebuild_timeline.py index 2c462ce0..5d95d4e4 100644 --- a/taiga/timeline/management/commands/rebuild_timeline.py +++ b/taiga/timeline/management/commands/rebuild_timeline.py @@ -25,6 +25,8 @@ from django.core.exceptions import ObjectDoesNotExist from django.core.management.base import BaseCommand from django.db.models import Model from django.db import reset_queries +from django.test.utils import override_settings + from taiga.projects.models import Project from taiga.projects.history import services as history_services @@ -165,13 +167,8 @@ class Command(BaseCommand): help='Selected project id for timeline generation'), ) - + @override_settings(DEBUG=False) def handle(self, *args, **options): - debug_enabled = settings.DEBUG - if debug_enabled: - print("Please, execute this script only with DEBUG mode disabled (DEBUG=False)") - return - if options["purge"] == True: Timeline.objects.all().delete() diff --git a/taiga/timeline/management/commands/rebuild_timeline_for_user_creation.py b/taiga/timeline/management/commands/rebuild_timeline_for_user_creation.py index 2982969a..78e637d1 100644 --- a/taiga/timeline/management/commands/rebuild_timeline_for_user_creation.py +++ b/taiga/timeline/management/commands/rebuild_timeline_for_user_creation.py @@ -23,6 +23,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.core.management.base import BaseCommand from django.db.models import Model from django.db import reset_queries +from django.test.utils import override_settings from taiga.timeline.service import (_get_impl_key_from_model, _timeline_impl_map, extract_user_info) @@ -88,10 +89,6 @@ def generate_timeline(): class Command(BaseCommand): help = 'Regenerate project timeline' + @override_settings(DEBUG=False) def handle(self, *args, **options): - debug_enabled = settings.DEBUG - if debug_enabled: - print("Please, execute this script only with DEBUG mode disabled (DEBUG=False)") - return - generate_timeline() diff --git a/taiga/timeline/management/commands/update_timeline_for_updated_tasks.py b/taiga/timeline/management/commands/update_timeline_for_updated_tasks.py index 15b42172..1d145d30 100644 --- a/taiga/timeline/management/commands/update_timeline_for_updated_tasks.py +++ b/taiga/timeline/management/commands/update_timeline_for_updated_tasks.py @@ -18,6 +18,7 @@ from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist from django.core.management.base import BaseCommand from django.db.models import Prefetch, F +from django.test.utils import override_settings from taiga.timeline.models import Timeline from taiga.timeline.timeline_implementations import userstory_timeline @@ -34,7 +35,7 @@ def update_timeline(initial_date, final_date): timelines = timelines.filter(created__lt=final_date) timelines = timelines.filter(event_type="tasks.task.change") - + print("Generating tasks indexed by id dict") task_ids = timelines.values_list("object_id", flat=True) tasks_per_id = {task.id: task for task in Task.objects.filter(id__in=task_ids).select_related("user_story").iterator()} @@ -77,10 +78,6 @@ class Command(BaseCommand): help='Final date for timeline update'), ) + @override_settings(DEBUG=False) def handle(self, *args, **options): - debug_enabled = settings.DEBUG - if debug_enabled: - print("Please, execute this script only with DEBUG mode disabled (DEBUG=False)") - return - update_timeline(options["initial_date"], options["final_date"])