示例#1
0
文件: views.py 项目: benmao/xfox
 def get(self,slug,key,p="1"):
     dis = get_or_404(Discussion.get_discussion_by_key,slug,key)
     p = int(p)
     
     #check ACL
     check_roles(self,dis.role)
     
     #handler visit log
     if not self.user is None:
         key = "%s%s" %(self.user.name_lower,self.p)
         logs = memcache.get(":visitlogs:")
         if logs is None:
             logs = set([])
         logs.add(key)
         memcache.set(":visitlogs:",logs,3600)
     
     self.template_value['f_tag']={'key':dis.tag_slug,'title':dis.tag_title,'show':'G' in dis.role,'post':True}
     self.template_value['disviews']=ShardCount.get_increment_count("disviews:"+key,"disviews")
     self.template_value['dis']=dis
     bookmark = Bookmark.get_bookmark(self.user,dis) if self.user else None
     self.template_value['bookmark'] = bookmark
     
     #comment page
     comments = PagedQuery(Comment.get_by_dis(dis),self.setting.comment_pagesize)
     temp = comments.fetch_page(p)
     self.template_value['prev']= p-1 if p>1 else None
     self.template_value['next']= p+1 if  len(temp) == self.setting.comment_pagesize else None
     self.template_value['comments'] = temp
     self.template_value['p']=p
     self.render("dis.html")
示例#2
0
文件: views.py 项目: benmao/xfox
 def get(self):
     p = int(self.request.get("p","1"))
     users = PagedQuery(User.get_all(),PAGESIZE)
     
     self.template_value['prev'] = p-1 if p >1 else None
     self.template_value['next'] = p+1 if users.has_page(p+1) else None
     self.template_value['users'] = users.fetch_page(p)
     self.render('user.html')
示例#3
0
    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))
示例#4
0
文件: main.py 项目: v998/sa3album
 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')
示例#5
0
 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')
示例#6
0
文件: views.py 项目: benmao/xfox
 def get(self):
     p =int(self.request.get("p","1"))
     cat = self.request.get("cat",None)
     tags = Tag.get_all()
     if not cat is None:
         tags.filter("category =",Category.get(cat))
     q = PagedQuery(tags,PAGESIZE)
     
     self.template_value['cat'] = cat
     self.template_value['prev'] = p-1 if p>1 else None
     self.template_value['next'] = p+1 if q.has_page(p+1) else None
     self.template_value['tags'] = q.fetch_page(p)
     self.render('tag.html')
示例#7
0
    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))
示例#8
0
    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 ) )
示例#9
0
    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))
示例#10
0
文件: views.py 项目: melice/forumx
    def get(self, slug, key, p="1"):
        dis = get_or_404(Discussion.get_discussion_by_key, slug, key)
        p = int(p)

        # check ACL
        check_roles(self, dis.role)

        # handler visit log
        if not self.user is None:
            key = "%s%s" % (self.user.name_lower, self.p)
            logs = memcache.get(":visitlogs:")
            if logs is None:
                logs = set([])
            logs.add(key)
            memcache.set(":visitlogs:", logs, 3600)

        self.template_value["f_tag"] = {
            "key": dis.tag_slug,
            "title": dis.tag_title,
            "show": "G" in dis.role,
            "post": True,
        }
        # self.template_value['disviews']=
        dis.count_view = ShardCount.get_increment_count("disviews:" + key, "disviews")
        dis.put()
        self.template_value["dis"] = dis
        bookmark = Bookmark.get_bookmark(self.user, dis) if self.user else None
        self.template_value["bookmark"] = bookmark

        # comment page
        comments = PagedQuery(Comment.get_by_dis(dis), self.setting.comment_pagesize)
        temp = comments.fetch_page(p)
        self.template_value["prev"] = p - 1 if p > 1 else None
        self.template_value["next"] = p + 1 if len(temp) == self.setting.comment_pagesize else None
        self.template_value["comments"] = temp
        self.template_value["p"] = p
        self.render("dis.html")