view farol/controller.py @ 60:c6e7175ff28c

Unify acknowledgments update/creation from forms
author Benoît Allard <benoit.allard@greenbone.net>
date Wed, 08 Oct 2014 11:58:33 +0200
parents fbc413b8a46e
children 55b72057b066
line wrap: on
line source
# -*- 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, CVRFAcknowledgment

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)

def update_acknowledgment_from_request(ack):
    ack._name = request.form['name'] or None
    ack._organization = request.form['organization'] or None
    ack._description = request.form['description'] or None
    ack._url = request.form['url'] or None

def create_acknowledgment_from_request():
    ack = CVRFAcknowledgment()
    ack._name = request.form['name'] or None
    ack._organization = request.form['organization'] or None
    ack._description = request.form['description'] or None
    ack._url = request.form['url'] or None
    return ack

http://farol.wald.intevation.org