From 32233bf7dc6a362cd645e9831348f01eb57f20b7 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Mon, 11 Nov 2019 06:10:31 +0100 Subject: [PATCH] Debug cleaning of formulate recommendation (needs tier) --- submissions/forms.py | 7 +++++++ .../pool/recommendation_formulate.html | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/submissions/forms.py b/submissions/forms.py index b868be6f0..5d2e9ef14 100644 --- a/submissions/forms.py +++ b/submissions/forms.py @@ -1299,6 +1299,13 @@ class EICRecommendationForm(forms.ModelForm): ) self.load_assignment() + def clean(self): + cleaned_data = super().clean() + if (cleaned_data['recommendation'] == EIC_REC_PUBLISH and + cleaned_data['tier'] == ''): + raise forms.ValidationError( + 'If you recommend Publish, please also provide a Tier.') + def save(self): recommendation = super().save(commit=False) recommendation.submission = self.submission diff --git a/submissions/templates/submissions/pool/recommendation_formulate.html b/submissions/templates/submissions/pool/recommendation_formulate.html index 31e49858e..7b4e93295 100644 --- a/submissions/templates/submissions/pool/recommendation_formulate.html +++ b/submissions/templates/submissions/pool/recommendation_formulate.html @@ -13,6 +13,26 @@ {% block content %} + {% if form.errors %} + <div class="row"> + <div class="col-12"> + <h1 class="text-danger">There was an error in submitting the form:</h1> + {% for field in form %} + {% for error in field.errors %} + <div class="alert alert-danger"> + <strong>{{ field.name }} - {{ error|escape }}</strong> + </div> + {% endfor %} + {% endfor %} + {% for error in form.non_field_errors %} + <div class="alert alert-danger"> + <strong>{{ error|escape }}</strong> + </div> + {% endfor %} + </div> + </div> + {% endif %} + <h1 class="highlight">Formulate Editorial Recommendation for Submission</h1> <br> -- GitLab