def create_page(self, issue: Issue, jira_man: JiraManager, with_comments: bool = False): """ Creation of a new Notion page """ try: title_key = issue.fields.parent.key except Exception: title_key = issue.key title = title_key + " - " + issue.fields.summary subpage = self._page.children.add_new(PageBlock, title=title) subpage.children.add_new(BookmarkBlock, link=jira_man.get_url(issue.key), title=issue.key, description=issue.fields.summary) subpage.children.add_new(TextBlock, title=issue.fields.description) subpage.children.add_new(DividerBlock) subpage.children.add_new(HeaderBlock, title="İşler") subpage.children.add_new(TodoBlock, title="...") subpage.children.add_new(DividerBlock) subpage.children.add_new(HeaderBlock, title="Bittiğinde Jira'ya yazılacak") subpage.children.add_new(SubheaderBlock, title="Request notu") subpage.children.add_new(TextBlock, title="...") subpage.children.add_new(SubheaderBlock, title="Soft Config") subpage.children.add_new(TextBlock, title="...") subpage.children.add_new(SubheaderBlock, title="Yorum") subpage.children.add_new(TextBlock, title="...") if with_comments: subpage.children.add_new(DividerBlock) subpage.children.add_new(HeaderBlock, title="Mevcut yorumlar") for i in range(self._config.notion_comment_count): comment_idx = issue.fields.comment.total - 1 - i if comment_idx < 0: break current_comment = issue.fields.comment.comments[comment_idx] subpage.children.add_new(QuoteBlock, title=current_comment.body) subpage.children.add_new(DividerBlock)
def create_note(self, issue: Issue, jira_man: JiraManager): # ______________________________ # Note object note = ttypes.Note() note.notebookGuid = self._notebook.guid # ______________________________ # Attributes issue_url = jira_man.get_url(issue.key) note.attributes = ttypes.NoteAttributes(sourceURL=issue_url) note.tagNames = self._config.evernote_tags # ______________________________ # Title try: note.title = issue.fields.parent.key + " - " + self._get_safe_text(issue.fields.summary) except: note.title = issue.key + " - " + self._get_safe_text(issue.fields.summary) # ______________________________ # Body # Header body = '<?xml version="1.0" encoding="UTF-8"?>' body += '<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">' body += '<en-note>' # URL body += 'Madde: <a href="' + issue_url + '">' + issue_url + '</a><br/>' try: parent_url = jira_man.get_url(issue.fields.parent.key) body += 'Üst madde: <a href="' + parent_url + '">' + parent_url + '</a><br/>' except: pass # Summary summary = "" try: summary = self._get_safe_text(issue.fields.summary) except: pass try: summary2 = self._get_safe_text(issue.fields.description) summary += "<br/><br/>" + summary2 except: pass body += '<br/>' + summary + '<br/><br/>' # To do body += '<hr/><b>İşler</b><br/><br/>' body += '<en-todo/>Jira''yı ilerlet<br/><br/>' body += '<en-todo/>Geliştirme<br/><br/>' body += '<en-todo/>EPC + Task Release<br/><br/>' body += '<en-todo/>Teknik test<br/><br/>' body += '<en-todo/>Jira''yı ilerlet ve yorum yaz<br/><br/>' # Comments for i in range(self._config.evernote_comment_count): comment_idx = issue.fields.comment.total - 1 - i if comment_idx < 0: break if i == 0: body += '<hr/><b>Son yorumlar</b><br/><br/>' current_comment = issue.fields.comment.comments[comment_idx] comment_body = self._get_safe_text(current_comment.body).replace("\r\n", "<br/>") body += '<b>' + current_comment.author.displayName + ", " + current_comment.created + ':</b> <br/>' + comment_body + "<br/><br/>" # Bottom body += '<br/><hr/><br/>' # Finish body += '</en-note>' note.content = body # ______________________________ # Flush self._note_store.createNote(note)
def create_page(self, issue: Issue, jira_man: JiraManager, with_comments: bool = False): """ Creation of a new Notion page """ global _PAGE_URL # Get details from JIRA try: title_key = issue.fields.parent.key except Exception: title_key = issue.key title = title_key + " - " + issue.fields.summary link = jira_man.get_url(issue.key) description = issue.fields.description if description is None: description = "(No description)" # Post to Notion headers = { "Content-Type": "application/json", "Notion-Version": self._config.notion_official_version, "Authorization": "Bearer " + self._config.notion_official_token } body = { "parent": { "database_id": self._config.notion_official_database }, "properties": { "title": { "title": [{ "text": { "content": title } }] }, "URL": { "type": "url", "url": link } }, "children": [{ "object": "block", "type": "heading_1", "heading_1": { "text": [{ "type": "text", "text": { "content": "Comments" } }] } }, { "object": "block", "type": "paragraph", "paragraph": { "text": [{ "type": "text", "text": { "content": "..." } }] } }] } response = requests.post(_PAGE_URL, data=json.dumps(body), headers=headers) if response.status_code != 200: raise Exception("Notion API error: " + response.reason)