diff --git a/scipost_django/proceedings/forms.py b/scipost_django/proceedings/forms.py index 0ab15c35344ab4656590d595338c97ea30d85021..17c0d8fcdceb6ebfe2aef528b05f666696d49532 100644 --- a/scipost_django/proceedings/forms.py +++ b/scipost_django/proceedings/forms.py @@ -23,3 +23,8 @@ class ProceedingsForm(forms.ModelForm): "submissions_close", "template_latex_tgz", ) + + +class ProceedingsMultipleChoiceField(forms.ModelMultipleChoiceField): + def label_from_instance(self, obj): + return obj.event_suffix or obj.event_name diff --git a/scipost_django/production/forms.py b/scipost_django/production/forms.py index e8dfa0bc46d93687b8999e868041e092c453a570..5130b699f5ced3ba22c813d1e91389cccfdf003c 100644 --- a/scipost_django/production/forms.py +++ b/scipost_django/production/forms.py @@ -16,6 +16,7 @@ from crispy_bootstrap5.bootstrap5 import FloatingField from journals.models import Journal from markup.widgets import TextareaWithPreview from proceedings.models import Proceedings +from proceedings.forms import ProceedingsMultipleChoiceField from scipost.fields import UserModelChoiceField from . import constants @@ -260,7 +261,7 @@ class ProductionStreamSearchForm(forms.Form): queryset=Journal.objects.active(), required=False, ) - proceedings = forms.ModelChoiceField( + proceedings = ProceedingsMultipleChoiceField( queryset=Proceedings.objects.order_by("-submissions_close"), required=False, ) @@ -278,7 +279,11 @@ class ProductionStreamSearchForm(forms.Form): empty_label="Any", ) status = forms.MultipleChoiceField( - choices=constants.PRODUCTION_STREAM_STATUS, + # Use short status names from their internal (code) name + choices=[ + (status_code_name, status_code_name.replace("_", " ").title()) + for status_code_name, _ in constants.PRODUCTION_STREAM_STATUS + ], required=False, ) orderby = forms.ChoiceField( @@ -318,8 +323,8 @@ class ProductionStreamSearchForm(forms.Form): Div( Div( Div( - Div(Field("accepted_in", size=3), css_class="col-12 col-sm-7"), - Div(Field("proceedings", size=3), css_class="col-12 col-sm-5"), + Div(Field("accepted_in", size=3), css_class="col-sm-8"), + Div(Field("proceedings", size=3), css_class="col-sm-4"), css_class="row mb-0", ), Div( @@ -332,11 +337,11 @@ class ProductionStreamSearchForm(forms.Form): Div(Field("ordering"), css_class="col-6"), css_class="row mb-0", ), - css_class="col-md-7", + css_class="col-sm-9", ), Div( Field("status", size=len(constants.PRODUCTION_STREAM_STATUS)), - css_class="col-md-5", + css_class="col-sm-3", ), css_class="row mb-0", ), @@ -349,36 +354,28 @@ class ProductionStreamSearchForm(forms.Form): latest_activity_annot=Greatest(Max("events__noted_on"), "opened", "closed") ) - if self.cleaned_data.get("accepted_in"): - streams = streams.filter( - submission__editorialdecision__for_journal=self.cleaned_data.get( - "accepted_in" - ), - ) - if self.cleaned_data.get("proceedings"): - streams = streams.filter( - submission__proceedings=self.cleaned_data.get("proceedings"), - ) - if self.cleaned_data.get("identifier"): + if accepted_in := self.cleaned_data.get("accepted_in"): streams = streams.filter( - submission__preprint__identifier_w_vn_nr__icontains=self.cleaned_data.get( - "identifier" - ), + submission__editorialdecision__for_journal__in=accepted_in, ) - if self.cleaned_data.get("author"): - streams = streams.filter( - submission__author_list__icontains=self.cleaned_data.get("author"), - ) - if self.cleaned_data.get("title"): + if proceedings := self.cleaned_data.get("proceedings"): + streams = streams.filter(submission__proceedings__in=proceedings) + + if identifier := self.cleaned_data.get("identifier"): streams = streams.filter( - submission__title__icontains=self.cleaned_data.get("title"), + submission__preprint__identifier_w_vn_nr__icontains=identifier, ) - if self.cleaned_data.get("officer"): - streams = streams.filter(officer=self.cleaned_data.get("officer")) - if self.cleaned_data.get("supervisor"): - streams = streams.filter(supervisor=self.cleaned_data.get("supervisor")) - if self.cleaned_data.get("status"): - streams = streams.filter(status__in=self.cleaned_data.get("status")) + if author := self.cleaned_data.get("author"): + streams = streams.filter(submission__author_list__icontains=author) + if title := self.cleaned_data.get("title"): + streams = streams.filter(submission__title__icontains=title) + + if officer := self.cleaned_data.get("officer"): + streams = streams.filter(officer=officer) + if supervisor := self.cleaned_data.get("supervisor"): + streams = streams.filter(supervisor=supervisor) + if status := self.cleaned_data.get("status"): + streams = streams.filter(status__in=status) if not self.user.has_perm("scipost.can_view_all_production_streams"): # Restrict stream queryset if user is not supervisor diff --git a/scipost_django/production/templates/production/_productionstream_details_summary_contents.html b/scipost_django/production/templates/production/_productionstream_details_summary_contents.html index 785311ad1be6ba1cda4460542e83594cac107aac..a3cf1852e14134cc89fff4bb8cfe1d84e9d95bab 100644 --- a/scipost_django/production/templates/production/_productionstream_details_summary_contents.html +++ b/scipost_django/production/templates/production/_productionstream_details_summary_contents.html @@ -31,7 +31,12 @@ <br> {{ productionstream.submission.editorial_decision.for_journal }} {% if productionstream.submission.proceedings %} - - {{ productionstream.submission.proceedings.event_suffix }} + - + {% if productionstream.submission.proceedings.event_suffix %} + {{ productionstream.submission.proceedings.event_suffix }} + {% else %} + {{ productionstream.submission.proceedings.event_name }} + {% endif %} {% endif %} </div>