Fixed session retrieving.
This commit is contained in:
parent
26cf3610fe
commit
688755c542
@ -14,7 +14,7 @@ def get_accounts():
|
||||
"""
|
||||
Returns accounts with their solds.
|
||||
"""
|
||||
session = db.create_scoped_session()
|
||||
session = db.session
|
||||
|
||||
query = session.query(
|
||||
Account.id.label("id"),
|
||||
@ -36,7 +36,7 @@ def get_accounts():
|
||||
|
||||
@app.route("/api/accounts/<account_id>/months")
|
||||
def get_months(account_id):
|
||||
session = db.create_scoped_session()
|
||||
session = db.session
|
||||
|
||||
query = session.query(
|
||||
distinct(extract("year", Entry.value_date)).label("year"),
|
||||
@ -50,7 +50,7 @@ def get_months(account_id):
|
||||
|
||||
@app.route("/api/accounts", methods=["PUT"])
|
||||
def add_account():
|
||||
session = db.create_scoped_session()
|
||||
session = db.session
|
||||
|
||||
try:
|
||||
account = Account(request.json['name'], request.json['authorized_overdraft'])
|
||||
@ -66,7 +66,7 @@ def add_account():
|
||||
|
||||
@app.route("/api/accounts/<account_id>", methods=["PUT"])
|
||||
def update_account(account_id):
|
||||
session = db.create_scoped_session()
|
||||
session = db.session
|
||||
|
||||
try:
|
||||
account = session.query(Account).filter(Account.id == account_id).first()
|
||||
@ -84,7 +84,7 @@ def update_account(account_id):
|
||||
|
||||
@app.route("/api/accounts/<account_id>", methods=["DELETE"])
|
||||
def delete_account(account_id):
|
||||
session = db.create_scoped_session()
|
||||
session = db.session
|
||||
|
||||
try:
|
||||
account = session.query(Account).filter(Account.id == account_id).first()
|
||||
|
@ -17,7 +17,7 @@ def get_entries(account_id, year, month):
|
||||
"""
|
||||
Return entries for an account, year, and month.
|
||||
"""
|
||||
session = db.create_scoped_session()
|
||||
session = db.session
|
||||
|
||||
query = session.query(
|
||||
Entry
|
||||
@ -46,7 +46,7 @@ def get_entries(account_id, year, month):
|
||||
|
||||
@app.route("/api/entries", methods=["PUT"])
|
||||
def add_entry():
|
||||
session = db.create_scoped_session()
|
||||
session = db.session
|
||||
|
||||
try:
|
||||
entry = Entry(
|
||||
@ -68,7 +68,7 @@ def add_entry():
|
||||
|
||||
@app.route("/api/entries/<entry_id>", methods=["PUT"])
|
||||
def update_entry(entry_id):
|
||||
session = db.create_scoped_session()
|
||||
session = db.session
|
||||
|
||||
try:
|
||||
entry = session.query(Entry).filter(Entry.id == entry_id).first()
|
||||
@ -91,7 +91,7 @@ def update_entry(entry_id):
|
||||
|
||||
@app.route("/api/entries/<entry_id>", methods=["DELETE"])
|
||||
def delete_entry(entry_id):
|
||||
session = db.create_scoped_session()
|
||||
session = db.session
|
||||
|
||||
try:
|
||||
entry = session.query(Entry).filter(Entry.id == entry_id).first()
|
||||
|
Loading…
Reference in New Issue
Block a user