Skip to content
Snippets Groups Projects
Commit 1609a838 authored by Fanna Lautenbach's avatar Fanna Lautenbach
Browse files

Merge branch 'hotfix/add-filter-constraint' into 'main'

add 'obs-id' as mandatory filter field

See merge request !51
parents 97938437 a76f9653
No related branches found
No related tags found
1 merge request!51add 'obs-id' as mandatory filter field
Pipeline #41548 passed
from django.core.exceptions import ValidationError
from .models import WorkSpecification, DataProductFilter from .models import WorkSpecification, DataProductFilter
from django.forms import ModelForm from django.forms import ModelForm
...@@ -20,6 +22,9 @@ class WorkSpecificationForm(ModelForm): ...@@ -20,6 +22,9 @@ class WorkSpecificationForm(ModelForm):
def clean(self): def clean(self):
self.cleaned_data = super().clean() self.cleaned_data = super().clean()
self.cleaned_data["filters"] = self._extract_filters() self.cleaned_data["filters"] = self._extract_filters()
if not 'obs_id' in self.cleaned_data["filters"]:
raise ValidationError(["obs_id: This field is required."])
return self.cleaned_data return self.cleaned_data
class Meta: class Meta:
......
...@@ -204,7 +204,11 @@ ...@@ -204,7 +204,11 @@
The input is invalid: The input is invalid:
{% for field, errors in form.errors.items %} {% for field, errors in form.errors.items %}
{% for error in errors %} {% 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 %}
{% endfor %} {% endfor %}
</div> </div>
......
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