def update(self): self.lock_ui(LABELS.loc.pt_info_downld_pt) BLOG.update_posts_cats_and_tags() self.unlock_ui() if not BLOG.posts: note(LABELS.loc.pt_info_no_posts, "info") self.refresh()
def new(self): t = self.get_title() if not BLOG.comments: # no comments ... user need to select a post to add the comment if not BLOG.posts: self.lock_ui(LABELS.loc.cm_info_downld_pt) upd = BLOG.update_posts_cats_and_tags() self.set_title( t ) self.unlock_ui() if not upd: return False self.set_title(LABELS.loc.cm_info_which_post) post_idx = selection_list( [ utf8_to_unicode( p['title'] )[:70] for p in BLOG.posts ], search_field=1) # idx may be -1 if list is empty and user press OK... strange ... why not None ? if post_idx is None or post_idx == -1: return False post_id = BLOG.posts[post_idx]['postid'] post_title = BLOG.posts[post_idx]['title'] else: comment_idx = self.body.current() post_id = BLOG.comments[comment_idx]['post_id'] post_title = BLOG.comments[comment_idx]['post_title'] self.dlg = NewComment( self.new_cbk, 0, post_id, utf8_to_unicode(post_title)) self.dlg.run()
def update(self, post_idx=None): k = self.status_list.keys() item = popup_menu(k, LABELS.loc.cm_pmenu_cmt_status) if item is None: return False comment_status = k[item] t = self.get_title() if not BLOG.posts: self.lock_ui(LABELS.loc.cm_info_downld_pt) upd = BLOG.update_posts_cats_and_tags() self.set_title(t) self.unlock_ui() if not upd: self.refresh() return False if post_idx is None: comment_set = popup_menu([LABELS.loc.cm_list_one_post, LABELS.loc.cm_list_all_posts], LABELS.loc.cm_pmenu_updt_for) if comment_set is None: return False if comment_set == 0: self.set_title( LABELS.loc.cm_info_which_post ) post_idx = selection_list([utf8_to_unicode( p['title'] )[:70] for p in BLOG.posts], search_field=1) self.set_title(t) if post_idx is None or post_idx == -1: return False else: post_idx = -1 self.lock_ui() upd = self.update_comment(post_idx, comment_status) self.set_title( LABELS.loc.wm_menu_comm ) self.unlock_ui() self.refresh() return upd