Mercurial > farol > farol
comparison 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 |
comparison
equal
deleted
inserted
replaced
57:4ac1dd522998 | 58:fbc413b8a46e |
---|---|
1 # -*- encoding: utf-8 -*- | |
2 # Description: | |
3 # Common controller Web stuffs | |
4 # | |
5 # Authors: | |
6 # BenoƮt Allard <benoit.allard@greenbone.net> | |
7 # | |
8 # Copyright: | |
9 # Copyright (C) 2014 Greenbone Networks GmbH | |
10 # | |
11 # This program is free software; you can redistribute it and/or | |
12 # modify it under the terms of the GNU General Public License | |
13 # as published by the Free Software Foundation; either version 2 | |
14 # of the License, or (at your option) any later version. | |
15 # | |
16 # This program is distributed in the hope that it will be useful, | |
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 # GNU General Public License for more details. | |
20 # | |
21 # You should have received a copy of the GNU General Public License | |
22 # along with this program; if not, write to the Free Software | |
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
24 | |
25 """\ | |
26 Some common routines for handling of Notes, Acknowledgments and Reference that | |
27 is shared for the Document and the Vulnerabilities. | |
28 """ | |
29 | |
30 from flask import request | |
31 | |
32 from farolluz.cvrf import CVRFNote | |
33 | |
34 def update_note_from_request(note): | |
35 note._type = request.form['type'] | |
36 note._ordinal = int(request.form['ordinal']) | |
37 note._note = request.form['note'] | |
38 note._title = request.form['title'] or None | |
39 note._audience = request.form['audience'] or None | |
40 | |
41 def create_note_from_request(): | |
42 title = request.form['title'] or None | |
43 audience = request.form['audience'] or None | |
44 | |
45 return CVRFNote(request.form['type'], int(request.form['ordinal']), | |
46 request.form['note'], title, audience) |