changed form validation onto field

This commit is contained in:
Thomas Nahuel Rusiecki 2024-11-11 14:47:44 -03:00 committed by pedro
parent b4c18535fb
commit 8dade92f7e
2 changed files with 12 additions and 14 deletions

View File

@ -15,7 +15,7 @@ from utils.save_snapshots import move_json, save_in_disk
class UploadForm(forms.Form): class UploadForm(forms.Form):
evidence_file = MultipleFileField(label=_("File")) evidence_file = MultipleFileField(label=_("File"))
def clean(self): def clean_evidence_file(self):
self.evidences = [] self.evidences = []
data = self.cleaned_data.get('evidence_file') data = self.cleaned_data.get('evidence_file')
if not data: if not data:

View File

@ -8,22 +8,20 @@
</div> </div>
</div> </div>
<!-- override invalid-feedback class -->
<style>
.invalid-feedback {
color: #670000;
font-size: 1rem;
}
</style>
{% load django_bootstrap5 %} {% load django_bootstrap5 %}
<form role="form" method="post" enctype="multipart/form-data"> <form role="form" method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
{% if form.errors %}
<div class="alert alert-danger alert-icon alert-icon-border alert-dismissible" role="alert"> {% bootstrap_form form alert_error_type="none" error_css_class="alert alert-danger alert-icon alert-icon-border" %}
<div class="icon"><span class="mdi mdi-close-circle-o"></span></div> <div class="form-actions-no-box">
<div class="message">
{% for error in form.non_field_errors %}
{{ error }}<br />
{% endfor %}
<button class="btn-close" type="button" data-dismiss="alert" aria-label="Close"></button>
</div>
</div>
{% endif %}
{% bootstrap_form form alert_error_type="fields" %}
<div class="form-actions-no-box">
<a class="btn btn-grey" href="{% url 'dashboard:unassigned_devices' %}">{% translate "Cancel" %}</a> <a class="btn btn-grey" href="{% url 'dashboard:unassigned_devices' %}">{% translate "Cancel" %}</a>
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" /> <input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
</div> </div>