SciPost Code Repository

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

refactor production stream search

parent 60fb7876
No related branches found
No related tags found
Loading
...@@ -286,25 +286,31 @@ class ProductionStreamSearchForm(forms.Form): ...@@ -286,25 +286,31 @@ class ProductionStreamSearchForm(forms.Form):
identifier = forms.CharField(max_length=128, required=False) identifier = forms.CharField(max_length=128, required=False)
all_streams = ProductionStream.objects.ongoing() all_streams = ProductionStream.objects.ongoing()
stream_journals = all_streams.values_list(
"submission__editorialdecision__for_journal", flat=True
).distinct()
stream_proceedings = all_streams.values_list(
"submission__proceedings", flat=True
).distinct()
stream_officers = all_streams.values_list("officer", flat=True).distinct()
stream_supervisors = all_streams.values_list("supervisor", flat=True).distinct()
journal = forms.MultipleChoiceField( journal = forms.MultipleChoiceField(
choices=Journal.objects.active() choices=Journal.objects.active()
.filter( .filter(id__in=stream_journals)
id__in=all_streams.values_list(
"submission__editorialdecision__for_journal", flat=True
)
)
.order_by("name") .order_by("name")
.values_list("id", "name"), .values_list("id", "name"),
required=False, required=False,
) )
proceedings = forms.MultipleChoiceField( proceedings = forms.MultipleChoiceField(
choices=Proceedings.objects.all() choices=Proceedings.objects.all()
.filter(id__in=all_streams.values_list("submission__proceedings", flat=True)) .filter(id__in=stream_proceedings)
.order_by("-submissions_close") .order_by("-submissions_close")
# Short name is `event_suffix` if set, otherwise `event_name` # Short name is `event_suffix` if set, otherwise `event_name`
.annotate(short_name=Coalesce(NullIf("event_suffix", Value("")), "event_name")) .annotate(
.values_list("id", "short_name") short_name=Coalesce(NullIf("event_suffix", Value("")), "event_name")
.distinct(), ).values_list("id", "short_name"),
required=False, required=False,
) )
officer = forms.MultipleChoiceField( officer = forms.MultipleChoiceField(
...@@ -312,9 +318,8 @@ class ProductionStreamSearchForm(forms.Form): ...@@ -312,9 +318,8 @@ class ProductionStreamSearchForm(forms.Form):
+ [ + [
(prod_user.id, str(prod_user)) (prod_user.id, str(prod_user))
for prod_user in ProductionUser.objects.active() for prod_user in ProductionUser.objects.active()
.filter(id__in=all_streams.values_list("officer", flat=True)) .filter(id__in=stream_officers)
.order_by("-user__id") .order_by("-user__id")
.distinct()
], ],
required=False, required=False,
) )
...@@ -323,9 +328,8 @@ class ProductionStreamSearchForm(forms.Form): ...@@ -323,9 +328,8 @@ class ProductionStreamSearchForm(forms.Form):
+ [ + [
(prod_user.id, str(prod_user)) (prod_user.id, str(prod_user))
for prod_user in ProductionUser.objects.active() for prod_user in ProductionUser.objects.active()
.filter(id__in=all_streams.values_list("supervisor", flat=True)) .filter(id__in=stream_supervisors)
.order_by("-user__id") .order_by("-user__id")
.distinct()
], ],
required=False, required=False,
) )
......
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