예제 #1
0
파일: views.py 프로젝트: benmao/xfox
 def get(self):
     
     action = self.request.get("action")
     key = self.request.get("key")
     dis = Discussion.get_by_key_name(key)
     if dis is None:
         return self.error(404)
     if not action in ['un','do']:
         return self.error(404)
     if action =='un':
         Bookmark.un_bookmark(self.user,dis)
     else:
         Bookmark.do_bookmark(self.user,dis)
     self.redirect(dis.url)
예제 #2
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")
예제 #3
0
파일: views.py 프로젝트: benmao/xfox
 def get(self, name):
     u = User.get_user_by_name(name)
     if u is None:
         return self.error(404)
     self.template_value["u"] = u
     self.template_value["is_following"] = UserFollow.is_following(self.user, name)
     self.template_value["recent_dis"] = Discussion.get_recent_dis(u)
     self.template_value["recent_comment"] = RecentCommentLog.get_recent_comment(u)
     self.template_value["recent_bookmark"] = Bookmark.get_recent_bookmark(u)
     self.template_value["f_tag"] = {"key": "u/%s" % u.name_lower, "title": u.name, "show": True}
     self.render("user.html")
예제 #4
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")
예제 #5
0
파일: main.py 프로젝트: benmao/xfox
 def get(self):
     self.template_value['diss'] = Discussion.get_recent()
     self.template_value['bookmarks'] = Bookmark.all().order('-created').fetch(10)
     self.template_value['cats'] =  Category.get_all()
     self.render('index.html')