Skip to content

Commit 2be5cf8

Browse files
committed
makes test leads not required, conditionally displays tests
1 parent 8634f99 commit 2be5cf8

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

dojo/engagement/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,11 @@ def add_tests(request, eid):
309309
if form.is_valid():
310310
new_test = form.save(commit=False)
311311
new_test.engagement = eng
312-
new_test.lead = User.objects.get(id=form['lead'].value())
312+
try:
313+
new_test.lead = User.objects.get(id=form['lead'].value())
314+
except:
315+
new_test.lead = None
316+
pass
313317
new_test.save()
314318
tags = request.POST.getlist('tags')
315319
t = ", ".join(tags)

dojo/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ class TestForm(forms.ModelForm):
555555
"Choose from the list or add new tags. Press TAB key to add.")
556556
lead = forms.ModelChoiceField(
557557
queryset=User.objects.exclude(is_staff=False),
558-
required=True, label="Testing Lead")
558+
required=False, label="Testing Lead")
559559

560560

561561
def __init__(self, *args, **kwargs):

dojo/templates/dojo/engagement.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ <h3 class="has-filters">
6363
<div class="lineContainer">
6464
<a style="display: inline" class="eng_link" href="{% url 'view_engagement' e.id %}">
6565
{% if e.name %}{{ e.name }} {% endif %}{{ e.target_start }}</a>
66-
| Lead : {{ e.lead.first_name }}
66+
| Lead: {{ e.lead.first_name }}
6767
|
6868
{% for test in e.test_set.all %}
69-
<a href="{% url 'view_test' test.id %}"> {{ test.test_type }} : {{ test.lead.first_name }} </a> |
69+
{% if test.lead %}
70+
<a href="{% url 'view_test' test.id %}"> {{ test.test_type }}: {{ test.lead.first_name }} </a> |
71+
{% else %}
72+
<a href="{% url 'view_test' test.id %}"> {{ test.test_type }} </a> |
73+
{% endif %}
7074
{% endfor %}
7175
</div>
7276
<sup>

0 commit comments

Comments
 (0)