def content(self): self.creator = None self.num = 1 # don't let this shit to distract you global session self.user = session.get_user() if self.user.posts: # show posts disp = lib.Displayer(self.user.posts, UpdatePostPage.page, UpdatePostPage.ppp) disp.show(author=False, content=False, id_=True) # Number of pages self.num = disp.get_page_amount() lib.print_alert('Number of pages: %s\nCurrent Page: %s' % \ (self.num, UpdatePostPage.page)) if UpdatePostPage.is_typing: print('Type in id of post you want to update:') self.select = -1 ids = [post.id for post in self.user.posts] while 1: try: self.select = int(input(settings.promt)) except ValueError: print("Not an integer!") continue else: if self.select in ids: break else: print('Enter correct id!') continue self.creator = PostCreator() self.creator.create() # allow same name for title self.oldpost = ramdb.get_by_id('posts', self.select) if self.oldpost.title == self.creator.title: errmsg = 'Post with such title already exists!' if self.creator.response.get_message() == errmsg: # forcing to be a valid post self.creator.response['is_valid'] = True else: print('You have not any posts yet!')
def content(self): self.num = 1 # don't let this self.select = -1 # distract you global session self.user = session.get_user() if self.user.posts: disp = lib.Displayer(self.user.posts, self.currentpage, self.postsperpage) disp.show(author=False, content=False, id_=True) # Number of pages self.num = disp.get_page_amount() lib.print_alert('Number of pages: %s\nCurrent Page: %s' % \ (self.num, self.currentpage)) if self.is_typing: print('Type in id of post you want to delete:') ids = [post.id for post in self.user.posts] while 1: try: self.select = int(input(settings.promt)) except ValueError: print("Not an integer!") continue else: if self.select in ids: break else: print('Enter correct id!') continue # Warn user print('ID of post you have selected is %d' % self.select) print( 'If you delete this post, you will lose your post forever!' ) else: print('You have not any posts yet!')
def content(self): global session user = session.get_user() lib.print_alert('Showing posts written by %s' % user.username) posts = user.posts posts = posts[::-1] # from new to old # Posts if posts: disp = lib.Displayer(posts, self.currentpage, self.postsperpage) disp.show(author=False) # Number of pages self.num = disp.get_page_amount() lib.print_alert('Number of pages: %s\nCurrent Page: %s' % \ (self.num, self.currentpage)) else: self.num = 1 lib.print_alert('Number of pages: %s\nCurrent Page: %s' % \ (self.num, self.currentpage))
def content(self): # User info global session lib.print_alert('Logged in as %s' % session.get_username()) # Posts posts = session.get_posts() posts = posts[::-1] # show from new to old if posts: disp = lib.Displayer(posts, self.currentpage, self.postsperpage) disp.show() # Number of pages self.num = disp.get_page_amount() lib.print_alert('Number of pages: %s\nCurrent Page: %s' % \ (self.num, self.currentpage)) else: self.num = 1 lib.print_alert('Number of pages: %s\nCurrent Page: %s' % \ (self.num, self.currentpage))