Skip to content

Fix #1518, check also unavailable views/tasks for projects sync#1524

Open
MyPyDavid wants to merge 3 commits into2.5.0/releasefrom
2.5.0/fix/project-views-sync-available
Open

Fix #1518, check also unavailable views/tasks for projects sync#1524
MyPyDavid wants to merge 3 commits into2.5.0/releasefrom
2.5.0/fix/project-views-sync-available

Conversation

@MyPyDavid
Copy link
Copy Markdown
Member

@MyPyDavid MyPyDavid commented Feb 3, 2026

Description

Related issue: #1518

  • Aligns sync logic and view/task filtering to use availability rules consistently (including user-based availability).
  • Updates project/task/view creation and selection flows to use the unified filtering helper.
  • Adjusts the sync management command to process all instances so unavailable items are removed.

Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
@MyPyDavid MyPyDavid self-assigned this Feb 3, 2026
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
@MyPyDavid
Copy link
Copy Markdown
Member Author

do you wanna possibly make a 2.4.1 for this or keep at 2.5.0? @jochenklar

@MyPyDavid MyPyDavid added this to the RDMO 2.5.0 milestone Feb 3, 2026
@MyPyDavid MyPyDavid added type:bug status:acceptance python Pull requests that update Python code labels Feb 3, 2026
self.show_project_tasks_and_views()

def sync_all_tasks_or_views_to_projects(self, model):
queryset = model.objects.filter(available=True)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}...'))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this behaviour should be kept?
That a view without any catalogs could be added to all projects potentially..? Same for groups?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests that update Python code status:acceptance type:bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant