def __edit_pass_thru_expense(current_user_id, our_expenses, expense, expense_id, error):

    # fetch user's categories
    categories = our_expenses.get_categories()
    if not categories: error = 'You need to define at least one category'

    if request.method == 'POST':
        if 'description' in request.form and request.form['description']: description = request.form['description']
        else: error = 'You need to provide a description'
        if 'category' in request.form: category_id = request.form['category']
        else: error = 'You need to provide a category'

        # valid category?
        if our_expenses.is_category(id=category_id):

            our_expenses.edit_pass_thru_expense(description, category_id, expense_id)
            flash('Expense edited')

            # do a GET otherwise category will fail
            return redirect(url_for('expenses.edit_expense', expense_id=expense_id))

        else: error = 'Not a valid category'

    # show the form
    return render_template('admin_edit_pass_thru_expense.html', **locals())
Edit shared with expense from the perspective of shared with user
dataset/ETHPy150Open radekstepan/FlaskBudget/presenters/expenses.py/__edit_pass_thru_expense