Moving requests to resource
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
from datetime import date
|
||||
|
||||
from account.models import Account
|
||||
from account.resource import AccountResource
|
||||
from account.schemas import AccountCreate, CategoryCreate
|
||||
|
||||
def inject_fixtures(session):
|
||||
for f in fixtures_account:
|
||||
f = prepare_dict(session, f)
|
||||
schema = AccountCreate(**f)
|
||||
Account.create(schema, session)
|
||||
AccountResource.create(schema, session)
|
||||
|
||||
for f in fixtures_category:
|
||||
f = prepare_dict(session, f)
|
||||
schema = CategoryCreate(**f)
|
||||
Account.create(schema, session)
|
||||
AccountResource.create(schema, session)
|
||||
|
||||
def prepare_dict(session, entry):
|
||||
if entry['parent_path']:
|
||||
parent = Account.get_by_path(session, entry['parent_path'])
|
||||
parent = AccountResource.get_by_path(session, entry['parent_path'])
|
||||
entry['parent_account_id'] = parent.id
|
||||
else:
|
||||
entry['parent_account_id'] = None
|
||||
|
||||
Reference in New Issue
Block a user