def deferred_company_choices(node, kw): """ return a deferred company selection widget """ values = DBSESSION().query(Company.id, Company.name).all() if default_option: values.insert(0, default_option) return deform.widget.Select2Widget(values=values, **widget_options)
def deferred_company_id_widget(node, kw): """ Defer the company id selection widget """ datas = DBSESSION().query(distinct(AccountingOperation.company_id)).all() datas = zip(*datas)[0] values = DBSESSION().query(Company.id, Company.name).all() values.insert(0, ('', u"Toutes les entreprises")) return deform.widget.Select2Widget(values=values)
def deferred_company_choices(node, kw): """ return a deferred company selection widget """ values = DBSESSION().query(Company.id, Company.name).all() if default_option: values.insert(0, default_option) return deform.widget.Select2Widget( values=values, **widget_options )
def deferred_company_id_widget(node, kw): """ Defer the company id selection widget """ datas = DBSESSION().query( distinct(AccountingOperation.company_id) ).all() datas = zip(*datas)[0] values = DBSESSION().query(Company.id, Company.name).all() values.insert(0, ('', u"Toutes les entreprises")) return deform.widget.Select2Widget(values=values)
def insert(cls, item, new_order): """ Place the item at the given index :param obj item: The item to move :param int new_order: The new index of the item """ items = DBSESSION().query(cls).filter_by(active=True).filter( cls.id != item.id).order_by(cls.order).all() items.insert(new_order, item) for index, item in enumerate(items): item.order = index DBSESSION().merge(item)
def insert(cls, item, new_order): """ Place the item at the given index in the hierarchy of items of the same category :param obj item: The item to place :param int new_order: The index where to place the item """ items = DBSESSION().query(cls).filter_by( category_id=item.category_id).filter_by(active=True).filter( cls.id != item.id).order_by(cls.order).all() items.insert(new_order, item) for index, item in enumerate(items): item.order = index DBSESSION().merge(item)
def insert(cls, item, new_order): """ Place the item at the given index :param obj item: The item to move :param int new_order: The new index of the item """ items = DBSESSION().query( cls ).filter_by( active=True ).filter(cls.id != item.id).order_by(cls.order).all() items.insert(new_order, item) for index, item in enumerate(items): item.order = index DBSESSION().merge(item)
def insert(cls, item, new_order): """ Place the item at the given index in the hierarchy of items of the same category :param obj item: The item to place :param int new_order: The index where to place the item """ items = DBSESSION().query( cls ).filter_by( category_id=item.category_id ).filter_by( active=True ).filter(cls.id != item.id).order_by(cls.order).all() items.insert(new_order, item) for index, item in enumerate(items): item.order = index DBSESSION().merge(item)