diff --git a/ldvspec/lofardata/forms.py b/ldvspec/lofardata/forms.py index 8542d95ab7e91267e7212f160110a686ecda0ba1..2aea9a0d2050122bda7a6b53ac19db2088c7f6ea 100644 --- a/ldvspec/lofardata/forms.py +++ b/ldvspec/lofardata/forms.py @@ -1,3 +1,5 @@ +from django.core.exceptions import ValidationError + from .models import WorkSpecification, DataProductFilter from django.forms import ModelForm @@ -20,6 +22,9 @@ class WorkSpecificationForm(ModelForm): def clean(self): self.cleaned_data = super().clean() self.cleaned_data["filters"] = self._extract_filters() + if not 'obs_id' in self.cleaned_data["filters"]: + raise ValidationError(["You have forgotten about the 'obs_id'"]) + return self.cleaned_data class Meta: diff --git a/ldvspec/lofardata/templates/lofardata/workspecification/create_update.html b/ldvspec/lofardata/templates/lofardata/workspecification/create_update.html index 4eb6bb9e117d5af056fa8fb525694acbd8df0368..c2952bd73d3e16a089553d1701ee490bdada469c 100644 --- a/ldvspec/lofardata/templates/lofardata/workspecification/create_update.html +++ b/ldvspec/lofardata/templates/lofardata/workspecification/create_update.html @@ -204,7 +204,11 @@ The input is invalid: {% for field, errors in form.errors.items %} {% for error in errors %} - <li class="text text--red text--faded">{{ field }}: {{ error }}</li> + {% if field == '__all__' %} + <li class="text text--red text--faded">{{ error }}</li> + {% else %} + <li class="text text--red text--faded">{{ field }}: {{ error }}</li> + {% endif %} {% endfor %} {% endfor %} </div>