# old one
if id is None:
e = model.Expenditure()
+ meta.Session.add(e)
else:
e = meta.Session.query(model.Expenditure).get(id)
# Set the fields that were submitted
update_sar(e, self.form_result)
- meta.Session.save_or_update(e)
if id is None:
e.even_split()
if id is None:
t = model.Transfer()
+ meta.Session.add(t)
else:
t = meta.Session.query(model.Transfer).get(id)
update_sar(t, self.form_result)
- meta.Session.save_or_update(t)
meta.Session.commit()
h.flash('Transfer recorded.')
def init_model(engine):
"""Call me before using any of the tables or classes in the model"""
- sm = orm.sessionmaker(autoflush=True, transactional=True, bind=engine)
+ sm = orm.sessionmaker(autoflush=True, bind=engine)
meta.engine = engine
meta.Session = orm.scoped_session(sm)
for user, share in amounts_dict.iteritems():
s = Split(self, user, share)
- meta.Session.save(s)
+ meta.Session.add(s)
__all__ = ['Expenditure']
SetupCommand('setup-app').run([config['__file__']])
test_user = bluechips.model.User(u'root', u'Charlie Root', False)
- meta.Session.save(test_user)
+ meta.Session.add(test_user)
meta.Session.commit()
def tearDownPackage():
n = random.randint(2, 5)
for i in xrange(n):
u = bluechips.model.User(sample_users[i].lower(), resident=True)
- meta.Session.save(u)
+ meta.Session.add(u)
meta.Session.commit()
def createExpenditures(n=None):
for i in xrange(n):
e = bluechips.model.Expenditure(random.choice(users),
Currency(random.randint(1000, 100000)))
- meta.Session.save(e)
+ meta.Session.add(e)
e.even_split()
meta.Session.commit()
e = model.Expenditure(meta.Session.query(model.User).first(),
Currency("100"))
- meta.Session.save(e)
+ meta.Session.add(e)
e.even_split()
meta.Session.commit()
users = meta.Session.query(model.User).all()
e = model.Expenditure(users[0], Currency("100"))
- meta.Session.save(e)
+ meta.Session.add(e)
split_dict = {users[0]: Decimal("20"),
users[1]: Decimal("80")}
users = meta.Session.query(model.User).all()
e = model.Expenditure(users[0], Currency("100.00"))
- meta.Session.save(e)
+ meta.Session.add(e)
split_dict = {users[0]: Decimal(10),
users[1]: Decimal(15)}
users = meta.Session.query(model.User).all()
e = model.Expenditure(users[0], Currency("100.00"))
- meta.Session.save(e)
+ meta.Session.add(e)
# Force a split that will result in needing to distribute
# pennies