Skip to content
Snippets Groups Projects
Commit 404e160f authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Scheduler: Show conflicts in AK details in both directions

Find conflicts that this AK specifies and those AKs where this AK was specified
Deduplicate and order list alphabetically
This implements #223
parent 3ee08b9a
Branches
No related tags found
1 merge request!242Admin interface improvements
Pipeline #274455 passed
...@@ -408,8 +408,22 @@ class AK(models.Model): ...@@ -408,8 +408,22 @@ class AK(models.Model):
detail_string += f"\n{_('Requirements')}: {', '.join(str(r) for r in self.requirements.all())}" detail_string += f"\n{_('Requirements')}: {', '.join(str(r) for r in self.requirements.all())}"
if self.types.count() > 0: if self.types.count() > 0:
detail_string += f"\n{_('Types')}: {', '.join(str(r) for r in self.types.all())}" detail_string += f"\n{_('Types')}: {', '.join(str(r) for r in self.types.all())}"
# Find conflicts
# (both directions, those specified for this AK and those were this AK was specified as conflict)
# Deduplicate and order list alphabetically
conflicts = set()
if self.conflicts.count() > 0: if self.conflicts.count() > 0:
detail_string += f"\n{_('Conflicts')}: {', '.join(str(c) for c in self.conflicts.all())}" for c in self.conflicts.all():
conflicts.add(str(c))
if self.conflict.count() > 0:
for c in self.conflict.all():
conflicts.add(str(c))
if len(conflicts) > 0:
conflicts = list(conflicts)
conflicts.sort()
detail_string += f"\n{_('Conflicts')}: {', '.join(conflicts)}"
if self.prerequisites.count() > 0: if self.prerequisites.count() > 0:
detail_string += f"\n{_('Prerequisites')}: {', '.join(str(p) for p in self.prerequisites.all())}" detail_string += f"\n{_('Prerequisites')}: {', '.join(str(p) for p in self.prerequisites.all())}"
detail_string += f"\n{_('Availabilities')}: \n{availabilities}" detail_string += f"\n{_('Availabilities')}: \n{availabilities}"
......
...@@ -43,7 +43,7 @@ class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView): ...@@ -43,7 +43,7 @@ class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView):
def get_queryset(self): def get_queryset(self):
return super().get_queryset().filter(start__isnull=True).select_related('event', 'ak', 'ak__track', return super().get_queryset().filter(start__isnull=True).select_related('event', 'ak', 'ak__track',
'ak__category').prefetch_related('ak__types', 'ak__owners', 'ak__conflicts', 'ak__prerequisites', 'ak__category').prefetch_related('ak__types', 'ak__owners', 'ak__conflicts', 'ak__prerequisites',
'ak__requirements').order_by('ak__track', 'ak') 'ak__requirements', 'ak__conflict').order_by('ak__track', 'ak')
def get_context_data(self, *, object_list=None, **kwargs): def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs) context = super().get_context_data(object_list=object_list, **kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment