From 488feff8f591465f1f5923125482afca5c69cf0c Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Mon, 5 Aug 2024 14:58:05 +0200 Subject: [PATCH] add SciPost Selections to alternative journals --- scipost_django/journals/admin.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scipost_django/journals/admin.py b/scipost_django/journals/admin.py index d21521abb..a07c3720a 100644 --- a/scipost_django/journals/admin.py +++ b/scipost_django/journals/admin.py @@ -52,9 +52,18 @@ class JournalAdmin(admin.ModelAdmin): if db_field.name == "alternative_journals": journal_id = request.resolver_match.kwargs["object_id"] journal = Journal.objects.get(pk=journal_id) - kwargs["queryset"] = Journal.objects.filter( - active=True, college__acad_field=journal.college.acad_field - ).exclude(pk=journal_id) + selections = Journal.objects.filter(name="SciPost Selections") + + # Show all active journals if the current journal is SciPost Selections + if journal == selections.first(): + kwargs["queryset"] = Journal.objects.all() + else: + kwargs["queryset"] = ( + Journal.objects.filter(college=journal.college) | selections + ) + + kwargs["queryset"] = kwargs["queryset"].active().exclude(pk=journal_id) + return super().formfield_for_manytomany(db_field, request, **kwargs) -- GitLab