def helper_card_to_checklist(_, data): ppcurses.post(f"/api/v1/cards/{data['parent_card_id']}/checklist", {'title': data['checklist_title']} ) ppcurses.delete(f"/api/v1/cards/{data['new_card_id']}") return True
def checklist_to_card(self, char): try: index = bigindex.index(char) except ValueError: return False if self.data.id is None: return False if self.data.checklist is None: return False try: checklist = self.data.checklist[index] except IndexError: return False endpoint = f"/api/v1/checklists/{self.data.checklist_id}/checklist-item/{checklist['id']}/convert-to-card" data = { "column_id": ppcurses.memstore['columnstate'].current_item['id'], "board_id": ppcurses.memstore['board'].id } planlet_id = ppcurses.memstore['planletstate'].current_item['id'] if planlet_id != -1: data['planlet_id'] = planlet_id response = ppcurses.post(endpoint, data) if response: ppcurses.mkundo( 'cardliststate', ppcurses.data.helper_card_to_checklist, None, { 'new_card_id': response['id'], 'parent_card_id': self.data.id, 'checklist_title': checklist['title'] }) return response
def move_to_planlet(self): if self.data.id is None: return False board_id = ppcurses.memstore['board'].id column_id = ppcurses.memstore['columnstate'].current_item['id'] selection = ppcurses.hover.select_one( 'planlets', lambda **kwargs: ppcurses.memstore['planletstate'].data) if (selection is None) or ( selection['id'] == ppcurses.memstore['planletstate'].current_item['id']): return logger.info('Moving card to %s', selection) endpoint = f"/api/v1/boards/{board_id}/move-cards" if selection['id'] == -1: selection['id'] = None data = { "card_ids": [self.data.id], "column_id": column_id, "after_card": None, "swimlane": { "type": "planlet_id", "value": selection['id'] } } response = ppcurses.post(endpoint, data) if response: if ppcurses.memstore['planletstate'].current_item['id'] == -1: planlet_id = None else: planlet_id = ppcurses.memstore['planletstate'].current_item[ 'id'] ppcurses.mkundo( 'planletstate', ppcurses.post, endpoint, { "card_ids": [self.data.id], "column_id": column_id, "after_card": None, "swimlane": { "type": "planlet_id", "value": planlet_id } }) return response
def add_checklist(self): if self.data.id is None: return False endpoint = f"/api/v1/cards/{self.data.id}/checklist" checklist, _ = ppcurses.hover.textbox('add checklist item') if checklist is None: return data = {'title': checklist} response = ppcurses.post(endpoint, data) if response: for each in response['checklist']['items'][-1::-1]: if each['title'] == checklist: break else: return response logger.error(each) ppcurses.mkundo( 'carddetailstate', ppcurses.delete, f"/api/v1/cards/{self.data.id}/checklist/{each['id']}/") return response
def create_card(self): project_id = ppcurses.dbstore['project_id'] endpoint = f"/api/v1/projects/{project_id}/cards/create-new" board_id = ppcurses.memstore['board'].id planlet_id = ppcurses.memstore['planletstate'].current_item['id'] column_id = ppcurses.memstore['columnstate'].current_item['id'] if (board_id is None) or (planlet_id is None) or (column_id is None): return False card_name, _ = ppcurses.hover.textbox('card name') if card_name is None: return False data = { "column_id": column_id, "board_id": board_id, "title": card_name } if planlet_id != -1: data['planlet_id'] = planlet_id response = ppcurses.post(endpoint, data) if response: ppcurses.mkundo('cardliststate', ppcurses.delete, f"/api/v1/cards/{response['id']}") return response