diff farol/controller.py @ 58:fbc413b8a46e

Unify note update/creation from forms
author Benoît Allard <benoit.allard@greenbone.net>
date Wed, 08 Oct 2014 11:34:11 +0200
parents
children c6e7175ff28c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/farol/controller.py	Wed Oct 08 11:34:11 2014 +0200
@@ -0,0 +1,46 @@
+# -*- encoding: utf-8 -*-
+# Description:
+# Common controller Web stuffs
+#
+# Authors:
+# BenoƮt Allard <benoit.allard@greenbone.net>
+#
+# Copyright:
+# Copyright (C) 2014 Greenbone Networks GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+"""\
+Some common routines for handling of Notes, Acknowledgments and Reference that
+is shared for the Document and the Vulnerabilities.
+"""
+
+from flask import request
+
+from farolluz.cvrf import CVRFNote
+
+def update_note_from_request(note):
+    note._type = request.form['type']
+    note._ordinal = int(request.form['ordinal'])
+    note._note = request.form['note']
+    note._title = request.form['title'] or None
+    note._audience = request.form['audience'] or None
+
+def create_note_from_request():
+    title = request.form['title'] or None
+    audience = request.form['audience'] or None
+
+    return CVRFNote(request.form['type'], int(request.form['ordinal']),
+                    request.form['note'], title, audience)

http://farol.wald.intevation.org