def index(): db = connect_db() seed_db(db) invoice = Invoice.objects().first() results = process_invoice(invoice=invoice, return_dict=True) labels = [ 'Date', 'Ending Def Rev', 'Cumulative Revenue', 'CR Sales Revenue', 'DR Deferred Revenue', 'DR Reserve Refunds', 'DR Contra-Revenue', 'CR Refunds Payable', 'DR Reserve Grace Period', 'CR Contra-Revenue' ] data = [] for (date, v) in sorted(results['revrec_schedule'].iteritems(), key=lambda (k, v): (k, v)): row = [ pretty_date(date), v['ending_defrev'], v['cumul_rev'], v['cr_rev'], v['dr_defrev'], v['dr_reserve_ref'], v['dr_contra_rev'], v['cr_ref_payable'], v['dr_reserve_graceperiod'], v['cr_contra_rev'] ] data.append(row) return render_template('base.html', labels=labels, data=data, invoice=invoice, payment=results['payment'], invoice_items=results['invoice_items'], refunds=results['refunds'], gp_notes=results['gp_notes'])
def index(): db = connect_db() seed_db(db) invoice = Invoice.objects().first() results = process_invoice(invoice=invoice, return_dict=True) labels = ['Date', 'Ending Def Rev', 'Cumulative Revenue', 'CR Sales Revenue', 'DR Deferred Revenue', 'DR Reserve Refunds', 'DR Contra-Revenue', 'CR Refunds Payable', 'DR Reserve Grace Period', 'CR Contra-Revenue'] data = [] for (date, v) in sorted(results['revrec_schedule'].iteritems(), key=lambda (k, v): (k, v)): row = [pretty_date(date), v['ending_defrev'], v['cumul_rev'], v['cr_rev'], v['dr_defrev'], v['dr_reserve_ref'], v['dr_contra_rev'], v['cr_ref_payable'], v['dr_reserve_graceperiod'], v['cr_contra_rev']] data.append(row) return render_template('base.html', labels=labels, data=data, invoice=invoice, payment=results['payment'], invoice_items=results['invoice_items'], refunds=results['refunds'], gp_notes=results['gp_notes'])
def setUp(self): """ Setup for the tests""" Cupcake.query.delete() db.session.commit() #uses seed.py's seed_db() to setup the db for tests seed_db()
def setUp(self): """ Setup a testing only database """ self.app = app.test_client() app.config['TESTING'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql:///testingdb' db.app = app db.init_app(app) db.create_all() seed_db()
def setUpClass(cls): app.config['TESTING'] = True app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@localhost:5432/blogly' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SQLALCHEMY_ECHO'] = True seed_db() connect_db(app) db.create_all() cls.client = app.test_client() with cls.client as client: pass
def setUp(self): """ Setup a testing only database """ self.app = app.test_client() app.config['TESTING'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql:///testingdb' db.app = app db.init_app(app) db.create_all() seed_db() u = User(first_name='Jane', last_name='Smith', email='*****@*****.**', username='******', password='******') db.session.add(u) db.session.commit() self.login('jsmith', 'test')
def setUp(self): seed_db(self.app) access_token = get_access_token(self.client, 'delete') self.headers = get_authorization_bearer(access_token)
def setUp(self): seed_db(self.app)
def create_tables(): db.create_all() seed_db()
from flask import Flask, request, jsonify, render_template from models import connect_db, db, Cupcake from secret_key import secret_key from seed import seed_db app = Flask(__name__) app.config['SECRET_KEY'] = secret_key app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres:///cupcakes' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False seed_db(app) @app.route('/') def get(): return render_template('index.html') @app.route('/api/cupcakes', methods=["GET", "POST"]) def cupcakes(): if request.method == "GET": cupcakes = Cupcake.get(all=True) return jsonify(cupcakes) elif request.method == "POST": data = request.get_json(silent=True) flavor = data.get('flavor')
def seed(): seed_db() print('Seed FINISHED successfully.')
'dr_reserve_ref': 0, 'dr_contra_rev': 0, 'dr_defrev': 0, 'dr_reserve_graceperiod': 0, 'cr_contra_rev': 0 }, reduce= 'function(doc,out){ \ out.cr_rev+=doc.cr_rev; \ out.ending_defrev+=doc.ending_defrev; \ out.cr_ref_payable+=doc.cr_ref_payable; \ out.dr_reserve_ref+=doc.dr_reserve_ref; \ out.dr_contra_rev+=doc.dr_contra_rev; \ out.dr_defrev+=doc.dr_defrev; \ out.dr_reserve_graceperiod+=doc.dr_reserve_graceperiod; \ out.cr_contra_rev+=doc.cr_contra_rev; \ }', finalize='') print 'Mapreduce results = ' pprint.pprint(results) """ ------------------------- COMMAND LINE EXECUTABLE ------------------------- """ if __name__ == '__main__': print 'Running revenue recognition module...' db = connect_db() seed_db(db) recognize_revenue() mapreduce(db)
def tearDownClass(cls): seed_db()
def get(self): #for a get request seed_db() self.response.headers['Content-Type'] = 'text/html' self.response.write( "<h1>Database seeded! .. Get it?</h1>") #the response