aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/srtgui/templates/investigation.html217
-rw-r--r--lib/srtgui/views.py14
2 files changed, 114 insertions, 117 deletions
diff --git a/lib/srtgui/templates/investigation.html b/lib/srtgui/templates/investigation.html
index 54228749..b662c5e1 100644
--- a/lib/srtgui/templates/investigation.html
+++ b/lib/srtgui/templates/investigation.html
@@ -64,48 +64,6 @@
<!-- include SRtool Metadata/Notification -->
{% include "srtool_metadata_include.html" with default_category="INVESTIGATION" default_url="investigation" %}
-<div class="col-md-12">
- <div id="details-defect" style="border: 1px solid Blue; background-color:LightBlue; padding-left: 25px; padding-right: 20px; display:none;">
- <p><p>
- <div class="row">
- <button class="execute" id="submit-createdefect"> Submit New Defect </button>
- <button id="select-canceldefect"> Cancel </button>
- </div>
- <div class="row">
- <div class="column1">
- <p><b><label id="priority">Set Priority:</label></b>
- <div id="priority-list" class="scrolling" style="width: 120px;">
- <div class="checkbox"> <label>
- <input type="radio" name="priority" value="4" type="checkbox"> High
- </label><p></div>
- <div class="checkbox"> <label>
- <input type="radio" name="priority" value="3" type="checkbox" checked="yes"> Medium
- </label><p></div>
- <div class="checkbox"> <label>
- <input type="radio" name="priority" value="2" type="checkbox"> Low
- </label><p></div>
- </div>
- </div>
- <div class="column2">
- <p><b><label id="components">Set Components:</label></b>
- <div id="all-components" class="scrolling" style="width: 150px;">
- {% for component in components %}
- <div class="checkbox">
- <label>
- <input class="checkbox-components" name="{{component}}" type="checkbox">{{component}}
- {% if "Userspace" == component %}<hr>{% endif %}
- </label>
- <p>
- </div>
- {% endfor %}
- </div>
- </div>
- </div>
- Reason: <input type="text" id="input-defect-reason" name="defect-reason" size="20" placeholder="(optional)"> (e.g. "Security Advisory [- REASON -] CVE-2020-1234")
- <p><p>
- </div>
-</div>
-
<HR ALIGN="center" WIDTH="100%">
<div class="row" style="padding-left: 25px;">
@@ -118,52 +76,6 @@
<dt>Vulnerability:</dt>
<dd><a href="{% url 'vulnerability' object.vulnerability.id %}">{{object.vulnerability.get_long_name}}</a></dd>
-
- <dt>Defect:</dt>
- <dd>
- {% for ij in object.investigation_to_defect.all %}
- {% if not forloop.first %}| {% endif %}<a href="{% url 'defect' ij.defect.id %}" target="_blank">{{ij.defect.name}} </a>
- {% endfor %}
- <p>
- {% if request.user.is_creator %}
- <a class="btn btn-default navbar-btn " id="select-attachdefect">Attach Defect</a>
- <a class="btn btn-default navbar-btn " id="select-createdefect">Create Defect</a>
- <a class="btn btn-default navbar-btn " id="select-detachdefect">Detach Defect</a>
- {% endif %}
- </dd>
-
- <div id="details-attachdefect" style="display:none; border: 1px solid; padding:20px; width:400px; margin-bottom:25px; margin-left:150px">
- <p><b><label>Select Defect by Key:</label></b>
- <div id="input-attachdefect" style="padding-left: 50px">
- <p><input type="text" id="text-attachdefect" placeholder="Issue Key (ex. {{defect_example}})" size="20"> <button class="execute" id="submit-attachdefect"> Submit </button></p>
- </div>
- </div>
-
- <div id="details-detachdefect" style="display:none; border: 1px solid; padding:20px; width:400px; margin-bottom:25px; margin-left:150px">
- <p><b><label>Select Defect(s):</label></b>
- <div id="select-detachdefectlist" style="padding-left: 50px">
- <div class="row">
- <div id="all-investigation-to-defects" class="scrolling" style="width: 300px;">
- {% for obj in investigation_to_defect %}
- <div class="checkbox">
- <label>
- <input class="checkbox-defects" name="defect-list" value="{{obj.defect.id}}" type="checkbox">{{obj.defect.name}}
- </label>
- <p>
- </div>
- {% endfor %}
- </div>
- <button class="execute" id="submit-detachdefect"> Detach </button>
- </div>
- </div>
- </div>
-
- <dt>Release Version:</dt>
- <dd>
- {% for ij in object.investigation_to_defect.all %}
- {% if not forloop.first %}| {% endif %}<a href="{{ij.defect.url}}" target="_blank">{{ij.defect.release_version}} </a>
- {% endfor %}
- </dd>
</dl>
</div>
</div>
@@ -172,6 +84,104 @@
<hr>
<div class="row" style="padding-left: 25px;">
+ <h3>Defects
+ {% if request.user.is_creator %}
+ <button id="select-attachdefect" class="btn btn-default" type="button">Attach Defect</button>
+ <button id="select-createdefect" class="btn btn-default" type="button">Create Defect</button>
+ {% endif %}
+ </h3>
+
+ <div id="details-attachdefect" style="display:none; border: 1px solid; padding:20px; width:400px; margin-bottom:25px; margin-left:150px">
+ <p><b><label>Select Defect by Key:</label></b>
+ <div id="input-attachdefect" style="padding-left: 50px">
+ <p><input type="text" id="text-attachdefect" placeholder="Issue Key (ex. {{defect_example}})" size="20"> <button class="execute" id="submit-attachdefect"> Submit </button></p>
+ </div>
+ </div>
+
+ <div class="col-md-12">
+ <div id="details-defect" style="border: 1px solid Blue; background-color:LightBlue; padding-left: 25px; padding-right: 20px; display:none;">
+ <p><p>
+ <div class="row">
+ <button class="execute" id="submit-createdefect"> Submit New Defect </button>
+ <button id="select-canceldefect"> Cancel </button>
+ </div>
+ <div class="row">
+ <div class="column1">
+ <p><b><label id="priority">Set Priority:</label></b>
+ <div id="priority-list" class="scrolling" style="width: 120px;">
+ <div class="checkbox"> <label>
+ <input type="radio" name="priority" value="4" type="checkbox"> High
+ </label><p></div>
+ <div class="checkbox"> <label>
+ <input type="radio" name="priority" value="3" type="checkbox" checked="yes"> Medium
+ </label><p></div>
+ <div class="checkbox"> <label>
+ <input type="radio" name="priority" value="2" type="checkbox"> Low
+ </label><p></div>
+ </div>
+ </div>
+ <div class="column2">
+ <p><b><label id="components">Set Components:</label></b>
+ <div id="all-components" class="scrolling" style="width: 150px;">
+ {% for component in components %}
+ <div class="checkbox">
+ <label>
+ <input class="checkbox-components" name="{{component}}" type="checkbox">{{component}}
+ {% if "Userspace" == component %}<hr>{% endif %}
+ </label>
+ <p>
+ </div>
+ {% endfor %}
+ </div>
+ </div>
+ </div>
+ Reason: <input type="text" id="input-defect-reason" name="defect-reason" size="20" placeholder="(optional)"> (e.g. "Security Advisory [- REASON -] CVE-2020-1234")
+ <p><p>
+ </div>
+ </div>
+
+ <table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
+ <thead>
+ <tr>
+ <th>Defect</th>
+ <th>Summary</th>
+ <th>Priority</th>
+ <th>Status</th>
+ <th>Resolution</th>
+ <th>Release Version</th>
+ <th>URL</th>
+ {% if request.user.is_creator %}
+ <th>Manage</th>
+ {% endif %}
+ </tr>
+ </thead>
+
+ {% if object.investigation_to_defect.all %}
+ {% for id in object.investigation_to_defect.all %}
+ <tr>
+ <td><a href="{% url 'defect' id.defect.id %}">{{id.defect.name}} </a></td>
+ <td>{{ id.defect.summary }}</td>
+ <td>{{ id.defect.get_priority_text }}</td>
+ <td>{{ id.defect.get_status_text }}</td>
+ <td>{{ id.defect.get_resolution_text }}</td>
+ <td>{{ id.defect.release_version }}</td>
+ <td><a href="{{id.defect.url}}" id="dataid_{{id.defect.id}}" target="_blank">{{id.defect.url}}</a></td>
+ {% if request.user.is_creator %}
+ <td>
+ <span class="glyphicon glyphicon-trash detach-defect" id="detach-defect_'+{{id.defect.id}}+'" x-data="{{id.defect.name}}"></span>
+ </td>
+ {% endif %}
+ </tr>
+ {% endfor %}
+ {% else %}
+ <tr>
+ <td>No defects found</td>
+ </tr>
+ {% endif %}
+ </table>
+</div>
+
+<div class="row" style="padding-left: 25px;">
<h3>Comments
{% if request.user.is_creator %}
<button id="select-newcomment" class="btn btn-default" type="button">Add comment ...</button>
@@ -215,7 +225,6 @@
</tr>
{% endif %}
</table>
-
</div>
<div class="row" style="padding-left: 25px;">
@@ -338,7 +347,6 @@
</tr>
{% endif %}
</table>
-
</div>
<div class="row" style="padding-left: 25px;">
@@ -405,7 +413,6 @@
{% endif %}
{% endif %}
</table>
-
</div>
{% endif %}
@@ -540,7 +547,7 @@
$('#submit-attachdefect').click(function(){
var query=$('#text-attachdefect').val().trim()
if (query=="") {
- alert("No query given");
+ alert("No defect given");
return;
}
postCommitAjaxRequest({
@@ -549,24 +556,18 @@
});
});
- $('#submit-detachdefect').click(function(){
- var defect_list=[];
- $('input[name="defect-list"]').each(function(){
- if ($(this).is(':checked')) {
- defect_list.push($(this).prop('value'));
- }
- });
- defect_list = defect_list.join(",");
- if ("" == defect_list) {
- alert("No defects were selected");
- return;
- }
- postCommitAjaxRequest({
- "action" : 'submit-detachdefect',
- "defects" : defect_list,
- });
+ $('.detach-defect').click(function(){
+ var defect_name = $(this).attr('x-data');
+ var result = confirm("Are you sure you want to detach " + defect_name + "?");
+ if (result){
+ postCommitAjaxRequest({
+ "action" : 'submit-detachdefect',
+ "defect" : defect_name,
+ });
+ }
});
+
/* Comment management */
$('#select-newcomment').click(function(){
diff --git a/lib/srtgui/views.py b/lib/srtgui/views.py
index db9e8fbc..d87dca38 100644
--- a/lib/srtgui/views.py
+++ b/lib/srtgui/views.py
@@ -1708,16 +1708,12 @@ def xhr_investigation_commit(request):
priority = request.POST['priority']
defect_name = _create_defect(investigation,defect_reason,components)
history_comment = "New defect '%s' created" % defect_name
- if 'submit-trashdefect' == action:
- defects = request.POST['defects']
+ if 'submit-detachdefect' == action:
+ defect_name = request.POST['defect']
product_id = Investigation.objects.get(id=invst_id).product_id
- defect_names = ""
- for defect_id in defects.split(','):
- defect_id = int(defect_id)
- defect_names += Defect.objects.get(pk=defect_id).name + ", "
- InvestigationToDefect.objects.get(investigation_id=invst_id, defect_id=defect_id).delete()
- defect_names = defect_names[:-2]
- history_comment = defect_names + " deleted from defects"
+ defect_id = Defect.objects.get(name=defect_name).id
+ InvestigationToDefect.objects.get(investigation_id=invst_id, defect_id=defect_id).delete()
+ history_comment = defect_name + " detached from investigation"
if 'submit-newcomment' == action:
comment = request.POST['comment']
InvestigationComments.objects.create(investigation_id=invst_id, comment=comment, date=datetime.today().strftime('%Y-%m-%d'), author=username)