def submit_success(self, appstruct): """ handle successfull payment mode configuration """ for mode in PaymentMode.query(): self.dbsession.delete(mode) for data in appstruct['paymentmodes']: mode = PaymentMode(label=data) self.dbsession.add(mode) self.request.session.flash(self.validation_msg) return HTTPFound(self.request.route_path("admin_paymentmode"))
def before(self, form): """ Add appstruct to the current form object """ appstruct = [mode.label for mode in PaymentMode.query()] form.set_appstruct({'paymentmodes': appstruct}) populate_actionmenu(self.request)
def before(self, form): """ Add appstruct to the current form object """ appstruct = [mode.label for mode in PaymentMode.query()] form.set_appstruct({'paymentmodes':appstruct}) populate_actionmenu(self.request)
def downgrade(): for p in PaymentMode.query(): DBSESSION().delete(p) for p in Payment.query(): if p.mode == u"par chèque": p.mode = u"cheque" elif p.mode == u"par virement": p.mode = u"virement" elif p.mode == u"en liquide": p.mode = u"liquide" else: p.mode = "inconnu" DBSESSION().merge(p)
def downgrade(): from autonomie.models.task.invoice import PaymentMode, Payment for p in PaymentMode.query(): DBSESSION().delete(p) for p in Payment.query(): if p.mode == u"par chèque": p.mode = u"cheque" elif p.mode == u"par virement": p.mode = u"virement" elif p.mode == u"en liquide": p.mode = u"liquide" else: p.mode = "inconnu" DBSESSION().merge(p)
def upgrade(): for payment in Payment.query(): if payment.mode in (u"cheque", u"CHEQUE"): payment.mode = u"par chèque" elif payment.mode in (u"virement", u"VIREMENT"): payment.mode = u"par virement" elif payment.mode in (u"liquide", u"LIQUIDE"): payment.mode = u"en liquide" else: payment.mode = "mode de paiement inconnu" DBSESSION().merge(payment) for mode in (u"par chèque", u"par virement", u"en liquide"): pmode = PaymentMode(label=mode) DBSESSION().add(pmode)
def add_payment_mode(label): p = PaymentMode(label=label) session = DBSESSION() session.add(p) session.flush()
def deferred_payment_mode_validator(node, kw): return colander.OneOf([mode.label for mode in PaymentMode.query()])
def deferred_payment_mode_widget(node, kw): """ dynamically retrieves the payment modes """ modes = [(mode.label, mode.label) for mode in PaymentMode.query()] return deform.widget.SelectWidget(values=modes)
def mode(dbsession): from autonomie.models.task.invoice import PaymentMode mode = PaymentMode(label=u"Chèque") dbsession.add(mode) dbsession.flush() return mode