# from __future__ import print_function
from pprint import pprint
from flask import Blueprint, render_template, flash, redirect, url_for

from app.connection import Connection
from app.helper import get_kwargs, portify
from .forms import TransactionForm
from .models import Transaction

cronus = Blueprint('cronus', __name__)
table = 'transaction'


@cronus.route('/transaction/', methods=['GET', 'POST'])
def transaction():
	site = portify(url_for('api', _external=True))
	conn = Connection(site, display=True)
	kwargs = get_kwargs(str(table), 'cronus', conn, False)
	return render_template('entry.html', **kwargs)


@cronus.route('/add_trxn/', methods=['GET', 'POST'])
def add():
	pass

@@ -680,9 +680,942 @@
 ):%0A%09
-pass
+table_as_class = table.title().replace('_', '')%0A%0A%09try:%0A%09%09form = eval('%25sForm.new()' %25 table_as_class)%0A%09except AttributeError:%0A%09%09form = eval('%25sForm()' %25 table_as_class)%0A%0A%09if form.validate_on_submit():%0A%09%09site = portify(url_for('api', _external=True))%0A%09%09conn = Connection(site, display=True)%0A%09%09entry = eval('%25s()' %25 table_as_class)%0A%09%09form.populate_obj(entry)%0A%09%09keys = %5Bf for f in form._fields.keys() if f != 'csrf_token'%5D%0A%09%09values = %5Bgetattr(form, k).data for k in keys%5D%0A%09%09content = conn.process(values, table, keys)%0A%09%09conn.post(content)%0A%09%09flash(%0A%09%09%09'Awesome! You just posted a new %25s.' %25 table.replace('_', ' '),%0A%09%09%09'alert alert-success')%0A%0A%09else:%0A%09%09%5Bflash('%25s: %25s.' %25 (k.title(), v%5B0%5D), 'alert alert-error')%0A%09%09%09for k, v in form.errors.iteritems()%5D%0A%0A%09return redirect(url_for('.transaction'))%0A%0A%0A@cronus.errorhandler(409)%0Adef duplicate_values(e):%0A%09flash('Error: %25s' %25 e.orig%5B0%5D, 'alert alert-error')%0A%09return redirect(url_for('.transaction'))
 %0A

Create cronus views