示例#1
0
def delete_suggestion():
    """
    Delete a suggestion selected by the user.
    :return: the 'suggestions.html' template. In case of error it shows an error message.
    """
    searched = request.args.get('searched', None)
    if remove_suggestion(searched):
        return render_template('suggestions.html',
                               suggestions=get_suggestions_list(),
                               default_suggestions=DEFAULT_SUGGESTIONS)
    else:
        error = 'ERROR: The suggestion you want to delete does not exist!'
        return render_template('suggestions.html',
                               suggestions=get_suggestions_list(),
                               suggestion_error=error,
                               default_suggestions=DEFAULT_SUGGESTIONS)
示例#2
0
def suggestions_manager():
    """
    Open suggestions manager
    :return: suggestion manager template
    """
    return render_template('suggestions.html',
                           suggestions=get_suggestions_list(),
                           default_suggestions=DEFAULT_SUGGESTIONS)
示例#3
0
def add_suggestion():
    """
    Add a new suggestion inserted by the user.
    :return: the 'suggestions.html' template. In case of error it shows an error message.
    """
    if request.method == 'POST':
        searched = request.form['searched']
        suggestion = request.form['suggestion']
        autoreplacement = request.form['autoreplacement']
        if not str(searched).lower() in DEFAULT_SUGGESTIONS:
            new_suggestion(searched, suggestion, autoreplacement)
            return render_template('suggestions.html',
                                   suggestions=get_suggestions_list(),
                                   default_suggestions=DEFAULT_SUGGESTIONS)
        else:
            error = 'ERROR: Default suggestions cannot be modified!'
            return render_template('suggestions.html',
                                   suggestions=get_suggestions_list(),
                                   suggestion_error=error,
                                   default_suggestions=DEFAULT_SUGGESTIONS)
示例#4
0
def add_suggestion():
    """
    Add a new suggestion inserted by the user.
    :return: the 'suggestions.html' template. In case of error it shows an error message.
    """
    if request.method == 'POST':
        searched = request.form['searched']
        suggestion = request.form['suggestion']
        autoreplacement = request.form['autoreplacement']
        new_suggestion(searched, suggestion, autoreplacement)
    return render_template('suggestions.html',
                           suggestions=get_suggestions_list(),
                           default_suggestions=DEFAULT_SUGGESTIONS)