Mercurial > farol
changeset 72:f9aa7b1e697e
Add possibility to delete References
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Thu, 09 Oct 2014 10:31:06 +0200 |
parents | 51825b0c4890 |
children | 88adf067cae1 |
files | farol/document.py farol/templates/document/view.j2 |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/farol/document.py Thu Oct 09 10:24:56 2014 +0200 +++ b/farol/document.py Thu Oct 09 10:31:06 2014 +0200 @@ -250,6 +250,17 @@ get_current().addReference(ref) return redirect(url_for('.view')) +@document.route('/reference/del', methods=['POST']) +@document_required +def del_reference(): + index = int(request.form['index']) + refs = get_current()._references + if not (0 <= index < len(refs)): + flash('Reference not found', 'danger') + abort(404) + del refs[index] + return redirect(url_for('.view')) + @document.route('/acknowledgment/<int:index>') @document_required def view_acknowledgment(index):
--- a/farol/templates/document/view.j2 Thu Oct 09 10:24:56 2014 +0200 +++ b/farol/templates/document/view.j2 Thu Oct 09 10:31:06 2014 +0200 @@ -118,7 +118,7 @@ {% call panel(type="warning", heading="References", badge=cvrf._references | length, title=3) %} <ul> {% for reference in cvrf._references %} - <li><a href="{{ reference._url }}" target="_blank">{{ reference._description }}{% if reference._type %} ({{ reference._type }}){% endif %}</a> (<a href="{{ url_for('.edit_reference', index=loop.index0) }}">edit</a>)</li> + <li><a href="{{ reference._url }}" target="_blank">{{ reference._description }}{% if reference._type %} ({{ reference._type }}){% endif %}</a> (<a href="{{ url_for('.edit_reference', index=loop.index0) }}">edit</a>){{ delete_button(url_for('.del_reference'), {'index': loop.index0}) }}</li> {% endfor %} </ul> <a class="pull-right" href="{{ url_for('.add_reference') }}">add</a>