Mercurial > farol
changeset 96:3848faa88cd5
Add deletion of Vulnerability's References
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Thu, 09 Oct 2014 16:32:03 +0200 |
parents | 0b64dc3f50eb |
children | 4ec281e68821 |
files | farol/templates/vulnerability/view.j2 farol/vulnerability.py |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/farol/templates/vulnerability/view.j2 Thu Oct 09 16:26:55 2014 +0200 +++ b/farol/templates/vulnerability/view.j2 Thu Oct 09 16:32:03 2014 +0200 @@ -109,7 +109,7 @@ {% call panel(heading="References", badge=vulnerability._references | length , title=3) %} <ul> {% for reference in vulnerability._references %} - <li><a href="{{ reference._url }}" target="_blank">{{ reference._description }}{% if reference._type %} ({{ reference._type }}){% endif %}</a> (<a href="{{ url_for('.edit_reference', ordinal=vulnerability._ordinal, index=loop.index0) }}">edit</a>)</li> + <li><div><a href="{{ reference._url }}" target="_blank">{{ reference._description }}{% if reference._type %} ({{ reference._type }}){% endif %}</a> (<a href="{{ url_for('.edit_reference', ordinal=vulnerability._ordinal, index=loop.index0) }}">edit</a>){{ delete_button(url_for('.del_reference', ordinal=vulnerability._ordinal, index=loop.index0)) }}</div></li> {% endfor %} </ul> <a class="pull-right" href="{{ url_for('.add_reference', ordinal=vulnerability._ordinal) }}">add</a>
--- a/farol/vulnerability.py Thu Oct 09 16:26:55 2014 +0200 +++ b/farol/vulnerability.py Thu Oct 09 16:32:03 2014 +0200 @@ -512,6 +512,17 @@ get_vuln(ordinal).addReference(ref) return redirect(url_for('.view', ordinal=ordinal)) +@vulnerability.route('/<int:ordinal>/reference/<int:index>/del', methods=['POST']) +@document_required +def del_reference(ordinal, index): + refs = get_vuln(ordinal)._references + if not ( 0 <= index < len(refs)): + flash('Reference not found', 'danger') + abort(404) + + del refs[index] + return redirect(url_for('.view', ordinal=ordinal)) + @vulnerability.route('/<int:ordinal>/acknowledgment/<int:index>') @document_required