SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 488feff8 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add SciPost Selections to alternative journals

parent 69084b84
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment