async def set_hidden(domain_id: str, pid: document.convert_doc_id, hidden: bool): pdoc = await document.set(domain_id, document.TYPE_PROBLEM, pid, hidden=hidden) if not pdoc: raise error.DocumentNotFoundError(domain_id, document.TYPE_PROBLEM, pid) return pdoc
async def get_reply(domain_id: str, drid: document.convert_doc_id, did=None): drdoc = await document.get(domain_id, document.TYPE_DISCUSSION_REPLY, drid) if not drdoc or (did and drdoc['parent_doc_id'] != did): raise error.DocumentNotFoundError(domain_id, document.TYPE_DISCUSSION_REPLY, drid) return drdoc
async def set_solution(domain_id: str, psid: document.convert_doc_id, content: str): validator.check_content(content) psdoc = await document.set(domain_id, document.TYPE_PROBLEM_SOLUTION, psid, content=content) if not psdoc: raise error.DocumentNotFoundError(domain_id, document.TYPE_PROBLEM_SOLUTION, psid) return psdoc
async def set_data(domain_id: str, pid: document.convert_doc_id, data: objectid.ObjectId): pdoc = await document.set(domain_id, document.TYPE_PROBLEM, pid, data=data) if not pdoc: raise error.DocumentNotFoundError(domain_id, document.TYPE_PROBLEM, pid) await bus.publish('problem_data_change', {'domain_id': domain_id, 'pid': pid}) return pdoc
async def get_solution(domain_id: str, psid: document.convert_doc_id, pid=None): psdoc = await document.get(domain_id, document.TYPE_PROBLEM_SOLUTION, psid) if not psdoc or (pid and psdoc['parent_doc_id'] != pid): raise error.DocumentNotFoundError(domain_id, document.TYPE_PROBLEM_SOLUTION, psid) return psdoc
async def set_data(domain_id: str, pid: document.convert_doc_id, data: objectid.ObjectId): pdoc = await document.set(domain_id, document.TYPE_PROBLEM, pid, data=data) if not pdoc: raise error.DocumentNotFoundError(domain_id, document.TYPE_PROBLEM, pid) return pdoc
async def get(domain_id: str, tid: objectid.ObjectId): tdoc = await document.get(domain_id, document.TYPE_CONTEST, tid) if not tdoc: raise error.DocumentNotFoundError(domain_id, document.TYPE_CONTEST, tid) return tdoc
async def get(domain_id: str, doc_type: int, tid: objectid.ObjectId): tdoc = await document.get(domain_id, doc_type, tid) if not tdoc: raise error.DocumentNotFoundError(domain_id, doc_type, tid) return tdoc
async def get(fid: objectid.ObjectId): doc = await document.get(STORE_DOMAIN_ID, document.TYPE_USERFILE, fid) if not doc: raise error.DocumentNotFoundError(STORE_DOMAIN_ID, document.TYPE_USERFILE, fid) return doc