def filter(cls, oid=None, account=None, issue=None, include_private=False): "Look up offers." (all_ids, all_accounts, all_issues) = (False, False, False) if not oid: all_ids = True if account: uid = account.id else: uid = None all_accounts = True if issue: iid = issue.id else: iid = None all_issues = True result = [] with cls.db.conn.cursor() as curs: curs.execute( '''SELECT account, maturity, matures, contract_type, issue, url, title, side, price, quantity, id, created, all_or_nothing FROM offer_overview WHERE (id = %s OR %s) AND (account = %s OR %s) AND (issue = %s OR %s) ''', (oid, all_ids, uid, all_accounts, iid, all_issues)) for row in curs.fetchall(): (uid, mid, matures, cid, iid, url, title, side, price, quantity, oid, created, all_or_nothing) = row account = Account(uid=uid) issue = Issue(url=url, iid=iid, title=title) if (not include_private) and (not issue.is_public): continue maturity = Maturity(matures, mid) ctype = ContractType(issue, maturity, cid) result.append( cls(account, ctype, side, price, quantity, oid, created, all_or_nothing)) return result
def issue_by_url(self, url, title=None, is_open=True): return Issue.by_url(self, url, title, is_open)
def issue_by_id(self, iid): return Issue.by_id(self, iid)
def get_issues(self, include_private=False, project=None): return list(Issue.get_all(self, include_private, project))
def add_issue(self, user, issue_url): return Issue(url=issue_url).persist(self)
def cleanup(self, contract_types=[]): Offer.cleanup(self, contract_types) ContractType.cleanup(contract_types) Maturity.cleanup(self) Issue.cleanup(self)
def get_issues(self, include_private=False): return list(Issue.get_all(self, include_private))