|
5 | 5 | from typing import Any, Mapping, Optional |
6 | 6 |
|
7 | 7 | from annoying.fields import AutoOneToOneField |
| 8 | +from core.current_request import CurrentContext |
8 | 9 | from core.label_config import ( |
9 | 10 | check_control_in_config_by_regex, |
10 | 11 | check_toname_in_config_by_regex, |
@@ -484,14 +485,13 @@ def has_collaborator_enabled(self, user): |
484 | 485 | return membership.exists() and membership.first().enabled |
485 | 486 |
|
486 | 487 | def _update_tasks_states( |
487 | | - self, maximum_annotations_changed, overlap_cohort_percentage_changed, tasks_number_changed, user=None |
| 488 | + self, maximum_annotations_changed, overlap_cohort_percentage_changed, tasks_number_changed |
488 | 489 | ): |
489 | 490 | """ |
490 | 491 | Update tasks states after settings change |
491 | 492 | :param maximum_annotations_changed: If maximum_annotations param changed |
492 | 493 | :param overlap_cohort_percentage_changed: If cohort_percentage param changed |
493 | 494 | :param tasks_number_changed: If tasks number changed in project |
494 | | - :param user: User who is updating the tasks states |
495 | 495 | """ |
496 | 496 | logger.info( |
497 | 497 | f'Starting _update_tasks_states with params: Project {str(self)} maximum_annotations ' |
@@ -533,6 +533,7 @@ def _update_tasks_states( |
533 | 533 |
|
534 | 534 | if tasks_number_changed: |
535 | 535 | # FSM: Recalculate project state after task deletion or import |
| 536 | + user = CurrentContext.get_user() |
536 | 537 | update_project_state_after_task_change(self, user=user) |
537 | 538 |
|
538 | 539 | def _batch_update_with_retry(self, queryset, batch_size=500, max_retries=3, **update_fields): |
@@ -1184,22 +1185,18 @@ def _update_tasks_counters_and_task_states( |
1184 | 1185 | tasks_number_changed, |
1185 | 1186 | from_scratch=True, |
1186 | 1187 | recalculate_stats_counts: Optional[Mapping[str, int]] = None, |
1187 | | - user=None, |
1188 | 1188 | ): |
1189 | 1189 | """ |
1190 | 1190 | Update tasks counters and update tasks states (rearrange and/or is_labeled) |
1191 | 1191 | :param queryset: Tasks to update queryset |
1192 | 1192 | :param from_scratch: Skip calculated tasks |
1193 | | - :param user: User who is updating the tasks states |
1194 | 1193 | :return: Count of updated tasks |
1195 | 1194 | """ |
1196 | 1195 | from tasks.functions import update_tasks_counters |
1197 | 1196 |
|
1198 | 1197 | queryset = make_queryset_from_iterable(queryset) |
1199 | 1198 | objs = update_tasks_counters(queryset, from_scratch) |
1200 | | - self._update_tasks_states( |
1201 | | - maximum_annotations_changed, overlap_cohort_percentage_changed, tasks_number_changed, user=user |
1202 | | - ) |
| 1199 | + self._update_tasks_states(maximum_annotations_changed, overlap_cohort_percentage_changed, tasks_number_changed) |
1203 | 1200 |
|
1204 | 1201 | if recalculate_all_stats and recalculate_stats_counts: |
1205 | 1202 | recalculate_all_stats(self.id, **recalculate_stats_counts) |
|
0 commit comments