def send_datadoc_access_request_notification(doc_id, uid, session=None): requestor = user_logic.get_user_by_id(uid, session=session) data_doc = logic.get_data_doc_by_id(doc_id, session=session) environment = data_doc.environment data_doc_title = data_doc.title or "Untitled" doc_url = f"{QuerybookSettings.PUBLIC_URL}/{environment.name}/datadoc/{doc_id}/" owner = user_logic.get_user_by_id(data_doc.owner_uid, session=session) doc_editors = [owner] writer_uids = [ writer.uid for writer in logic.get_data_doc_writers_by_doc_id(doc_id) ] doc_editors.extend(user_logic.get_users_by_ids(writer_uids)) requestor_username = requestor.get_name() for user in doc_editors: notify_user( user=user, template_name="datadoc_access_request", template_params=dict( username=requestor_username, data_doc_title=data_doc_title, doc_url=doc_url, ), )
def send_board_access_request_notification(board_id, uid, session=None): requestor = user_logic.get_user_by_id(uid, session=session) board = Board.get(id=board_id, session=session) environment = board.environment board_url = f"{QuerybookSettings.PUBLIC_URL}/{environment.name}/list/{board_id}/" owner = user_logic.get_user_by_id(board.owner_uid, session=session) doc_editors = [owner] writer_uids = [ writer.uid for writer in logic.get_board_editors_by_board_id(board_id) ] doc_editors.extend(user_logic.get_users_by_ids(writer_uids)) requestor_username = requestor.get_name() for user in doc_editors: notify_user( user=user, template_name="board_access_request", template_params=dict( username=requestor_username, board_name=board.name, board_url=board_url, ), )
def batch_get_user_info(uids): return logic.get_users_by_ids(uids)