Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dojo/templates/dojo/form_fields.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% load event_tags %}
{% load display_tags %}
{% block css %}
{{ form.media.css }}
{% endblock %}
Expand All @@ -17,6 +18,16 @@
{{ field }}
{% endfor %}

{% if form|has_required_field %}
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<p class="help-block">
<em>Required fields are marked with an asterisk</em><sup>*</sup>
</p>
</div>
</div>
{% endif %}

{% for field in form.visible_fields %}
<div class="form-group{% if field.errors %} has-error{% endif %}">
{% if field|is_checkbox %}
Expand Down
11 changes: 11 additions & 0 deletions dojo/templates_classic/dojo/form_fields.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% load event_tags %}
{% load display_tags %}
{% block css %}
{{ form.media.css }}
{% endblock %}
Expand All @@ -16,6 +17,16 @@
{{ field }}
{% endfor %}

{% if form|has_required_field %}
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<p class="help-block">
<em>Required fields are marked with an asterisk</em><sup>*</sup>
</p>
</div>
</div>
{% endif %}

{% for field in form.visible_fields %}
<div class="form-group{% if field.errors %} has-error{% endif %}">
{% if field|is_checkbox %}
Expand Down
8 changes: 8 additions & 0 deletions dojo/templatetags/display_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,3 +1167,11 @@ def import_history(finding, *, autoescape=True):
list_of_status_changes += "<b>" + status_change.created.strftime("%b %d, %Y, %H:%M:%S") + "</b>: " + status_change.get_action_display() + "<br/>"

return mark_safe(html % (list_of_status_changes))

@register.filter
def has_required_field(form):
"""Returns True if the form has at least one required field"""
if not form:
return False
return any(field.field.required for field in form)