# HG changeset patch # User BenoƮt Allard # Date 1412846090 -7200 # Node ID 88adf067cae15b434562269a3987de47fe0a0399 # Parent f9aa7b1e697ea4d08e9aa00a814401b09df69ffa Fix delete urls diff -r f9aa7b1e697e -r 88adf067cae1 farol/document.py --- a/farol/document.py Thu Oct 09 10:31:06 2014 +0200 +++ b/farol/document.py Thu Oct 09 11:14:50 2014 +0200 @@ -142,10 +142,9 @@ tracking._currentDate = date return redirect(url_for('.view')) -@document.route('/revision/del', methods=['POST']) +@document.route('/revision//del', methods=['POST']) @document_required -def del_revision(): - index = int(request.form['index']) +def del_revision(index): history = get_current()._tracking._history if not (0 <= index < len(history)): flash('Revision not found', 'danger') @@ -213,17 +212,15 @@ get_current().addNote(note) return redirect(url_for('.view')) -@document.route('/note/del', methods=['POST']) +@document.route('/note//del', methods=['POST']) @document_required -def del_note(): - ordinal = int(request.form['ordinal']) +def del_note(ordinal): cvrf = get_current() - notes = cvrf._notes note = cvrf.getNote(ordinal) if note is None: flash('Note not found', 'danger') abort(404) - notes.remove(note) + cvrf._notes.remove(note) return redirect(url_for('.view')) @document.route('/reference//edit', methods=['GET', 'POST']) @@ -250,10 +247,9 @@ get_current().addReference(ref) return redirect(url_for('.view')) -@document.route('/reference/del', methods=['POST']) +@document.route('/reference//del', methods=['POST']) @document_required -def del_reference(): - index = int(request.form['index']) +def del_reference(index): refs = get_current()._references if not (0 <= index < len(refs)): flash('Reference not found', 'danger') diff -r f9aa7b1e697e -r 88adf067cae1 farol/templates/document/view.j2 --- a/farol/templates/document/view.j2 Thu Oct 09 10:31:06 2014 +0200 +++ b/farol/templates/document/view.j2 Thu Oct 09 11:14:50 2014 +0200 @@ -62,7 +62,7 @@
edit - {{ delete_button(url_for('.del_revision'), {'index': loop.index0}) }} + {{ delete_button(url_for('.del_revision', index=loop.index0)) }}
{{ label_value('Number', revision._number | join('.'), right=8) }} {{ label_value('Date', revision._date) }} @@ -118,7 +118,7 @@ {% call panel(type="warning", heading="References", badge=cvrf._references | length, title=3) %} add diff -r f9aa7b1e697e -r 88adf067cae1 farol/templates/document/view_note.j2 --- a/farol/templates/document/view_note.j2 Thu Oct 09 10:31:06 2014 +0200 +++ b/farol/templates/document/view_note.j2 Thu Oct 09 11:14:50 2014 +0200 @@ -34,5 +34,5 @@
{% if note._audience %}

Audience: {{ note._audience }}

{% endif %}

{{ note._note | replace('\n', '
') }}

-
{{ delete_button(url_for('.del_note'), {'ordinal': note._ordinal}) }}
+
{{ delete_button(url_for('.del_note', ordinal=note._ordinal)) }}
{% endblock %} diff -r f9aa7b1e697e -r 88adf067cae1 farol/templates/macros.j2 --- a/farol/templates/macros.j2 Thu Oct 09 10:31:06 2014 +0200 +++ b/farol/templates/macros.j2 Thu Oct 09 11:14:50 2014 +0200 @@ -169,7 +169,7 @@ {% endif %} {% endmacro %} -{% macro delete_button(url, hiddens, text="delete") %} +{% macro delete_button(url, hiddens={}, text="delete") %}
{% for elem in hiddens %}