def get(self): template_values = { 'user': users.get_current_user(), 'admin': users.is_current_user_admin(), 'date_string': datetime.now().ctime(), 'url': users.create_logout_url(self.request.host_url), 'link_text': 'logout', } if self.request.get("word"): word = vocabulary_word.all().filter( "word =", self.request.get("word")).get() template_values['word'] = word template_values['related_kanji_list'] = [] for entry in kanji_entry.get(word.related_kanji): template_values['related_kanji_list'].append(entry.kanji) if not template_values['word']: template_values['message'] = 'no word found' next_page = 'template/vocab.html' else: search_string = self.request.get('search_string') # setup paged query if search_string: template_values['search_string'] = search_string vocab_query = PagedQuery( vocabulary_word.all().order('modified').filter( 'word =', search_string), PAGESIZE) else: vocab_query = PagedQuery( vocabulary_word.all().order('modified'), PAGESIZE) # retreive requested page number, defaulting to page 1 bookmark = self.request.get('bookmark') if bookmark: bookmark = int(bookmark) else: bookmark = 1 logging.info('bookmark=' + str(bookmark)) template_values['bookmark'] = str(bookmark) template_values['vocab_list'] = vocab_query.fetch_page(bookmark) template_values['page_links'] = PageLinks( page=bookmark, page_count=vocab_query.page_count(), url_root="/vocab", page_field="bookmark", page_range=10).get_links() next_page = 'template/vocablist.html' path = os.path.join(os.path.dirname(__file__), next_page) self.response.out.write(template.render(path, template_values))
def get(self,key_name): p = int(self.request.get('p','1')) album = get_or_404(Album.get_by_key_name,key_name) self.template_value['album']=album PAGESIZE = 500 if self.settings.theme <> 'default' else 24 imgs = PagedQuery(Image.all().filter('album = ',album),PAGESIZE) temp = imgs.fetch_page(p) self.template_value['prev']=p-1 if p>1 else None self.template_value['next'] = p +1 if len(temp) == PAGESIZE else None self.template_value['imgs'] = temp self.template_value['ps'] = range(1,imgs.page_count()+1) self.template_value['current_p'] = p self.render('album.html')
def get(self, key_name): album = get_or_404(Album.get_by_key_name, key_name) p = int(self.request.get("p", "1")) imgs = PagedQuery( Image.all().filter("album =", album).order('-created'), PAGESIZE) temp = imgs.fetch_page(p) self.template_value['album'] = album self.template_value['prev'] = p - 1 if p > 1 else None self.template_value['next'] = p + 1 if len(temp) == PAGESIZE else None self.template_value['imgs'] = temp self.template_value['ps'] = range(1, imgs.page_count() + 1) self.template_value['current_p'] = p self.render('album_manage.html')
def get(self): template_values = { 'user': users.get_current_user(), 'admin': users.is_current_user_admin(), 'date_string': datetime.now().ctime(), 'url': users.create_logout_url(self.request.host_url), 'link_text': 'logout', } if self.request.get('kanji'): kanji = kanji_entry.all().filter("kanji =", self.request.get('kanji')).get() template_values['kanji'] = kanji if not template_values['kanji']: template_values['message'] = 'no kanji found' next_page = 'template/kanji.html' else: # setup paged query kanji_query = PagedQuery(kanji_entry.all(), PAGESIZE) # retreive requested page number, defaulting to page 1 bookmark = self.request.get('bookmark') if bookmark: bookmark = int(bookmark) else: bookmark = 1 logging.info('bookmark=' + str(bookmark)) template_values['bookmark'] = str(bookmark) template_values['kanji_list'] = kanji_query.fetch_page(bookmark) template_values['page_links'] = PageLinks( page=bookmark, page_count=kanji_query.page_count(), url_root="/kanji", page_field="bookmark", page_range=10).get_links() next_page = 'template/kanjilist.html' path = os.path.join(os.path.dirname(__file__), next_page) self.response.out.write(template.render(path, template_values))