Fix #1518, check also unavailable views/tasks for projects sync#1524
Fix #1518, check also unavailable views/tasks for projects sync#1524MyPyDavid wants to merge 3 commits into2.5.0/releasefrom
Conversation
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
|
do you wanna possibly make a |
| self.show_project_tasks_and_views() | ||
|
|
||
| def sync_all_tasks_or_views_to_projects(self, model): | ||
| queryset = model.objects.filter(available=True) |
There was a problem hiding this comment.
this line would leave out the unavailable tasks/views from the sync, so that they will not be removed from the projects by this command.
That would need to be fixed with the queryset = model.objects.all() so that the sync functions as expected.
| qs_count = queryset.count() | ||
|
|
||
| self.stdout.write(self.style.SUCCESS(f'Starting sync for {qs_count} available {model_name}...')) | ||
| self.stdout.write(self.style.SUCCESS(f'Starting sync for {qs_count} {model_name}...')) |
There was a problem hiding this comment.
self.stdout.write is preferred according to: https://docs.djangoproject.com/en/4.2/howto/custom-management-commands/#module-django.core.management
Note
When you are using management commands and wish to provide console output, you should write to self.stdout and self.stderr, instead of printing to stdout and stderr directly. By using these proxies, it becomes much easier to test your custom command. Note also that you don’t need to end messages with a newline character, it will be added automatically, unless you specify the ending parameter:
| def filter_tasks_or_views_for_project(task_or_view, project) -> TaskQuerySet | ViewQuerySet: | ||
| queryset = ( task_or_view.objects | ||
| .filter(Q(catalogs=None) | Q(catalogs=project.catalog)) | ||
| .filter(Q(groups=None) | Q(groups__in=project.groups)) |
There was a problem hiding this comment.
this behaviour should be kept?
That a view without any catalogs could be added to all projects potentially..? Same for groups?
Description
Related issue: #1518