def get(self, pid=0): if pid: return self.succ(Purchase.get(pid)) g_dict = {} for g in set(PURCHASE.FLOW).difference([PURCHASE.FLOW_ONE]): g_dict[g] = [user.uid for user in Group.get_users(g)] unfinished = Purchase.unfinished(g_dict) return self.succ(unfinished)
def get(self): submit = request.args resp = excel.make_response_from_records(Purchase.export(submit), "xlsx") resp.headers[ "Content-Disposition"] = "attachment; filename=purchase.xlsx" return resp
def _to_dict(contract): _dict = contract.to_dict() from bmp.models.purchase import Purchase purchase = contract.purchase if purchase: purchase = Purchase._to_dict(purchase) purchase.pop("imgs") purchase.pop("contract") _dict["purchase"] = purchase return _dict
def search(self, page=None, pre_page=None): submit = self.request() return self.succ(Purchase.search(submit, page, pre_page))
def delete(self, pid): Purchase.delete(pid) return self.succ()
def post(self): submit = self.__submit() purchase = Purchase.add(submit) return self.succ()
def save(self): submit = self.__submit() Purchase.edit(submit) return self.succ()
def passed(self, page=0, pre_page=None): return self.succ(Purchase.passed(page, pre_page))
def finished(self, page=0, pre_page=None): return self.succ(Purchase.finished(page, pre_page))
def saved(self, page=0, pre_page=None, pid=0): if pid: return self.succ(Purchase.get(pid)) page = Purchase.drafts(page, pre_page) return self.succ(page)
def approval(self, pid): Purchase.approval(pid) Mail().to(Purchase.query.filter(Purchase.id == pid).one()) return self.succ()
def get(self): submit = request.args resp = excel.make_response_from_records(Purchase.export(submit), "xlsx") resp.headers["Content-Disposition"] = "attachment; filename=purchase.xlsx" return resp